openstamanager/update/2_4_1.php

21 lines
1.0 KiB
PHP
Raw Normal View History

2018-06-26 14:30:26 +02:00
<?php
2018-05-11 15:11:01 +02:00
// Script per aggiornare le date dei movimenti con le date dei documenti
2018-06-26 14:30:26 +02:00
$rs = $dbo->fetchArray('SELECT * FROM mg_movimenti');
2018-05-11 15:11:01 +02:00
2018-06-26 14:30:26 +02:00
for ($i = 0; $i < sizeof($rs); ++$i) {
if ($rs[$i]['idintervento'] != '') {
2018-05-11 15:11:01 +02:00
$rs_data = $dbo->fetchArray("SELECT IFNULL(MAX(orario_fine), data_richiesta) AS data FROM in_interventi LEFT JOIN in_interventi_tecnici ON in_interventi.id=in_interventi_tecnici.idintervento WHERE in_interventi.id='".$rs[$i]['idintervento']."'");
$data = $rs_data[0]['data'];
$dbo->query("UPDATE mg_movimenti SET data='".$data."' WHERE id='".$rs[$i]['id']."'");
2018-06-26 14:30:26 +02:00
} elseif ($rs[$i]['idddt'] != '0') {
2018-05-11 15:11:01 +02:00
$rs_data = $dbo->fetchArray("SELECT data FROM dt_ddt WHERE id='".$rs[$i]['idddt']."'");
$data = $rs_data[0]['data'];
$dbo->query("UPDATE mg_movimenti SET data='".$data."' WHERE id='".$rs[$i]['id']."'");
2018-06-26 14:30:26 +02:00
} elseif ($rs[$i]['iddocumento'] != '0') {
2018-05-11 15:11:01 +02:00
$rs_data = $dbo->fetchArray("SELECT data FROM co_documenti WHERE id='".$rs[$i]['iddocumento']."'");
$data = $rs_data[0]['data'];
}
}