mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-21 05:50:55 +01:00
Introduzione operazioni utente
Introduzione delle operazioni utente (issue #137) e dell'email per la Fatturazione Elettronica. Gli XML vengono ora registrati come allegati.
This commit is contained in:
parent
45ee5f8b7b
commit
3f1f2a85b4
84
actions.php
84
actions.php
@ -16,7 +16,7 @@ if (!empty($id_plugin)) {
|
|||||||
$permesso = $id_module;
|
$permesso = $id_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = DOCROOT.'/files/'.basename($directory);
|
$upload_dir = DOCROOT.'/'.Uploads::getDirectory($id_module, $id_plugin);
|
||||||
|
|
||||||
$dbo->query('START TRANSACTION');
|
$dbo->query('START TRANSACTION');
|
||||||
|
|
||||||
@ -79,57 +79,13 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
|||||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($id_module).' AND id='.prepare(filter('id')).' AND filename='.prepare(filter('filename')));
|
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($id_module).' AND id='.prepare(filter('id')).' AND filename='.prepare(filter('filename')));
|
||||||
|
|
||||||
download($upload_dir.'/'.$rs[0]['filename'], $rs[0]['original']);
|
download($upload_dir.'/'.$rs[0]['filename'], $rs[0]['original']);
|
||||||
} elseif (filter('op') == 'send-email') {
|
} elseif (post('op') == 'send-email') {
|
||||||
$template = Mail::getTemplate($post['template']);
|
$template = Mail::getTemplate($post['template']);
|
||||||
$id_account = $template['id_smtp'];
|
$id_account = $template['id_smtp'];
|
||||||
|
|
||||||
// Elenco degli allegati
|
// Informazioni di log
|
||||||
$attachments = [];
|
Filter::set('get', 'id_email', $template['id']);
|
||||||
|
|
||||||
// Stampe
|
|
||||||
foreach ($post['prints'] as $print) {
|
|
||||||
$print = Prints::get($print);
|
|
||||||
|
|
||||||
// Utilizzo di una cartella particolare per il salvataggio temporaneo degli allegati
|
|
||||||
$filename = DOCROOT.'/files/attachments/'.$print['title'].' - '.$id_record.'.pdf';
|
|
||||||
|
|
||||||
Prints::render($print['id'], $id_record, $filename);
|
|
||||||
|
|
||||||
$attachments[] = [
|
|
||||||
'path' => $filename,
|
|
||||||
'name' => $print['title'].'.pdf',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allegati del record
|
|
||||||
$selected = [];
|
|
||||||
if (!empty($post['attachments'])) {
|
|
||||||
$selected = $dbo->fetchArray('SELECT * FROM zz_files WHERE id IN ('.implode(',', $post['attachments']).') AND id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($selected as $attachment) {
|
|
||||||
$attachments[] = [
|
|
||||||
'path' => $upload_dir.'/'.$attachment['filename'],
|
|
||||||
'name' => $attachment['nome'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allegati dell'Azienda predefinita
|
|
||||||
$anagrafiche = Modules::get('Anagrafiche');
|
|
||||||
|
|
||||||
$selected = [];
|
|
||||||
if (!empty($post['attachments'])) {
|
|
||||||
$selected = $dbo->fetchArray('SELECT * FROM zz_files WHERE id IN ('.implode(',', $post['attachments']).') AND id_module != '.prepare($id_module));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($selected as $attachment) {
|
|
||||||
$attachments[] = [
|
|
||||||
'path' => DOCROOT.'/files/'.$anagrafiche['directory'].'/'.$attachment['filename'],
|
|
||||||
'name' => $attachment['nome'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preparazione email
|
|
||||||
$mail = new Mail($id_account);
|
$mail = new Mail($id_account);
|
||||||
|
|
||||||
// Conferma di lettura
|
// Conferma di lettura
|
||||||
@ -153,38 +109,13 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destinatari
|
// Destinatari
|
||||||
foreach ($post['destinatari'] as $key => $destinatario) {
|
$mail->addReceivers($post['destinatari'], $post['tipo_destinatari']);
|
||||||
$type = $post['tipo_destinatari'][$key];
|
|
||||||
|
|
||||||
$pieces = explode('<', $destinatario);
|
|
||||||
$count = count($pieces);
|
|
||||||
|
|
||||||
$name = null;
|
|
||||||
if ($count > 1) {
|
|
||||||
$email = substr(end($pieces), 0, -1);
|
|
||||||
$name = substr($destinatario, 0, strpos($destinatario, '<'.$email));
|
|
||||||
} else {
|
|
||||||
$email = $destinatario;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($email)) {
|
|
||||||
if ($type == 'a') {
|
|
||||||
$mail->AddAddress($email, $name);
|
|
||||||
} elseif ($type == 'cc') {
|
|
||||||
$mail->AddCC($email, $name);
|
|
||||||
} elseif ($type == 'bcc') {
|
|
||||||
$mail->AddBCC($email, $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Oggetto
|
// Oggetto
|
||||||
$mail->Subject = $post['subject'];
|
$mail->Subject = $post['subject'];
|
||||||
|
|
||||||
// Allegati
|
// Allegati
|
||||||
foreach ($attachments as $attachment) {
|
$mail->attach($post['prints'], $post['attachments']);
|
||||||
$mail->AddAttachment($attachment['path'], $attachment['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contenuto
|
// Contenuto
|
||||||
$mail->Body = $post['body'];
|
$mail->Body = $post['body'];
|
||||||
@ -195,9 +126,6 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
|||||||
} else {
|
} else {
|
||||||
App::flash()->info(tr('Email inviata correttamente!'));
|
App::flash()->info(tr('Email inviata correttamente!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$id_record);
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Modules::getPermission($permesso) == 'r' || Modules::getPermission($permesso) == 'rw') {
|
if (Modules::getPermission($permesso) == 'r' || Modules::getPermission($permesso) == 'rw') {
|
||||||
|
@ -18,7 +18,6 @@ $redirectHTTPS = false;
|
|||||||
|
|
||||||
// Impostazioni di debug
|
// Impostazioni di debug
|
||||||
$debug = false;
|
$debug = false;
|
||||||
$operations_log = false;
|
|
||||||
|
|
||||||
// Personalizzazione dei gestori dei tag personalizzati
|
// Personalizzazione dei gestori dei tag personalizzati
|
||||||
$HTMLWrapper = null;
|
$HTMLWrapper = null;
|
||||||
|
3
core.php
3
core.php
@ -59,9 +59,6 @@ if (!API::isAPIRequest()) {
|
|||||||
$handlers[] = new StreamHandler($docroot.'/logs/error.log', Monolog\Logger::ERROR);
|
$handlers[] = new StreamHandler($docroot.'/logs/error.log', Monolog\Logger::ERROR);
|
||||||
$handlers[] = new StreamHandler($docroot.'/logs/setup.log', Monolog\Logger::EMERGENCY);
|
$handlers[] = new StreamHandler($docroot.'/logs/setup.log', Monolog\Logger::EMERGENCY);
|
||||||
|
|
||||||
// Impostazione dei log estesi (per monitorare in modo completo le azioni degli utenti)
|
|
||||||
$handlers[] = new StreamHandler($docroot.'/logs/info.log', Monolog\Logger::INFO);
|
|
||||||
|
|
||||||
// Impostazioni di debug
|
// Impostazioni di debug
|
||||||
if (!empty($debug)) {
|
if (!empty($debug)) {
|
||||||
// Ignora gli avvertimenti e le informazioni relative alla deprecazione di componenti
|
// Ignora gli avvertimenti e le informazioni relative alla deprecazione di componenti
|
||||||
|
@ -14,6 +14,9 @@ switch ($op) {
|
|||||||
if ($dbo->isConnected() && $dbo->isInstalled() && Auth::getInstance()->attempt($username, $password)) {
|
if ($dbo->isConnected() && $dbo->isInstalled() && Auth::getInstance()->attempt($username, $password)) {
|
||||||
$_SESSION['keep_alive'] = (filter('keep_alive') != null);
|
$_SESSION['keep_alive'] = (filter('keep_alive') != null);
|
||||||
|
|
||||||
|
// Rimozione log vecchi
|
||||||
|
$dbo->query('DELETE FROM `zz_operations` WHERE DATE_ADD(`created_at`, INTERVAL 30*24*60*60 SECOND) <= NOW()');
|
||||||
|
|
||||||
// Auto backup del database giornaliero
|
// Auto backup del database giornaliero
|
||||||
if (setting('Backup automatico')) {
|
if (setting('Backup automatico')) {
|
||||||
$result = Backup::daily();
|
$result = Backup::daily();
|
||||||
|
@ -435,11 +435,12 @@ function get_client_ip()
|
|||||||
*/
|
*/
|
||||||
function translateTemplate()
|
function translateTemplate()
|
||||||
{
|
{
|
||||||
global $id_module;
|
$id_module = filter('id_module');
|
||||||
global $id_record;
|
$id_plugin = filter('id_plugin');
|
||||||
global $id_plugin;
|
$id_record = filter('id_record');
|
||||||
global $id_parent;
|
|
||||||
global $operations_log;
|
$id_email = filter('id_email');
|
||||||
|
$id_parent = filter('id_parent');
|
||||||
|
|
||||||
$template = ob_get_clean();
|
$template = ob_get_clean();
|
||||||
|
|
||||||
@ -448,19 +449,19 @@ function translateTemplate()
|
|||||||
$template = str_replace('$id_module$', $id_module, $template);
|
$template = str_replace('$id_module$', $id_module, $template);
|
||||||
$template = str_replace('$id_plugin$', $id_plugin, $template);
|
$template = str_replace('$id_plugin$', $id_plugin, $template);
|
||||||
$template = str_replace('$id_record$', $id_record, $template);
|
$template = str_replace('$id_record$', $id_record, $template);
|
||||||
$template = str_replace('$id_parent$', $id_parent, $template);
|
|
||||||
|
|
||||||
// Completamento delle informazioni estese sulle azioni dell'utente
|
// Informazioni estese sulle azioni dell'utente
|
||||||
$infos = App::flash()->getMessage('info');
|
if (Auth::check() && !empty(post('op'))) {
|
||||||
if (Auth::check() && !empty($operations_log) && !empty($infos)) {
|
$database = \Database::getConnection();
|
||||||
$user = Auth::user();
|
|
||||||
$logger = Monolog\Registry::getInstance('logs');
|
|
||||||
|
|
||||||
foreach ($infos as $value) {
|
$database->insert('zz_operations', [
|
||||||
$logger->info($value.PHP_EOL.json_encode([
|
'id_module' => $id_module,
|
||||||
'user' => $user['username'],
|
'id_record' => $id_record,
|
||||||
]));
|
'id_plugin' => !empty($id_plugin) ? $id_plugin : null,
|
||||||
}
|
'id_email' => !empty($id_email) ? $id_email : null,
|
||||||
|
'id_utente' => Auth::user()['id'],
|
||||||
|
'op' => post('op'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibilità con le versioni precedenti
|
// Compatibilità con le versioni precedenti
|
||||||
|
10
mail.php
10
mail.php
@ -91,11 +91,17 @@ echo '
|
|||||||
{[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected).'", "values": "query=SELECT id, title AS text FROM zz_prints WHERE id_module = '.prepare($id_module).' AND enabled=1" ]}
|
{[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected).'", "values": "query=SELECT id, title AS text FROM zz_prints WHERE id_module = '.prepare($id_module).' AND enabled=1" ]}
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
$attachments = [];
|
||||||
|
if ($template['name'] == 'Fattura Elettronica') {
|
||||||
|
$attachments = $dbo->fetchArray('SELECT id FROM zz_files WHERE id_module = '.prepare($module['id']).' AND id_record = '.prepare($id_record).' AND category = \'Fattura elettronica\'');
|
||||||
|
$attachments = array_column($attachments, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
// Allegati
|
// Allegati
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "select", "multiple": "1", "label": "'.tr('Allegati').'", "name": "attachments[]", "values": "query=SELECT id, nome AS text FROM zz_files WHERE id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record)." UNION SELECT id, CONCAT(nome, ' (Azienda)') AS text FROM zz_files WHERE id_module = ".prepare(Modules::get('Anagrafiche')['id'])." AND id_record = (SELECT valore FROM zz_settings WHERE nome = 'Azienda predefinita')\" ]}
|
{[ "type": "select", "multiple": "1", "label": "'.tr('Allegati').'", "name": "attachments[]", "value": "'.implode(',', $attachments).'", "values": "query=SELECT id, nome AS text FROM zz_files WHERE id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record)." UNION SELECT id, CONCAT(nome, ' (Azienda)') AS text FROM zz_files WHERE id_module = ".prepare(Modules::get('Anagrafiche')['id'])." AND id_record = (SELECT valore FROM zz_settings WHERE nome = 'Azienda predefinita')\" ]}
|
||||||
</div>
|
</div>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
@ -136,7 +142,7 @@ echo '
|
|||||||
// Autocompletamento destinatario
|
// Autocompletamento destinatario
|
||||||
if (!empty($variables['id_anagrafica'])) {
|
if (!empty($variables['id_anagrafica'])) {
|
||||||
echo '
|
echo '
|
||||||
$(document).load(globals.rootdir + "/ajax_complete.php?module=Anagrafiche&op=get_email&id_anagrafica='.$variables['id_anagrafica'].'", function(response) {
|
$(document).load(globals.rootdir + "/ajax_complete.php?module=Anagrafiche&op=get_email&id_anagrafica='.$variables['id_anagrafica'].($template['name'] == 'Fattura Elettronica' ? '&type=pec' : '').'", function(response) {
|
||||||
emails = JSON.parse(response);
|
emails = JSON.parse(response);
|
||||||
|
|
||||||
$(".destinatari").each(function(){
|
$(".destinatari").each(function(){
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$r = $dbo->fetchOne('SELECT *,
|
$r = $dbo->fetchOne('SELECT *,
|
||||||
(SELECT email FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS email
|
(SELECT email FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS email,
|
||||||
|
(SELECT pec FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS pec
|
||||||
FROM co_documenti WHERE id='.prepare($id_record));
|
FROM co_documenti WHERE id='.prepare($id_record));
|
||||||
|
|
||||||
// Variabili da sostituire
|
// Variabili da sostituire
|
||||||
return [
|
return [
|
||||||
'email' => $r['email'],
|
'email' => $template['name'] == 'Fattura Elettronica' ? $r['pec'] : $r['email'],
|
||||||
|
'id_anagrafica' => $r['idanagrafica'],
|
||||||
'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'],
|
'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'],
|
||||||
'note' => $r['note'],
|
'note' => $r['note'],
|
||||||
'data' => Translator::dateToLocale($r['data']),
|
'data' => Translator::dateToLocale($r['data']),
|
||||||
|
@ -4,7 +4,7 @@ include_once __DIR__.'/../../core.php';
|
|||||||
|
|
||||||
switch (post('op')) {
|
switch (post('op')) {
|
||||||
case 'add':
|
case 'add':
|
||||||
$dbo->insert('zz_smtp', [
|
$dbo->insert('zz_smtps', [
|
||||||
'name' => $post['name'],
|
'name' => $post['name'],
|
||||||
'from_name' => $post['from_name'],
|
'from_name' => $post['from_name'],
|
||||||
'from_address' => $post['from_address'],
|
'from_address' => $post['from_address'],
|
||||||
@ -17,7 +17,7 @@ switch (post('op')) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
$dbo->update('zz_smtp', [
|
$dbo->update('zz_smtps', [
|
||||||
'name' => $post['name'],
|
'name' => $post['name'],
|
||||||
'note' => $post['note'],
|
'note' => $post['note'],
|
||||||
'server' => $post['server'],
|
'server' => $post['server'],
|
||||||
@ -32,7 +32,7 @@ switch (post('op')) {
|
|||||||
], ['id' => $id_record]);
|
], ['id' => $id_record]);
|
||||||
|
|
||||||
if (!empty($post['main'])) {
|
if (!empty($post['main'])) {
|
||||||
$dbo->query('UPDATE zz_smtp SET main = 0 WHERE id != '.prepare($id_record));
|
$dbo->query('UPDATE zz_smtps SET main = 0 WHERE id != '.prepare($id_record));
|
||||||
}
|
}
|
||||||
|
|
||||||
App::flash()->info(tr('Informazioni salvate correttamente!'));
|
App::flash()->info(tr('Informazioni salvate correttamente!'));
|
||||||
@ -75,7 +75,7 @@ switch (post('op')) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$dbo->query('UPDATE zz_smtp SET deleted = 1 WHERE id='.prepare($id_record));
|
$dbo->query('UPDATE zz_smtps SET deleted = 1 WHERE id='.prepare($id_record));
|
||||||
|
|
||||||
App::flash()->info(tr('Account email eliminato!'));
|
App::flash()->info(tr('Account email eliminato!'));
|
||||||
|
|
||||||
|
@ -36,9 +36,13 @@ switch ($resource) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Email del cliente
|
// Email del cliente
|
||||||
$q = "SELECT DISTINCT(email), ragione_sociale, idanagrafica FROM an_anagrafiche WHERE email != '' ".$where.' ORDER BY idanagrafica';
|
$query = "SELECT DISTINCT(pec) AS email, ragione_sociale, idanagrafica FROM an_anagrafiche WHERE email != '' ".$where;
|
||||||
|
if (empty(get('type'))) {
|
||||||
|
$query .= " UNION SELECT DISTINCT(email), ragione_sociale, idanagrafica FROM an_anagrafiche WHERE email != '' ".$where;
|
||||||
|
}
|
||||||
|
$query .= ' ORDER BY idanagrafica';
|
||||||
|
|
||||||
$rs = $dbo->fetchArray($q);
|
$rs = $dbo->fetchArray($query);
|
||||||
foreach ($rs as $r) {
|
foreach ($rs as $r) {
|
||||||
$results[] = [
|
$results[] = [
|
||||||
'value' => $r['email'],
|
'value' => $r['email'],
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once __DIR__.'/../../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
switch ($resource) {
|
switch ($resource) {
|
||||||
case 'smtp':
|
case 'smtp':
|
||||||
$query = 'SELECT id AS id, name AS descrizione FROM zz_smtp |where| ORDER BY name';
|
$query = 'SELECT id AS id, name AS descrizione FROM zz_smtps |where| ORDER BY name';
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'id = '.prepare($element);
|
$filter[] = 'id = '.prepare($element);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
if (isset($id_record)) {
|
if (isset($id_record)) {
|
||||||
$records = $dbo->fetchArray('SELECT * FROM zz_smtp WHERE id='.prepare($id_record).' AND deleted = 0');
|
$records = $dbo->fetchArray('SELECT * FROM zz_smtps WHERE id='.prepare($id_record).' AND deleted = 0');
|
||||||
}
|
}
|
||||||
|
@ -523,6 +523,22 @@ class FatturaElettronica
|
|||||||
// Salvataggio del file
|
// Salvataggio del file
|
||||||
$result = directory($directory) && file_put_contents(rtrim($directory, '/').'/'.$filename, $this->__toString());
|
$result = directory($directory) && file_put_contents(rtrim($directory, '/').'/'.$filename, $this->__toString());
|
||||||
|
|
||||||
|
// Registrazione come allegato
|
||||||
|
$data = [
|
||||||
|
'original' => $filename,
|
||||||
|
'category' => tr('Fattura elettronica'),
|
||||||
|
'id_module' => \Modules::get('Fatture di vendita')['id'],
|
||||||
|
'id_plugin' => \Plugins::get('Fatturazione Elettronica')['id'],
|
||||||
|
'id_record' => $this->getDocumento()['id'],
|
||||||
|
];
|
||||||
|
$uploads = \Uploads::get($data);
|
||||||
|
|
||||||
|
$registered = in_array($filename, array_column($uploads, 'original'));
|
||||||
|
|
||||||
|
if (!$registered) {
|
||||||
|
\Uploads::register($data);
|
||||||
|
}
|
||||||
|
|
||||||
return ($result === false) ? null : $filename;
|
return ($result === false) ? null : $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
|
$upload_dir = DOCROOT.'/'.Uploads::getDirectory($id_module, $id_plugin);
|
||||||
|
|
||||||
switch (filter('op')) {
|
switch (filter('op')) {
|
||||||
case 'generate':
|
case 'generate':
|
||||||
try {
|
try {
|
||||||
|
113
src/Mail.php
113
src/Mail.php
@ -19,7 +19,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
protected $infos = [];
|
protected $infos = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restituisce tutte le informazioni di tutti i plugin installati.
|
* Restituisce tutte le informazioni di tutti gli account email presenti.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -28,7 +28,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
if (empty(self::$accounts)) {
|
if (empty(self::$accounts)) {
|
||||||
$database = Database::getConnection();
|
$database = Database::getConnection();
|
||||||
|
|
||||||
$results = $database->fetchArray('SELECT * FROM zz_smtp WHERE deleted = 0');
|
$results = $database->fetchArray('SELECT * FROM zz_smtps WHERE deleted = 0');
|
||||||
|
|
||||||
$accounts = [];
|
$accounts = [];
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restituisce le informazioni relative a un singolo modulo specificato.
|
* Restituisce le informazioni relative a un singolo account email specificato.
|
||||||
*
|
*
|
||||||
* @param string|int $template
|
* @param string|int $template
|
||||||
*
|
*
|
||||||
@ -68,7 +68,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restituisce tutte le informazioni di tutti i plugin installati.
|
* Restituisce tutte le informazioni di tutti i template presenti.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -120,7 +120,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restituisce le informazioni relative a un singolo template specificato.
|
* Restituisce le variabili relative a un singolo template specificato.
|
||||||
*
|
*
|
||||||
* @param string|int $template
|
* @param string|int $template
|
||||||
*
|
*
|
||||||
@ -223,6 +223,109 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aggiunge gli allegati all'email.
|
||||||
|
*
|
||||||
|
* @param array $prints
|
||||||
|
* @param array $files
|
||||||
|
*/
|
||||||
|
public function attach($prints, $files)
|
||||||
|
{
|
||||||
|
$id_module = App::getCurrentModule()['id'];
|
||||||
|
$id_record = App::getCurrentElement();
|
||||||
|
|
||||||
|
// Elenco degli allegati
|
||||||
|
$attachments = [];
|
||||||
|
|
||||||
|
// Stampe
|
||||||
|
foreach ($prints as $print) {
|
||||||
|
$print = Prints::get($print);
|
||||||
|
|
||||||
|
// Utilizzo di una cartella particolare per il salvataggio temporaneo degli allegati
|
||||||
|
$filename = DOCROOT.'/files/attachments/'.$print['title'].' - '.$id_record.'.pdf';
|
||||||
|
|
||||||
|
Prints::render($print['id'], $id_record, $filename);
|
||||||
|
|
||||||
|
$attachments[] = [
|
||||||
|
'path' => $filename,
|
||||||
|
'name' => $print['title'].'.pdf',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allegati del record
|
||||||
|
$selected = [];
|
||||||
|
if (!empty($files)) {
|
||||||
|
$selected = $dbo->fetchArray('SELECT * FROM zz_files WHERE id IN ('.implode(',', $files).') AND id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($selected as $attachment) {
|
||||||
|
$attachments[] = [
|
||||||
|
'path' => $upload_dir.'/'.$attachment['filename'],
|
||||||
|
'name' => $attachment['nome'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allegati dell'Azienda predefinita
|
||||||
|
$anagrafiche = Modules::get('Anagrafiche');
|
||||||
|
|
||||||
|
$selected = [];
|
||||||
|
if (!empty($files)) {
|
||||||
|
$selected = $dbo->fetchArray('SELECT * FROM zz_files WHERE id IN ('.implode(',', $files).') AND id_module != '.prepare($id_module));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($selected as $attachment) {
|
||||||
|
$attachments[] = [
|
||||||
|
'path' => DOCROOT.'/files/'.$anagrafiche['directory'].'/'.$attachment['filename'],
|
||||||
|
'name' => $attachment['nome'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiunta allegati
|
||||||
|
foreach ($attachments as $attachment) {
|
||||||
|
$this->AddAttachment($attachment['path'], $attachment['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aggiunge i detinatari.
|
||||||
|
*
|
||||||
|
* @param array $receivers
|
||||||
|
* @param array $types
|
||||||
|
*/
|
||||||
|
public function addReceivers($receivers, $types)
|
||||||
|
{
|
||||||
|
// Destinatari
|
||||||
|
foreach ($receivers as $key => $destinatario) {
|
||||||
|
$type = $types[$key];
|
||||||
|
|
||||||
|
$pieces = explode('<', $destinatario);
|
||||||
|
$count = count($pieces);
|
||||||
|
|
||||||
|
$name = null;
|
||||||
|
if ($count > 1) {
|
||||||
|
$email = substr(end($pieces), 0, -1);
|
||||||
|
$name = substr($destinatario, 0, strpos($destinatario, '<'.$email));
|
||||||
|
} else {
|
||||||
|
$email = $destinatario;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($email)) {
|
||||||
|
if ($type == 'a') {
|
||||||
|
$this->AddAddress($email, $name);
|
||||||
|
} elseif ($type == 'cc') {
|
||||||
|
$this->AddCC($email, $name);
|
||||||
|
} elseif ($type == 'bcc') {
|
||||||
|
$this->AddBCC($email, $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Effettua un test di connessione all'email SMTP.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function testSMTP()
|
public function testSMTP()
|
||||||
{
|
{
|
||||||
if ($this->IsSMTP() && $this->smtpConnect()) {
|
if ($this->IsSMTP() && $this->smtpConnect()) {
|
||||||
|
387
src/Uploads.php
387
src/Uploads.php
@ -7,6 +7,229 @@
|
|||||||
*/
|
*/
|
||||||
class Uploads
|
class Uploads
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Restisuice l'elenco degli allegati registrati per un determinato modulo/plugin e record.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get($data)
|
||||||
|
{
|
||||||
|
$database = Database::getConnection();
|
||||||
|
|
||||||
|
$uploads = $database->select('zz_files', '*', [
|
||||||
|
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
||||||
|
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||||
|
'id_record' => $data['id_record'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $uploads;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restituisce il nome della cartella per l'upload degli allegati per un determinato modulo/plugin.
|
||||||
|
*
|
||||||
|
* @param string|int $id_module
|
||||||
|
* @param string|int $id_plugin
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDirectory($id_module, $id_plugin = null)
|
||||||
|
{
|
||||||
|
if (empty($id_plugin)) {
|
||||||
|
$directory = Modules::get($id_module)['directory'];
|
||||||
|
} else {
|
||||||
|
$info = Plugins::get($id_plugin);
|
||||||
|
|
||||||
|
if (!empty($info['script'])) {
|
||||||
|
$directory = self::fileInfo($info['script'])['filename'];
|
||||||
|
} else {
|
||||||
|
$directory = $info['directory'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'files/'.$directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Effettua l'upload di un file nella cartella indicata.
|
||||||
|
*
|
||||||
|
* @param array $source
|
||||||
|
* @param string $directory
|
||||||
|
* @param array $data
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function upload($source, $data, $options = [])
|
||||||
|
{
|
||||||
|
$src = $source['tmp_name'];
|
||||||
|
$original = $source['name'];
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($original)['extension']);
|
||||||
|
$ok = self::isSupportedType($extension);
|
||||||
|
|
||||||
|
$directory = DOCROOT.'/'.self::getDirectory($data['id_module'], $data['id_plugin']);
|
||||||
|
|
||||||
|
do {
|
||||||
|
$filename = random_string().'.'.$extension;
|
||||||
|
} while (file_exists($directory.'/'.$filename));
|
||||||
|
|
||||||
|
// Creazione file fisico
|
||||||
|
if (!directory($directory) || !move_uploaded_file($src, $directory.'/'.$filename)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registrazione del file
|
||||||
|
$data['filename'] = $filename;
|
||||||
|
$data['original'] = $original;
|
||||||
|
self::register($data);
|
||||||
|
|
||||||
|
if (!empty($options['thumbnails'])) {
|
||||||
|
self::thumbnails($directory.'/'.$filename, $directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registra nel database il file caricato con i dati richiesti.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public static function register($data)
|
||||||
|
{
|
||||||
|
$database = Database::getConnection();
|
||||||
|
|
||||||
|
$database->insert('zz_files', [
|
||||||
|
'nome' => !empty($data['name']) ? $data['name'] : $data['original'],
|
||||||
|
'filename' => !empty($data['filename']) ? $data['filename'] : $data['original'],
|
||||||
|
'original' => $data['original'],
|
||||||
|
'category' => !empty($data['category']) ? $data['category'] : null,
|
||||||
|
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
||||||
|
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||||
|
'id_record' => $data['id_record'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controlla se l'estensione è supportata dal sistema di upload.
|
||||||
|
*
|
||||||
|
* @param string $extension
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function isSupportedType($extension)
|
||||||
|
{
|
||||||
|
return in_array($extension, array_keys(self::$allowed_types));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Genera le thumbnails per le immagini.
|
||||||
|
*
|
||||||
|
* @param string $filepath
|
||||||
|
* @param string $directory
|
||||||
|
*/
|
||||||
|
protected static function thumbnails($filepath, $directory = null)
|
||||||
|
{
|
||||||
|
$fileinfo = self::fileInfo($filepath);
|
||||||
|
$directory = empty($directory) ? dirname($filepath) : $directory;
|
||||||
|
|
||||||
|
$driver = extension_loaded('gd') ? 'gd' : 'imagick';
|
||||||
|
Intervention\Image\ImageManagerStatic::configure(['driver' => $driver]);
|
||||||
|
|
||||||
|
$img = Intervention\Image\ImageManagerStatic::make($filepath);
|
||||||
|
|
||||||
|
$img->resize(600, null, function ($constraint) {
|
||||||
|
$constraint->aspectRatio();
|
||||||
|
});
|
||||||
|
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension']));
|
||||||
|
|
||||||
|
$img->resize(250, null, function ($constraint) {
|
||||||
|
$constraint->aspectRatio();
|
||||||
|
});
|
||||||
|
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb250.'.$fileinfo['extension']));
|
||||||
|
|
||||||
|
$img->resize(100, null, function ($constraint) {
|
||||||
|
$constraint->aspectRatio();
|
||||||
|
});
|
||||||
|
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb100.'.$fileinfo['extension']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elimina l'allegato indicato.
|
||||||
|
*
|
||||||
|
* @param string $filename
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return string Nome del file
|
||||||
|
*/
|
||||||
|
public static function delete($filename, $data)
|
||||||
|
{
|
||||||
|
$database = Database::getConnection();
|
||||||
|
|
||||||
|
$name = $database->selectOne('zz_files', ['nome'], [
|
||||||
|
'filename' => $filename,
|
||||||
|
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
||||||
|
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||||
|
'id_record' => $data['id_record'],
|
||||||
|
])['nome'];
|
||||||
|
|
||||||
|
$fileinfo = self::fileInfo($filename);
|
||||||
|
$directory = DOCROOT.'/'.self::getDirectory($data['id_module'], $data['id_plugin']);
|
||||||
|
|
||||||
|
$files = [
|
||||||
|
$directory.'/'.$fileinfo['basename'],
|
||||||
|
$directory.'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension'],
|
||||||
|
$directory.'/'.$fileinfo['filename'].'_thumb100.'.$fileinfo['extension'],
|
||||||
|
$directory.'/'.$fileinfo['filename'].'_thumb250.'.$fileinfo['extension'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (delete($files)) {
|
||||||
|
$database->delete('zz_files', [
|
||||||
|
'filename' => $fileinfo['basename'],
|
||||||
|
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
||||||
|
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||||
|
'id_record' => $data['id_record'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rimuove tutti gli allegati di un determinato modulo/plugin e record.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public static function deleteLinked($data)
|
||||||
|
{
|
||||||
|
$uploads = self::get($data);
|
||||||
|
|
||||||
|
foreach ($uploads as $upload) {
|
||||||
|
self::delete($upload['filename'], $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restituisce le informazioni relative al file indicato.
|
||||||
|
*
|
||||||
|
* @param string $filepath
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function fileInfo($filepath)
|
||||||
|
{
|
||||||
|
$infos = pathinfo($filepath);
|
||||||
|
$infos['extension'] = strtolower($infos['extension']);
|
||||||
|
|
||||||
|
return $infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var array Elenco delle tipologie di file permesse */
|
||||||
protected static $allowed_types = [
|
protected static $allowed_types = [
|
||||||
// Image formats
|
// Image formats
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
@ -119,168 +342,4 @@ class Uploads
|
|||||||
'wp' => 'application/wordperfect',
|
'wp' => 'application/wordperfect',
|
||||||
'wpd' => 'application/wordperfect',
|
'wpd' => 'application/wordperfect',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getDirectory($id_module, $id_plugin = null)
|
|
||||||
{
|
|
||||||
if (empty($id_plugin)) {
|
|
||||||
$directory = Modules::get($id_module)['directory'];
|
|
||||||
} else {
|
|
||||||
$info = Plugins::get($id_plugin);
|
|
||||||
|
|
||||||
if (!empty($info['script'])) {
|
|
||||||
$directory = self::fileInfo($info['script'])['filename'];
|
|
||||||
} else {
|
|
||||||
$directory = $info['directory'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'files/'.$directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effettua l'upload di un file nella cartella indicata.
|
|
||||||
*
|
|
||||||
* @param array $source
|
|
||||||
* @param string $directory
|
|
||||||
* @param array $data
|
|
||||||
* @param array $options
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function upload($source, $data, $options = [])
|
|
||||||
{
|
|
||||||
$src = $source['tmp_name'];
|
|
||||||
$original = $source['name'];
|
|
||||||
|
|
||||||
$extension = strtolower(pathinfo($original)['extension']);
|
|
||||||
$ok = self::isSupportedType($extension);
|
|
||||||
|
|
||||||
$directory = DOCROOT.'/'.self::getDirectory($data['id_module'], $data['id_plugin']);
|
|
||||||
|
|
||||||
do {
|
|
||||||
$filename = random_string().'.'.$extension;
|
|
||||||
} while (file_exists($directory.'/'.$filename));
|
|
||||||
|
|
||||||
// Creazione file fisico
|
|
||||||
if (!directory($directory) || !move_uploaded_file($src, $directory.'/'.$filename)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$database = Database::getConnection();
|
|
||||||
|
|
||||||
// Registrazione del file
|
|
||||||
$database->insert('zz_files', [
|
|
||||||
'nome' => !empty($data['name']) ? $data['name'] : $original,
|
|
||||||
'filename' => $filename,
|
|
||||||
'original' => $original,
|
|
||||||
'category' => !empty($data['category']) ? $data['category'] : null,
|
|
||||||
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
|
||||||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
|
||||||
'id_record' => $data['id_record'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!empty($options['thumbnails'])) {
|
|
||||||
self::thumbnails($directory.'/'.$filename, $directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controlla se l'estensione è supportata dal sistema di upload.
|
|
||||||
*
|
|
||||||
* @param string $extension
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected static function isSupportedType($extension)
|
|
||||||
{
|
|
||||||
return in_array($extension, array_keys(self::$allowed_types));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function thumbnails($filepath, $directory = null)
|
|
||||||
{
|
|
||||||
$fileinfo = self::fileInfo($filepath);
|
|
||||||
$directory = empty($directory) ? dirname($filepath) : $directory;
|
|
||||||
|
|
||||||
$driver = extension_loaded('gd') ? 'gd' : 'imagick';
|
|
||||||
Intervention\Image\ImageManagerStatic::configure(['driver' => $driver]);
|
|
||||||
|
|
||||||
$img = Intervention\Image\ImageManagerStatic::make($filepath);
|
|
||||||
|
|
||||||
$img->resize(600, null, function ($constraint) {
|
|
||||||
$constraint->aspectRatio();
|
|
||||||
});
|
|
||||||
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension']));
|
|
||||||
|
|
||||||
$img->resize(250, null, function ($constraint) {
|
|
||||||
$constraint->aspectRatio();
|
|
||||||
});
|
|
||||||
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb250.'.$fileinfo['extension']));
|
|
||||||
|
|
||||||
$img->resize(100, null, function ($constraint) {
|
|
||||||
$constraint->aspectRatio();
|
|
||||||
});
|
|
||||||
$img->save(slashes($directory.'/'.$fileinfo['filename'].'_thumb100.'.$fileinfo['extension']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function delete($filename, $data)
|
|
||||||
{
|
|
||||||
$database = Database::getConnection();
|
|
||||||
|
|
||||||
$name = $database->selectOne('zz_files', ['nome'], [
|
|
||||||
'filename' => $filename,
|
|
||||||
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
|
||||||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
|
||||||
'id_record' => $data['id_record'],
|
|
||||||
])['nome'];
|
|
||||||
|
|
||||||
$fileinfo = self::fileInfo($filename);
|
|
||||||
$directory = DOCROOT.'/'.self::getDirectory($data['id_module'], $data['id_plugin']);
|
|
||||||
|
|
||||||
$files = [
|
|
||||||
$directory.'/'.$fileinfo['basename'],
|
|
||||||
$directory.'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension'],
|
|
||||||
$directory.'/'.$fileinfo['filename'].'_thumb100.'.$fileinfo['extension'],
|
|
||||||
$directory.'/'.$fileinfo['filename'].'_thumb250.'.$fileinfo['extension'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (delete($files)) {
|
|
||||||
$database->delete('zz_files', [
|
|
||||||
'filename' => $fileinfo['basename'],
|
|
||||||
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
|
||||||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
|
||||||
'id_record' => $data['id_record'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function deleteLinked($data)
|
|
||||||
{
|
|
||||||
$database = Database::getConnection();
|
|
||||||
|
|
||||||
$uploads = $database->select('zz_files', ['filename'], [
|
|
||||||
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
|
||||||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
|
||||||
'id_record' => $data['id_record'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
foreach ($uploads as $upload) {
|
|
||||||
self::delete($upload['filename'], $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function fileInfo($filepath)
|
|
||||||
{
|
|
||||||
$infos = pathinfo($filepath);
|
|
||||||
$infos['extension'] = strtolower($infos['extension']);
|
|
||||||
|
|
||||||
return $infos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -210,9 +210,30 @@ INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable
|
|||||||
|
|
||||||
ALTER TABLE `an_anagrafiche` ADD `codice_destinatario` varchar(7);
|
ALTER TABLE `an_anagrafiche` ADD `codice_destinatario` varchar(7);
|
||||||
|
|
||||||
|
INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `main`, `deleted`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 1, 'Fattura Elettronica', 'fa fa-file', 'Invio fattura numero {numero} del {data}', '', 'sdi01@pec.fatturapa.it', '', '<p>Gentile Cliente,</p>\r\n<p>inviamo in allegato la fattura numero {numero} del {data}.</p>\r\n<p> </p>\r\n<p>Distinti saluti</p>\r\n', '0', '0', '0');
|
||||||
|
INSERT INTO `zz_email_print` (`id`, `id_email`, `id_print`) VALUES (NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Fattura Elettronica' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Fattura di vendita'));
|
||||||
|
UPDATE `zz_emails` SET `main` = 1 WHERE `name` = 'Fattura' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita');
|
||||||
|
|
||||||
-- Aggiornamento zz_settings
|
-- Aggiornamento zz_settings
|
||||||
ALTER TABLE `zz_settings` CHANGE `idimpostazione` `id` int(11) NOT NULL AUTO_INCREMENT;
|
ALTER TABLE `zz_settings` CHANGE `idimpostazione` `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
UPDATE `zz_views` SET `query` = REPLACE(`query`, 'idimpostazione', 'id');
|
UPDATE `zz_views` SET `query` = REPLACE(`query`, 'idimpostazione', 'id');
|
||||||
|
|
||||||
-- Aggiunta conti in Articoli
|
-- Aggiunta conti in Articoli
|
||||||
ALTER TABLE `mg_articoli` ADD `idconto_vendita` int(11), ADD `idconto_acquisto` int(11);
|
ALTER TABLE `mg_articoli` ADD `idconto_vendita` int(11), ADD `idconto_acquisto` int(11);
|
||||||
|
|
||||||
|
-- Aggiunta log per invio email
|
||||||
|
CREATE TABLE IF NOT EXISTS `zz_operations` (
|
||||||
|
`id_module` int(11) NOT NULL,
|
||||||
|
`id_plugin` int(11),
|
||||||
|
`id_email` int(11),
|
||||||
|
`id_record` int(11) NOT NULL,
|
||||||
|
`id_utente` int(11) NOT NULL,
|
||||||
|
`op` varchar(255) NOT NULL,
|
||||||
|
`options` text,
|
||||||
|
FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
ALTER TABLE `zz_smtp` RENAME `zz_smtps`;
|
||||||
|
@ -15,11 +15,14 @@ $tables = [
|
|||||||
'an_tipianagrafiche',
|
'an_tipianagrafiche',
|
||||||
'an_tipianagrafiche_anagrafiche',
|
'an_tipianagrafiche_anagrafiche',
|
||||||
'an_zone',
|
'an_zone',
|
||||||
|
'co_banche',
|
||||||
'co_contratti',
|
'co_contratti',
|
||||||
|
'co_contratti_promemoria',
|
||||||
'co_contratti_tipiintervento',
|
'co_contratti_tipiintervento',
|
||||||
'co_documenti',
|
'co_documenti',
|
||||||
'co_iva',
|
'co_iva',
|
||||||
'co_movimenti',
|
'co_movimenti',
|
||||||
|
'co_movimenti_modelli',
|
||||||
'co_ordiniservizio',
|
'co_ordiniservizio',
|
||||||
'co_ordiniservizio_pianificazionefatture',
|
'co_ordiniservizio_pianificazionefatture',
|
||||||
'co_ordiniservizio_vociservizio',
|
'co_ordiniservizio_vociservizio',
|
||||||
@ -30,7 +33,8 @@ $tables = [
|
|||||||
'co_preventivi',
|
'co_preventivi',
|
||||||
'co_preventivi_interventi',
|
'co_preventivi_interventi',
|
||||||
'co_righe_contratti',
|
'co_righe_contratti',
|
||||||
'co_contratti_promemoria',
|
'co_righe_contratti_articoli',
|
||||||
|
'co_righe_contratti_materiali',
|
||||||
'co_righe_documenti',
|
'co_righe_documenti',
|
||||||
'co_righe_preventivi',
|
'co_righe_preventivi',
|
||||||
'co_ritenutaacconto',
|
'co_ritenutaacconto',
|
||||||
@ -50,6 +54,12 @@ $tables = [
|
|||||||
'dt_spedizione',
|
'dt_spedizione',
|
||||||
'dt_statiddt',
|
'dt_statiddt',
|
||||||
'dt_tipiddt',
|
'dt_tipiddt',
|
||||||
|
'fe_causali_pagamento_ritenuta',
|
||||||
|
'fe_modalita_pagamento',
|
||||||
|
'fe_natura',
|
||||||
|
'fe_regime_fiscale',
|
||||||
|
'fe_tipi_documento',
|
||||||
|
'fe_tipo_cassa',
|
||||||
'in_interventi',
|
'in_interventi',
|
||||||
'in_interventi_tecnici',
|
'in_interventi_tecnici',
|
||||||
'in_righe_interventi',
|
'in_righe_interventi',
|
||||||
@ -74,20 +84,28 @@ $tables = [
|
|||||||
'or_righe_ordini',
|
'or_righe_ordini',
|
||||||
'or_statiordine',
|
'or_statiordine',
|
||||||
'or_tipiordine',
|
'or_tipiordine',
|
||||||
'zz_tokens',
|
'zz_documenti',
|
||||||
|
'zz_documenti_categorie',
|
||||||
|
'zz_email_print',
|
||||||
|
'zz_emails',
|
||||||
|
'zz_field_record',
|
||||||
|
'zz_fields',
|
||||||
'zz_files',
|
'zz_files',
|
||||||
'zz_groups',
|
'zz_groups',
|
||||||
'zz_group_module',
|
|
||||||
'zz_settings',
|
|
||||||
'zz_logs',
|
'zz_logs',
|
||||||
'zz_modules',
|
'zz_modules',
|
||||||
'zz_plugins',
|
'zz_operations',
|
||||||
'zz_permissions',
|
'zz_permissions',
|
||||||
'zz_users',
|
'zz_plugins',
|
||||||
'zz_widgets',
|
'zz_prints',
|
||||||
'zz_views',
|
'zz_segments',
|
||||||
'zz_group_view',
|
|
||||||
'zz_semaphores',
|
'zz_semaphores',
|
||||||
|
'zz_settings',
|
||||||
|
'zz_smtps',
|
||||||
|
'zz_tokens',
|
||||||
|
'zz_users',
|
||||||
|
'zz_views',
|
||||||
|
'zz_widgets',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user