Aggiunto log grafico delle email
This commit is contained in:
parent
7a7bcf6e68
commit
3f5a9ccec3
14
actions.php
14
actions.php
|
@ -72,15 +72,15 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||||
} elseif (post('op') == 'send-email') {
|
} elseif (post('op') == 'send-email') {
|
||||||
$id_template = post('template');
|
$id_template = post('template');
|
||||||
|
|
||||||
// Informazioni di log
|
|
||||||
Filter::set('get', 'id_email', $id_template);
|
|
||||||
|
|
||||||
// Inizializzazione
|
// Inizializzazione
|
||||||
$mail = new Notifications\EmailNotification();
|
$mail = new Notifications\EmailNotification();
|
||||||
$mail->setTemplate($id_template, $id_record);
|
$mail->setTemplate($id_template, $id_record);
|
||||||
|
|
||||||
// Destinatari
|
// Destinatari
|
||||||
$receivers = post('destinatari');
|
$receivers = post('destinatari');
|
||||||
|
$receivers = array_filter($receivers, function ($value) {
|
||||||
|
return !empty($value);
|
||||||
|
});
|
||||||
$types = post('tipo_destinatari');
|
$types = post('tipo_destinatari');
|
||||||
foreach ($receivers as $key => $receiver) {
|
foreach ($receivers as $key => $receiver) {
|
||||||
$mail->addReceiver($receiver, $types[$key]);
|
$mail->addReceiver($receiver, $types[$key]);
|
||||||
|
@ -120,6 +120,14 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||||
try {
|
try {
|
||||||
$mail->send(true); // Il valore true impone la gestione degli errori tramite eccezioni
|
$mail->send(true); // Il valore true impone la gestione degli errori tramite eccezioni
|
||||||
|
|
||||||
|
// Informazioni di log
|
||||||
|
Filter::set('get', 'id_email', $id_template);
|
||||||
|
Filter::set('get', 'operations_options', [
|
||||||
|
'receivers' => $receivers,
|
||||||
|
'prints' => post('prints'),
|
||||||
|
'attachments' => post('attachments'),
|
||||||
|
]);
|
||||||
|
|
||||||
flash()->info(tr('Email inviata correttamente!'));
|
flash()->info(tr('Email inviata correttamente!'));
|
||||||
} catch (PHPMailer\PHPMailer\Exception $e) {
|
} catch (PHPMailer\PHPMailer\Exception $e) {
|
||||||
flash()->error(tr("Errore durante l'invio dell'email").': '.$e->errorMessage());
|
flash()->error(tr("Errore durante l'invio dell'email").': '.$e->errorMessage());
|
||||||
|
|
|
@ -351,9 +351,6 @@ if ($read_only || !empty($block_edit)) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (!empty($advanced_sessions)) {
|
if (!empty($advanced_sessions)) {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -210,18 +210,20 @@ function translateTemplate()
|
||||||
$id_record = filter('id_record');
|
$id_record = filter('id_record');
|
||||||
$id_parent = filter('id_parent');
|
$id_parent = filter('id_parent');
|
||||||
$id_email = filter('id_email');
|
$id_email = filter('id_email');
|
||||||
|
$info = filter('operations_options');
|
||||||
|
|
||||||
$id_module = Modules::getCurrent()['id'];
|
$id_module = Modules::getCurrent()['id'];
|
||||||
$id_plugin = Plugins::getCurrent()['id'];
|
$id_plugin = Plugins::getCurrent()['id'];
|
||||||
|
|
||||||
$template = ob_get_clean();
|
|
||||||
|
|
||||||
$template = \HTMLBuilder\HTMLBuilder::replace($template);
|
$template = ob_get_clean();
|
||||||
|
|
||||||
$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 = \HTMLBuilder\HTMLBuilder::replace($template);
|
||||||
|
|
||||||
// Informazioni estese sulle azioni dell'utente
|
// Informazioni estese sulle azioni dell'utente
|
||||||
if (Auth::check() && !empty(post('op'))) {
|
if (Auth::check() && !empty(post('op'))) {
|
||||||
$database = database();
|
$database = database();
|
||||||
|
@ -233,6 +235,7 @@ function translateTemplate()
|
||||||
'id_email' => !empty($id_email) ? $id_email : null,
|
'id_email' => !empty($id_email) ? $id_email : null,
|
||||||
'id_utente' => Auth::user()['id'],
|
'id_utente' => Auth::user()['id'],
|
||||||
'op' => post('op'),
|
'op' => post('op'),
|
||||||
|
'options' => !empty($info) ? json_encode($info) : null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ if (!empty($google)) {
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "select", "label": "<?php echo tr('Ritenuta d\'acconto predefinita'); ?>", "name": "id_ritenuta_acconto_vendite", "values": "query=SELECT id, descrizione FROM co_ritenutaacconto ORDER BY descrizione ASC", "value": "$id_ritenuta_acconto_vendite$", "extra": "<?php echo ($cliente) ? '' : 'readonly'; ?>" ]}
|
{[ "type": "select", "label": "<?php echo tr('Ritenuta d\'acconto predefinita'); ?>", "name": "id_ritenuta_acconto_vendite", "values": "query=SELECT id, descrizione FROM co_ritenutaacconto ORDER BY descrizione ASC", "value": "$id_ritenuta_acconto_vendite$", "extra": "<?php echo ($cliente) ? '' : 'readonly'; ?>" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "select", "label": "<?php echo tr('Listino articoli'); ?>", "name": "idlistino_vendite", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_vendite$", "extra": "<?php echo ($cliente) ? '' : 'readonly'; ?>" ]}
|
{[ "type": "select", "label": "<?php echo tr('Listino articoli'); ?>", "name": "idlistino_vendite", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_vendite$", "extra": "<?php echo ($cliente) ? '' : 'readonly'; ?>" ]}
|
||||||
</div>
|
</div>
|
||||||
|
@ -430,7 +430,7 @@ if (!empty($google)) {
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ echo '
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$("#categoria").change( function(){
|
$("#categoria").change( function(){
|
||||||
|
|
|
@ -432,7 +432,9 @@ if (!empty($elementi)) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>", "ajax": "true" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<a class="btn btn-danger ask" data-backto="record-list">
|
<a class="btn btn-danger ask" data-backto="record-list">
|
||||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||||
|
|
|
@ -207,7 +207,6 @@ if ($record['flag_completato'] == 0) {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
include $docroot.'/modules/ddt/row-list.php';
|
include $docroot.'/modules/ddt/row-list.php';
|
||||||
?>
|
?>
|
||||||
|
@ -216,7 +215,9 @@ include $docroot.'/modules/ddt/row-list.php';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#idanagrafica').change( function(){
|
$('#idanagrafica').change( function(){
|
||||||
|
@ -226,8 +227,6 @@ include $docroot.'/modules/ddt/row-list.php';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Collegamenti diretti
|
// Collegamenti diretti
|
||||||
// Fatture collegate a questo ddt
|
// Fatture collegate a questo ddt
|
||||||
|
|
|
@ -400,7 +400,7 @@ include $docroot.'/modules/fatture/row-list.php';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#idanagrafica').change( function(){
|
$('#idanagrafica').change( function(){
|
||||||
|
@ -430,37 +430,12 @@ if (!empty($note_accredito)) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
// Visualizzo il log delle operazioni di invio email
|
|
||||||
$operations = $dbo->fetchArray('SELECT created_at, (SELECT name FROM zz_emails WHERE id = id_email) AS email, (SELECT username FROM zz_users WHERE id = id_utente) AS user FROM zz_operations WHERE id_record = '.prepare($id_record).' AND op = "send-email" ORDER BY created_at DESC');
|
|
||||||
|
|
||||||
// Se la mail è stata inviata, mostro la data
|
|
||||||
if (!empty($operations)) {
|
|
||||||
foreach ($operations as $operation) {
|
|
||||||
echo '
|
|
||||||
<span class="label label-success pull-right">
|
|
||||||
'.tr('Email "_EMAIL_" inviata il _DATE_ alle _HOUR_ da _USER_.', [
|
|
||||||
'_EMAIL_' => $operation['email'],
|
|
||||||
'_DATE_' => Translator::dateToLocale($operation['created_at']),
|
|
||||||
'_HOUR_' => Translator::timeToLocale($operation['created_at']),
|
|
||||||
'_USER_' => $operation['user'],
|
|
||||||
]).'
|
|
||||||
</span><br>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
echo '
|
|
||||||
<span class="label label-warning pull-right">
|
|
||||||
'.tr('Nessuna email inviata al cliente.').'
|
|
||||||
</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<a class="btn btn-danger ask" data-backto="record-list">
|
<a class="btn btn-danger ask" data-backto="record-list">
|
||||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -42,7 +42,7 @@ include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<a class="btn btn-danger ask" data-backto="record-list">
|
<a class="btn btn-danger ask" data-backto="record-list">
|
||||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||||
|
|
|
@ -251,7 +251,7 @@ $_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>", <?php echo ($record['flag_completato']) ? '"readonly": 1' : '"readonly": 0'; ?> )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$", <?php echo ($record['flag_completato']) ? '"readonly": 1' : '"readonly": 0'; ?> )}
|
||||||
|
|
||||||
<!-- EVENTUALE FIRMA GIA' EFFETTUATA -->
|
<!-- EVENTUALE FIRMA GIA' EFFETTUATA -->
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
@ -319,12 +319,12 @@ $_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script src="<?php echo $rootdir; ?>/modules/interventi/js/interventi_helperjs.js"></script>
|
<script src="<?php echo $rootdir; ?>/modules/interventi/js/interventi_helperjs.js"></script>
|
||||||
|
|
||||||
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Collegamenti diretti
|
// Collegamenti diretti
|
||||||
// Fatture collegate a questo intervento
|
// Fatture collegate a questo intervento
|
||||||
|
|
|
@ -111,7 +111,7 @@ if (!empty($record['immagine'])) {
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<a class="btn btn-danger ask" data-backto="record-list">
|
<a class="btn btn-danger ask" data-backto="record-list">
|
||||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||||
|
|
|
@ -136,7 +136,9 @@ if ($module['name'] == 'Ordini cliente') {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Collegamenti diretti
|
// Collegamenti diretti
|
||||||
|
|
|
@ -209,7 +209,9 @@ if (!empty($elementi)) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
||||||
|
|
||||||
<a class="btn btn-danger ask" data-backto="record-list">
|
<a class="btn btn-danger ask" data-backto="record-list">
|
||||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||||
|
|
|
@ -79,6 +79,7 @@ class HTMLBuilder
|
||||||
'csrf' => Manager\CSRFManager::class,
|
'csrf' => Manager\CSRFManager::class,
|
||||||
'custom_fields' => Manager\FieldManager::class,
|
'custom_fields' => Manager\FieldManager::class,
|
||||||
'widgets' => Manager\WidgetManager::class,
|
'widgets' => Manager\WidgetManager::class,
|
||||||
|
'log_email' => Manager\EmailManager::class,
|
||||||
],
|
],
|
||||||
'instances' => [],
|
'instances' => [],
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace HTMLBuilder\Manager;
|
||||||
|
|
||||||
|
use Translator;
|
||||||
|
use Prints;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gestione allegati.
|
||||||
|
*
|
||||||
|
* @since 2.4.2
|
||||||
|
*/
|
||||||
|
class EmailManager implements ManagerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Gestione "log_email".
|
||||||
|
* Esempio: {( "name": "log_email", "id_module": "2", "id_record": "1" )}.
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function manage($options)
|
||||||
|
{
|
||||||
|
$database = database();
|
||||||
|
|
||||||
|
// Visualizzo il log delle operazioni di invio email
|
||||||
|
$operations = $database->fetchArray('SELECT created_at, options, (SELECT name FROM zz_emails WHERE id = id_email) AS email, (SELECT username FROM zz_users WHERE id = id_utente) AS user FROM zz_operations WHERE id_record = '.prepare($options['id_record']).' AND id_module = '.prepare($options['id_module']).' AND op = "send-email" AND id_email IS NOT NULL ORDER BY created_at DESC');
|
||||||
|
|
||||||
|
if (empty($operations)) {
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Codice HTML
|
||||||
|
$result .= '
|
||||||
|
<div class="box box-info collapsable collapsed-box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title"><i class="fa fa-envelope"></i> '.tr('Email inviate: _NUM_', [
|
||||||
|
'_NUM_' => count($operations),
|
||||||
|
]).'</h3>
|
||||||
|
<div class="box-tools pull-right">
|
||||||
|
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<ul>';
|
||||||
|
|
||||||
|
foreach ($operations as $operation) {
|
||||||
|
$options = json_decode($operation['options'], true);
|
||||||
|
$receivers = $options['receivers'];
|
||||||
|
|
||||||
|
$prints = [];
|
||||||
|
foreach ($options['prints'] as $print) {
|
||||||
|
$print = Prints::get($print);
|
||||||
|
|
||||||
|
$prints[] = $print['title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$attachments = [];
|
||||||
|
foreach ($options['attachments'] as $attachment) {
|
||||||
|
$attachment = $database->selectOne('zz_files', '*', ['id' => $attachment]);
|
||||||
|
;
|
||||||
|
|
||||||
|
$attachments[] = $attachment['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result .= '
|
||||||
|
<li>
|
||||||
|
'.tr('Email "_EMAIL_" inviata il _DATE_ alle _HOUR_ da _USER_', [
|
||||||
|
'_EMAIL_' => $operation['email'],
|
||||||
|
'_DATE_' => Translator::dateToLocale($operation['created_at']),
|
||||||
|
'_HOUR_' => Translator::timeToLocale($operation['created_at']),
|
||||||
|
'_USER_' => $operation['user'],
|
||||||
|
]).'.
|
||||||
|
<ul>
|
||||||
|
<li><b>'.tr('Destinatari').'</b>: '.implode(', ', $receivers).'.</li>';
|
||||||
|
|
||||||
|
if (!empty($prints)) {
|
||||||
|
$result .= '
|
||||||
|
<li><b>'.tr('Stampe').'</b>: '.implode(', ', $prints).'.</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($attachments)) {
|
||||||
|
$result .= '
|
||||||
|
<li><b>'.tr('Allegati').'</b>: '.implode(', ', $attachments).'.</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$result .= '
|
||||||
|
</ul>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$result .= '
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -126,7 +126,7 @@ class Prints
|
||||||
|
|
||||||
$modutil = Modules::filepath($infos['id_module'], 'modutil.php');
|
$modutil = Modules::filepath($infos['id_module'], 'modutil.php');
|
||||||
if (!empty($modutil)) {
|
if (!empty($modutil)) {
|
||||||
include $modutil;
|
include_once $modutil;
|
||||||
}
|
}
|
||||||
|
|
||||||
Permissions::addModule($infos['id_module']);
|
Permissions::addModule($infos['id_module']);
|
||||||
|
|
Loading…
Reference in New Issue