Subversion Repositories Sigmater

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 Andrea 1
<?
2
//funzione costruzione select per controllo in tabella protocolli esistenza istanza della fornitura attuale
3
 function	getSelectProtocollo($connect,$arrDatiFornitura)
4
{
5
	$sql	=	'';
6
	if(trim($arrDatiFornitura['sez'])	==	'')
7
	{
8
		$arrDatiFornitura['sez']	=	' ';
9
	}
10
 
11
    //07/06/2004 13.15 inserito ordinamento e conversione data
12
	$sql	=	"select
13
				TI07_PROTOCOLLO,
14
				TI07_PROTOCOLLO_STAGING,
15
				TI07_KEYCOM,
16
				TI07_KEYSEZ,
17
				to_char(TI07_PERIODO_DA,'DD/MM/YYYY') TI07_PERIODO_DA,
18
				to_char(TI07_PERIODO_A,'DD/MM/YYYY') TI07_PERIODO_A,
19
				TI07_TIPO_FORNITURA,
20
				TI07_TIPO_PROCESSO,
21
				TI07_PROT_DBTI,
22
				TI07_CODSTATO
23
			from s3_ti07_protocolli where ti07_keycom = '".$arrDatiFornitura['codcom']."'".
24
	" and ti07_keysez = '".$arrDatiFornitura['sez']."'".
25
	" and ti07_tipo_processo = '".$arrDatiFornitura['tipocatasto']."'";
26
 
27
    $sql	.=	" order by  ti07_protocollo_staging desc";
28
	list($result, $err) = exec_select_format($connect, $sql,1);
29
 
30
	return(array($err,$result));
31
 
32
}
33
function	getSequenceProtocollo($connect)
34
{
35
	$sql		=	'';
36
	$sql		=	"select  ti07_seq.nextval SEQUENCE from dual";
37
 
38
	list($result, $err) = exec_select_format($connect, $sql,1);
39
	return(array($err,$result[0]['SEQUENCE']));
40
}
41
function	getSequenceProtStag($connect)
42
{
43
	$sql	=	'';
44
	$sql	=	"select  ti07_staging_seq.nextval SEQUENCE from dual";
45
	list($result, $err) = exec_select_format($connect, $sql,1);
46
	return(array($err,$result[0]['SEQUENCE']));
47
}
48
 
49
function	insetProtocolS3_ti07($connect,$arrArg)
50
{
51
	$sql	=	'';
52
	$err	=	0;
53
	$sql	="insert into s3_ti07_protocolli values (".
54
											$arrArg['protocollo'].","
55
											.$arrArg['protocollo_stag'].","
56
											."'".$arrArg['keycom']."',"
57
											."'".($arrArg['keysez']==''?' ':$arrArg['keysez'])."',"
58
											."to_date('".$arrArg['periodo_da']."','DD/MM/YYYY'),"
59
											."to_date('".$arrArg['periodo_a']."','DD/MM/YYYY'),"
60
											."'".$arrArg['tipo_fornitura']."',"
61
											."'".$arrArg['tipo_processo']."',"
62
											."null,"
63
											."null,"
64
											."'".$arrArg['nome_fornitura']."'"
65
 
66
										.")";
67
 
68
	list ($stmt, $ocierr) = exec_sql($connect, $sql, 1);
69
 
70
	if (!$stmt) {
71
     		$err = $ocierr;
72
	}
73
	return($err);
74
}
75
function	insetTcw17_errlog($connect,$arrArg)
76
{
77
	$sql	=	'';
78
	$err	=	0;
79
	$sql	="insert into tcw17_errlog values (".
80
											$arrArg['TCW17_STEP'].","
81
											."'".$arrArg['TCW17_DESCR_ERR']."',"
82
											.$arrArg['TCW17_LAST_RECORD'].","
83
											."to_date('".$arrArg['TCW17_DATE']."','DD/MM/YYYY'),"
84
											.$arrArg['TCW17_PROTOCOLLO']
85
											.")";
86
 
87
	list ($stmt, $ocierr) = exec_sql($connect, $sql, 1);
88
 
89
	if (!$stmt) {
90
     		$err = $ocierr;
91
	}
92
	return($err);
93
}
94
function	updateProtocolS3_ti07($connect,$value,$where)
95
{
96
	$sql	=	'';
97
	$err	=	0;
98
	$sql	="update  s3_ti07_protocolli set $value where $where";
99
 
100
	list ($stmt, $ocierr) = exec_sql($connect, $sql, 1);
101
	//echo $sql."<br>";
102
	if (!$stmt) {
103
     		$err = 1;
104
	}
105
	return($err);
106
}
107
function	updateTcw17_errlog($connect,$value,$where)
108
{
109
	$sql	=	'';
110
	$err	=	0;
111
	$sql	="update  TCW17_ERRLOG set $value where $where";
112
 
113
	list ($stmt, $ocierr) = exec_sql($connect, $sql, 1);
114
 
115
	if (!$stmt) {
116
     		$err = 1;
117
	}
118
	return($err);
119
}
120
 
