1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-29 07:02:41 +01:00

Potenziamento modulo newsletter

This commit is contained in:
Luca 2021-05-31 16:54:48 +02:00
parent 9dfc589068
commit cfb8b8721d
4 changed files with 67 additions and 14 deletions

View File

@ -131,4 +131,22 @@ switch (filter('op')) {
flash()->info(tr('Destinatario rimosso dalla newsletter!'));
break;
// Duplica newsletter
case 'copy':
$new = $newsletter->replicate();
$new->state = 'DEV';
$new->completed_at = null;
$new->save();
$id_record = $new->id;
flash()->info(tr('Newsletter duplicata correttamente!'));
break;
}

View File

@ -17,14 +17,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if ($newsletter->state == 'DEV') {
echo '
<button type="button" class="btn btn-primary ask" data-msg="'.tr('Procedere ad inviare la newsletter?').'" data-op="send" data-button="'.tr('Invia').'" data-class="btn btn-lg btn-warning">
<button type="button" class="btn btn-primary ask" data-msg="'.tr('Procedere ad inviare la newsletter?').'" data-op="send" data-button="'.tr('Invia').'" data-class="btn btn-lg btn-warning">
<i class="fa fa-envelope"></i> '.tr('Invia newsletter').'
</button>';
</button>';
} elseif ($newsletter->state == 'WAIT') {
echo '
<button type="button" class="btn btn-danger ask" data-msg="'.tr('Svuotare la coda di invio della newsletter?').'" data-op="block" data-button="'.tr('Svuota').'" data-class="btn btn-lg btn-warning">
<i class="fa fa-envelope"></i> '.tr('Svuota coda newsletter').'
</button>';
<button type="button" class="btn btn-danger ask" data-msg="'.tr('Svuotare la coda di invio della newsletter?').'" data-op="block" data-button="'.tr('Svuota').'" data-class="btn btn-lg btn-warning">
<i class="fa fa-envelope"></i> '.tr('Svuota coda newsletter').'
</button>';
}
// Duplica newsletter
echo '
<button type="button" class="btn btn-primary" onclick="if( confirm(\''.tr('Duplicare questa newsletter?').'\') ){ $(\'#copia-newsletter\').submit(); }">
<i class="fa fa-copy"></i> '.tr('Duplica newsletter').'
</button>';
echo '
<form action="" method="post" id="copia-newsletter">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="copy">
</form>';

View File

