require_once '../include/LSTU_init.inc';
require_once 'include/LSTU_path.inc';
require_once 'LSTM_controlla_staging.php';
require_once 'include/LSTU_fun_log.inc';
require_once 'include/LSTU_controllo_fornitura.inc';
require_once ('include/LSTU_gestione_errori.php.inc');
require_once ('include/LSTM_sql_function.inc');
require_once ('include/LSTM_fun_avvio_awk.inc');
require_once ('include/LSTU_class.prmfile.php.inc');
//08/07/2004 17.45 modificato per unificare style
$logf=$path_log."/impianto.log";
include 'LSTV_home_impianto.php';
$imp=$HTTP_GET_VARS['imp'];
if(isset($_REQUEST['sections'])){
//diretto
list($nomeFileSelezionato,$estensioneFileSelezionato) = explode('.',$_REQUEST['sections']);
}
else
{
//da staging
$nomeFileSelezionato = $_REQUEST['fileselected'];
}
$arrProtOk = getProtStagOK($conn);
if($arrProtOk['err'] != 'NODATA')
{
foreach($arrProtOk as $valueProtOk)
{
$numProtStag = $valueProtOk['TI07_PROTOCOLLO_STAGING'];
$cod_errore_dbti= $valueProtOk['TI07_CODSTATO'];
if ($imp==2)
{
$agg_DBTI="UPDATE tcw17_errlog SET tcw17_last_record = 3,TCW17_DATE=$form_data WHERE TCW17_DESCR_ERR='IMPDBTI' AND tcw17_last_record=1 and tcw17_protocollo = $numProtStag";
list ($st_dbti, $err_dbti) = exec_sql($conn,$agg_DBTI, 1);
$message='Avviata Fase DBTI dopo averne riscontrata una già attiva';
$log=w_log($logf,$message);
}
if ($cod_errore_dbti == 1) {
?>
exit;
}
$tabelle_vuote = isEmpty_table($conn,$numProtStag);
if ($tabelle_vuote) {
jError('E017',$err,0);
js_redirect('LSTV_file_frame.php');
exit;
}
}
}
else
{
JError('E018','',0);
exit();
}
?>
set_time_limit(0);
// ***********************************************************************
// IMPOSTAZIONE CONNESSIONE DB TERRITORIALE INTEGRATO ($conn_dbti)
// ***********************************************************************
if (!isset($conn_dbti) || !$conn_dbti)
$conn_dbti = db_connect(DBTI_USER, DBTI_PWD, DBTI_ALIAS);
if (!$conn_dbti) {
wlog(0, 0, 'Connessione fallita al Database Territoriale Integrato.', 0, 0, APP_PATH.'logs/db_connect.log');
?>
exit;
}
//$query="BEGIN IS_REGIONE.MAIN(:tipo_catasto,:cod_rit); END;";
$query="BEGIN IS_REGIONE.MAIN(:cod_rit); END;";
$stmt=OCIParse($conn_dbti,$query);
if ($stmt) {
$new_rec_dbti="insert into tcw17_errlog values (0,'IMPDBTI',1,$form_data,$numProtStag)";
list ($stmt1, $ocierr1) = exec_sql($conn,$new_rec_dbti, 1);
$msg="Avviato impianto DBTI";
if ($imp!=2) $log=w_log($logf,$msg);
}
if ($stmt === false)
{
$errore = 1;
$ocierr = OCIError($stmt);
?>
exit;
}
//assegnazione variabili php comprese variabili di errore per la gestione
//OCIBindByName($stmt,":tipo_catasto", $tipo_catasto, 1);
OCIBindByName($stmt,":cod_rit", $cod_rit, 2);
//esecuzione
$ex = OCIExecute($stmt,OCI_DEFAULT);
if ($ex === false)
{
$errore = 1;
$ocierr = OCIError($stmt);
?>
exit;
}
//commit
$a=OCICommit($conn_dbti);
if (!$cod_rit && $ex) {
$mess='Il caricamento del DBTI è stato correttamente inserito nella coda dei processi';
$log=w_log($logf,$mess);
}
if ($cod_rit || !$ex) {
$mess='Si è verificato un errore imprevisto';
$log=w_log($logf,$mess);
}
js_redirect ('LSTV_file_frame.php?ricaricata=0',$mess);
?>