1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-24 06:30:20 +01:00
openstamanager/update/2_4_1.php

42 lines
1.6 KiB
PHP
Raw Normal View History

2018-06-26 14:30:26 +02:00
<?php
2018-07-03 11:59:33 +02:00
/*
* Inserimento valori di default
*/
// Permessi di default delle viste
$gruppi = $database->fetchArray('SELECT `id` FROM `zz_groups`');
$results = $database->fetchArray('SELECT `id` FROM `zz_views` WHERE `id` NOT IN (SELECT `id_vista` FROM `zz_group_view`)');
$array = [];
foreach ($results as $result) {
foreach ($gruppi as $gruppo) {
$array[] = [
'id_gruppo' => $gruppo['id'],
'id_vista' => $result['id'],
];
}
}
if (!empty($array)) {
$database->insert('zz_group_view', $array);
}
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'];
}
}