openstamanager/update/2_4_2.php

46 lines
1.4 KiB
PHP
Raw Normal View History

2018-07-05 10:07:39 +02:00
<?php
2018-09-06 10:01:08 +02:00
// Script per aggiornare le date dei movimenti con le date dei documenti
$movimenti = $dbo->fetchArray('SELECT * FROM mg_movimenti');
foreach ($movimenti as $movimento) {
$documento = null;
if (!empty($movimento['idintervento'])) {
2018-09-19 09:57:30 +02:00
$documento = $dbo->fetchOne('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='.prepare($movimento['idintervento']));
2018-09-06 10:01:08 +02:00
} elseif (!empty($movimento['idddt'])) {
2018-09-19 09:57:30 +02:00
$documento = $dbo->fetchOne('SELECT data FROM dt_ddt WHERE id='.prepare($movimento['idddt']));
2018-09-06 10:01:08 +02:00
} elseif (!empty($movimento['iddocumento'])) {
2018-09-19 09:57:30 +02:00
$documento = $dbo->fetchOne('SELECT data FROM co_documenti WHERE id='.prepare($movimento['iddocumento']));
2018-09-06 10:01:08 +02:00
}
if (!empty($documento['data'])) {
$dbo->update('mg_movimenti', [
'data' => $documento['data'],
], [
2018-09-19 09:57:30 +02:00
'id' => $movimento['id'],
2018-09-06 10:01:08 +02:00
]);
}
}
$dbo->query("UPDATE mg_movimenti SET data = created_at WHERE data = '0000-00-00'");
2018-09-18 15:57:55 +02:00
2018-09-24 18:10:16 +02:00
// Fix Partite IVA
2020-09-23 11:47:59 +02:00
/*
2018-09-24 18:10:16 +02:00
foreach ($it as $key => $value) {
$dbo->query("UPDATE `an_anagrafiche` SET `piva` = SUBSTRING(`piva`, 2) WHERE `piva` LIKE '".$key."%'");
2020-09-23 11:47:59 +02:00
}*/
2018-09-24 18:10:16 +02:00
2018-09-18 15:57:55 +02:00
// File e cartelle deprecate
$files = [
'docs',
2018-09-19 09:57:30 +02:00
'couscous.yml',
2018-09-18 15:57:55 +02:00
];
foreach ($files as $key => $value) {
$files[$key] = realpath(base_dir().'/'.$value);
2018-09-18 15:57:55 +02:00
}
delete($files);