121
function getTcw17_errlog($connect,$protStag)
122
{
123
	$sql_select	=	'';
124
	$sql_select	="SELECT TCW17_STEP, TCW17_DESCR_ERR, TCW17_LAST_RECORD, TCW17_DATE FROM tcw17_errlog WHERE tcw17_protocollo = $protStag ORDER BY TCW17_DATE DESC";
125
	//23/06/2004 18.29	ricerco protocolli cancellati o in caricamento
126
	$arrReturn	=	Array();
127
 
128
	list($result, $err) = exec_select_format($connect, $sql_select,1);
129
	if ($err == 'NODATA') {
130
	   //nessun dato
131
		$return	=	array(
132
						'err'			=>	'NODATA',
133
						'message'	=>	''
134
					);
135
	}
136
	elseif ($err != '') {
137
	  //errore
138
		$return	=	array(
139
							'err'			=>   'E008',
140
							'message'	=>	$err.' '.$sql_select
141
						);
142
	}
143
	else {
144
	 //ok
145
	 	$return	=	$result;
146
	}
147
 
148
	return($return);
149
}
150
 
151
function protIsDeleted($connect,$protStag)
152
{
153
	$sql_select	=	'';
154
	$sql_select	="SELECT TCW17_STEP, TCW17_DESCR_ERR, TCW17_LAST_RECORD, TCW17_DATE FROM tcw17_errlog WHERE TCW17_DESCR_ERR = 'IMPDBDELETE'	and tcw17_protocollo = $protStag";
155
	$arrReturn	=	Array();
156
	list($result, $err) = exec_select_format($connect, $sql_select,1);
157
 
158
	if ($err == 'NODATA') {
159
	  	 //nessun dato
160
		$return	=	false;
161
	}
162
	elseif ($err != '') {
163
	  //errore
164
		$return	=	array(
165
							'err'			=>   'E008',
166
							'message'	=>	$err.' '.$sql_select
167
						);
168
	}
169
	else {
170
	 //ok
171
	 	$return	=	true;
172
 
173
	}
174
 
175
	return($return	);
176
}
177
 
178
//	Funzione estrae protocolo e protocollo di staging dalla sequence e inserisce nellan ti07_protocolli
179
//	array(
180
//	'protocollo'		=>	$numProt,
181
//	'protocollo_stag'	=>	$numProtStag,
182
//	'keycom'			=>	$p_prm->getCodCom(),
183
//	'keysez'			=>	$p_prm->getSez(),
184
//	'periodo_da'		=>	$p_prm->getDataRegDa(),
185
//	'periodo_a'		=>	$p_prm->getDataRegA(),
186
//	'tipo_fornitura'		=>	$p_prm->getTipoFornitura(),
187
//	'tipo_processo'	=>	$p_prm->getTipoCatasto('1')
188
//	)
189
function newStag($conn,$arrPrm)
190
{
191
	//caricamento fornitura differente
192
	//controllo date validita
193
	//nuovo caricamento
194
	$err					=	'';
195
	$ti07_tipo_fornitura	=	'';
196
	$ti07_periodo_da		=	'';
197
	$ti07_periodo_a			=	'';
198
	$numProt				=	0;
199
	$numProtStag			=	0;
200
 
201
	list($err,$numProt)		=	getSequenceProtocollo($conn);
202
	if($err	!=	'')
203
	{
204
		 jError('E002',$err,1);
205
		 exit();
206
	}
207
 
208
	list($err,$numProtStag)		=	getSequenceProtStag($conn);
209
	if($err	!=	'')
210
	{
211
		 jError('E003',$err,1);
212
		 exit();
213
	}
214
 
215
 
216
	$arrPrm['protocollo']		=	$numProt;
217
	$arrPrm['protocollo_stag']	=	$numProtStag;
218
 
219
	$err				=	insetProtocolS3_ti07($conn,$arrPrm);
220
	if($err	!=	'')
221
	{
222
		 JError('E004',$err,1);
223
	}
224
 
225
 
226
	$ti07_tipo_fornitura	=	$arrPrm['tipo_fornitura'];
227
	$ti07_periodo_da	=	$arrPrm['periodo_da'];
228
	$ti07_periodo_a		=	(trim($arrPrm['periodo_a'])	==	''?'':$arrPrm['periodo_a']);
229
	return(
230
			array(
231
					'err'			=>	$err,
232
					'protocollo'		=>	$numProt,
233
					'protocollo_stag'	=>	$numProtStag,
234
					'tipo_fornitura'	=>	$ti07_tipo_fornitura,
235
					'periodo_da'		=>	$ti07_periodo_da,
236
					'periodo_a'		=>	$ti07_periodo_a
237
			)
238
	);
239
 
240
}
241
 