@ -52,7 +52,8 @@ echo '
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{[ "type": "select", "label": "'.tr('Template email').'", "name": "id_template", "values": "query=SELECT id, name AS descrizione FROM em_templates", "required": 1, "value": "$id_template$", "disabled": 1 ]}
'.Modules::link('Template email', $record['id_template'], null, null, 'class="pull-right"').'
{[ "type": "select", "label": "'.tr('Template email').'", "name": "id_template", "values": "query=SELECT id, name AS descrizione FROM em_templates", "required": 1, "value": "$id_template$", "readonly": 1 ]}
</div>
<div class="col-md-6">
@ -66,7 +67,7 @@ echo '
</div>
<div class="col-md-6">
{[ "type": "timestamp", "label": "'.tr('Data di completamento').'", "name": "completed_at", "value": "$completed_at$", "disabled": 1 ]}
{[ "type": "timestamp", "label": "'.tr('Data di completamento').'", "name": "completed_at", "value": "$completed_at$", "readonly": 1 ]}
</div>
</div>
@ -156,9 +157,12 @@ if (!$anagrafiche->isEmpty()) {
<table class="table table-hover table-condensed table-bordered">
<thead>
<tr>
<th>'.tr('Nome').'</th>
<th class="text-center">'.tr('Indirizzo').'</th>
<th>'.tr('Ragione sociale').'</th>
<th>'.tr('Tipo').'</th>
<th>'.tr('Tipologia').'</th>
<th class="text-center">'.tr('E-mail').'</th>
<th class="text-center">'.tr('Data di invio').'</th>
<th class="text-center">'.tr('Newsletter').'</th>
<th class="text-center" width="60">#</th>
</tr>
</thead>
@ -169,18 +173,24 @@ if (!$anagrafiche->isEmpty()) {
$mail_id = $anagrafica->pivot->id_email;
$mail = Mail::find($mail_id);
if (!empty($mail) && !empty($mail->sent_at)) {
$data = timestampFormat($mail->sent_at);
$data = '<span class="label label-success" ><i class="fa fa-paper-plane" aria-hidden="true"></i> '. timestampFormat($mail->sent_at).'</span>';
} else {
$data = tr('Non ancora inviata');
$data = '<span class="label label-info" ><i class="fa fa-clock-o" aria-hidden="true"></i>
'.tr('Non ancora inviata').'</span>';
}
echo '
<tr '.((empty($anagrafica->email) || empty($anagrafica->enable_newsletter)) ? 'class="bg-danger"' : '').'>
<td>'.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).'</td>
<td class="text-center">'.$anagrafica->email.'</td>
<td class="text-left">'.$database->fetchOne('SELECT GROUP_CONCAT(an_tipianagrafiche.descrizione) AS descrizione FROM an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica WHERE an_tipianagrafiche_anagrafiche.idanagrafica='.prepare($anagrafica->id))['descrizione'].'</td>
<td class="text-left">'.$anagrafica->tipo.'</td>
<td class="text-left">'.$anagrafica->email.'</td>
<td class="text-center">'.$data.'</td>
<td class="text-left">
{[ "type": "checkbox", "readonly": "1","name": "disable_newsletter", "value": "'.!empty($anagrafica->enable_newsletter).'" ]}
</td>
<td class="text-center">
<a class="btn btn-danger ask btn-sm" data-backto="record-edit" data-op="remove_receiver" data-id="'.$anagrafica->id.'">
<a class="btn btn-danger ask btn-xs" data-backto="record-edit" data-op="remove_receiver" data-id="'.$anagrafica->id.'">
<i class="fa fa-trash"></i>
</a>
</td>

View File

@ -3,4 +3,15 @@ INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`,
((SELECT `id` FROM `zz_modules` WHERE name='Fatture di acquisto'), 'N. Prot.', 'co_documenti.numero', 1, 1, 0, 0, '', '', 0, 0, 0);
-- Formattazione colonna data modulo Ordini fornitore
UPDATE `zz_views` SET `format`=1 WHERE `zz_views`.`name`='Data' AND `zz_views`.`id_module`=(SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore');
UPDATE `zz_views` SET `format`=1 WHERE `zz_views`.`name`='Data' AND `zz_views`.`id_module`=(SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore');
-- Colonna stato per newsletter
INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES
((SELECT `id` FROM `zz_modules` WHERE name='Newsletter'), 'Stato', 'IF(em_newsletters.state = \'DEV\', \'Bozza\', IF(em_newsletters.state = \'WAIT\', \'Invio in corso\', \'Completata\'))', 4, 1, 0, 0, '', '', 1, 0, 0);
-- Colonna destinatari per newsletter
INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES
((SELECT `id` FROM `zz_modules` WHERE name='Newsletter'), 'Destinatari', '(SELECT COUNT(*) FROM `em_newsletter_anagrafica` WHERE `em_newsletter_anagrafica`.`id_newsletter` = `em_newsletters`.`id`)', 5, 1, 0, 0, '', '', 1, 0, 0);
-- Aggiorno colonna completato per newsletter
UPDATE `zz_views` SET `query` = 'IF(completed_at IS NULL, \'No\', CONCAT(\' \', \'(\', DATE_FORMAT(completed_at, \'%d/%m/%Y %H:%i:%s\' ), \')\'))', `order` = 6 WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE name='Newsletter') AND `name` = 'Completato';