openstamanager/update/2_4_11.php

64 lines
2.2 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\Mail;
use Models\MailTemplate;
use Models\User;
$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']);
$template = MailTemplate::find($log['id_email']);
$mail = Mail::build($user, $template, $log['id_record']);
$options = json_decode($log['options'], true);
$mail->attachments = $options['attachments'] ?: [];
$mail->prints = $options['prints'] ?: [];
foreach ($options['receivers'] as $receiver){
$mail->addReceiver($receiver);
}
$mail->created_at = $log['created_at'];
$mail->sent_at = $log['created_at'];
$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');
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);