242
 function	getSelectProtocolloDbti($connect)
243
{
244
	$sql	=	'';
245
 
246
	$sql	=	"select
247
 
248
				TI07_PROTOCOLLO_STAGING,
249
				TI07_KEYCOM,
250
				TI07_KEYSEZ,
251
				TI07_TIPO_FORNITURA,
252
				TI07_TIPO_PROCESSO,
253
				TI07_PROT_DBTI,
254
				TI07_CODSTATO,
255
				TI07_NOME_FORNITURA
256
			from s3_ti07_protocolli	where TI07_CODSTATO is null  or  TI07_CODSTATO != 2";
257
	list($result, $err) = exec_select_format($connect, $sql,1);
258
 
259
	if ($err == 'NODATA') {
260
	   //nessun dato
261
		$return	=	array(
262
						'err'			=>	'NODATA',
263
						'message'	=>	''
264
					);
265
	}
266
	elseif ($err != '') {
267
	  //errore
268
		$return	=	array(
269
							'err'			=>   'Errore',
270
							'message'	=>	$err.' '.$sql_select
271
						);
272
	}
273
	else {
274
		return(array($err,$result));
275
	}
276
 
277
}
278
 
279
function getProtStagOK($connect)
280
{
281
	$sql_select	=	'';
282
 
283
	$sql_select	="select TI07_NOME_FORNITURA,TI07_PROTOCOLLO_STAGING,TI07_CODSTATO from S3_TI07_PROTOCOLLI a,TCW17_ERRLOG b where (a.TI07_PROTOCOLLO_STAGING like b.TCW17_PROTOCOLLO) and ((b.TCW17_DESCR_ERR like 'IMPDBOK')OR(b.TCW17_DESCR_ERR like 'IMPDBRIPROK')) AND (A.TI07_CODSTATO <> 2 OR A.TI07_CODSTATO IS NULL)";
284
 
285
	$arrReturn	=	Array();
286
 
287
	list($result, $err) = exec_select_format($connect, $sql_select,1);
288
	if ($err == 'NODATA') {
289
	   //nessun dato
290
		$return	=	array(
291
						'err'			=>	'NODATA',
292
						'message'	=>	''
293
					);
294
	}
295
	elseif ($err != '') {
296
	  //errore
297
		$return	=	array(
298
							'err'			=>   'E016',
299
							'message'	=>	$err.' '.$sql_select
300
						);
301
	}
302
	else {
303
	 	$return	=	$result;
304
	}
305
 
306
	return($return);
307
}
308
 
309
function	getOracleDate($connect)
310
{
311
 
312
	$sql_select	=	'';
313
 
314
	//$sql_select	="select to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') data from dual";
315
	$sql_select	="select to_char(sysdate,'dd/mm/yyyy') data from dual";
316
	$arrReturn	=	Array();
317
 
318
	list($result, $err) = exec_select_format($connect, $sql_select,1);
319
	if ($err == 'NODATA') {
320
	   //nessun dato
321
		$return	=	array(
322
						'err'			=>	'NODATA',
323
						'message'	=>	''
324
					);
325
	}
326
	elseif ($err != '') {
327
	  //errore
328
		$return	=	array(
329
							'err'			=>   'E016',
330
							'message'	=>	$err.' '.$sql_select
331
						);
332
	}
333
	else {
334
		//print_r($result);
335
	 	$return	=	$result[0]['DATA'];
336
	}
337
 
338
	return($return);
339
}
340
?>