openstamanager/update/2_4_11.php

90 lines
2.8 KiB
PHP
Raw Normal View History

2019-07-19 15:23:00 +02:00
<?php
2019-08-28 16:58:47 +02:00
// Correzione zz_operations
use Models\User;
2019-08-29 10:25:14 +02:00
use Modules\Emails\Mail;
use Modules\Emails\Template;
2019-08-28 16:58:47 +02:00
$database->query('ALTER TABLE `zz_operations` DROP FOREIGN KEY `zz_operations_ibfk_3`');
$logs = $database->fetchArray("SELECT * FROM `zz_operations` WHERE `op` = 'send-email'");
foreach ($logs as $log) {
$user = User::find($log['id_utente']);
2019-08-29 10:25:14 +02:00
$template = Template::find($log['id_email']);
2019-08-28 16:58:47 +02:00
$mail = Mail::build($user, $template, $log['id_record']);
2019-08-29 10:25:14 +02:00
$mail->resetPrints();
2019-08-28 16:58:47 +02:00
$options = json_decode($log['options'], true);
2019-08-29 10:25:14 +02:00
foreach ($options['receivers'] as $receiver) {
2019-08-28 16:58:47 +02:00
$mail->addReceiver($receiver);
}
2019-08-29 10:25:14 +02:00
foreach ($options['attachments'] as $upload) {
$mail->addUpload($upload);
}
foreach ($options['prints'] as $print) {
$mail->addPrint($print);
}
$sent_at = $log['created_at'] ?: date('Y-m-d H:i:s');
$mail->created_at = $sent_at;
$mail->sent_at = $sent_at;
2019-08-28 16:58:47 +02:00
$mail->save();
$database->query('UPDATE `zz_operations` SET `id_email` = '.prepare($mail->id).' WHERE `id_module` = '.prepare($log['id_module']).' AND `id_email` = '.prepare($log['id_email']).' AND `id_record` = '.prepare($log['id_record']).' AND `options` = '.prepare($log['options']).' AND `created_at` = '.prepare($log['created_at']));
}
$database->query('ALTER TABLE `zz_operations` ADD FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE SET NULL');
// Aggiunta permessi alla gestione documentale
$gruppi = $database->fetchArray('SELECT `id` FROM `zz_groups`');
$viste = $database->fetchArray('SELECT `id` FROM `do_categorie`');
$array = [];
foreach ($viste as $vista) {
foreach ($gruppi as $gruppo) {
$array[] = [
'id_gruppo' => $gruppo['id'],
'id_categoria' => $vista['id'],
];
}
}
if (!empty($array)) {
$database->insert('do_permessi', $array);
}
2019-07-19 15:23:00 +02:00
// File e cartelle deprecate
$files = [
'src\API.php',
2019-08-26 18:02:05 +02:00
'src\Mail.php',
2019-07-29 18:03:02 +02:00
'modules\utenti\api',
'modules\stato_servizi\api',
'modules\stati_preventivo\api',
'modules\stati_intervento\api',
'modules\tipi_intervento\api',
'modules\stati_contratto\api',
'modules\articoli\api',
'modules\anagrafiche\api',
2019-07-19 15:23:00 +02:00
'modules\interventi\api\update.php',
'modules\interventi\api\retrieve.php',
'modules\interventi\api\delete.php',
'modules\interventi\api\create.php',
2019-07-29 18:03:02 +02:00
'modules\aggiornamenti\api',
2019-07-19 15:23:00 +02:00
'plugins\exportFE\src\Connection.php',
'modules\contratti\plugins\addfattura.php',
'modules\contratti\plugins\contratti.fatturaordiniservizio.php',
'modules\contratti\plugins\contratti.ordiniservizio.interventi.php ',
'modules\contratti\plugins\contratti.ordiniservizio.php',
'templates\contratti_cons\body.php',
'templates\preventivi_cons\body.php',
2019-07-19 15:23:00 +02:00
];
foreach ($files as $key => $value) {
$files[$key] = realpath(DOCROOT.'/'.$value);
}
delete($files);