Introduzione opt-out newsletter per Referenti e Sedi

This commit is contained in:
Dasc3er 2021-09-23 17:55:58 +02:00
parent 5a5734c526
commit 74665d4a88
8 changed files with 32 additions and 6 deletions

View File

@ -114,12 +114,12 @@ foreach ($destinatari_filtrati as $destinatario) {
$riga = array_merge($riga, [
'<div class="text-center">'.
(!empty($anagrafica->enable_newsletter) ?
(!empty($origine->enable_newsletter) ?
'<span class="text-success"><i class="fa fa-check"></i> '.tr('Abilitato').'</span>' :
'<span class="text-warning"><i class="fa fa-exclamation-triangle"></i> '.tr('Disabilitato').'</span>'
).'
</div>',
'<div class="text-center">'.(empty($lista) && !empty($origine->email) && !empty($anagrafica->enable_newsletter) ? '
'<div class="text-center">'.(empty($lista) && !empty($origine->email) && !empty($origine->enable_newsletter) ? '
<a class="btn btn-warning btn-xs" data-type="'.get_class($origine).'" data-id="'.$origine->id.'" data-email="'.$origine->email.'" onclick="testInvio(this)">
<i class="fa fa-paper-plane "></i>
</a>' : '').'

View File

@ -147,7 +147,7 @@ class Newsletter extends Model
$anagrafica = $origine instanceof Anagrafica ? $origine : $origine->anagrafica;
$abilita_newsletter = $anagrafica->enable_newsletter;
$abilita_newsletter = $origine->enable_newsletter;
$email = $destinatario->email;
if (empty($email) || empty($abilita_newsletter) || !v::email()->validate($email)) {
return null;

View File

@ -46,6 +46,8 @@ switch ($operazione) {
break;
case 'updatereferente':
$opt_out_newsletter = post('disable_newsletter');
$dbo->update('an_referenti', [
'idanagrafica' => $id_parent,
'nome' => post('nome'),
@ -53,6 +55,8 @@ switch ($operazione) {
'telefono' => post('telefono'),
'email' => post('email'),
'idsede' => post('idsede'),
'enable_newsletter' => empty($opt_out_newsletter),
], ['id' => $id_record]);
flash()->info(tr('Salvataggio completato!'));

View File

@ -49,9 +49,13 @@ echo '
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value": "0", "required": 1 ]}
</div>
<div class="col-md-6">
{[ "type": "checkbox", "label": "'.tr('Opt-out per newsletter').'", "name": "disable_newsletter", "id": "disable_newsletter_m", "value": "0" ]}
</div>
</div>
<!-- PULSANTI -->

View File

@ -48,9 +48,13 @@ echo '
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value" : "$idsede$", "required": 1 ]}
</div>
<div class="col-md-6">
{[ "type": "checkbox", "label": "'.tr('Opt-out per newsletter').'", "name": "disable_newsletter", "id": "disable_newsletter_m", "value": "'.empty($record['enable_newsletter']).'" ]}
</div>
</div>
<!-- PULSANTI -->

View File

@ -53,6 +53,8 @@ switch ($operazione) {
break;
case 'updatesede':
$opt_out_newsletter = post('disable_newsletter');
$dbo->update('an_sedi', [
'nomesede' => post('nomesede'),
'indirizzo' => post('indirizzo'),
@ -73,6 +75,8 @@ switch ($operazione) {
'gaddress' => post('gaddress'),
'lat' => post('lat'),
'lng' => post('lng'),
'enable_newsletter' => empty($opt_out_newsletter),
], ['id' => $id_record]);
flash()->info(tr('Salvataggio completato!'));

View File

@ -95,10 +95,15 @@ echo '
{[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email", "value": "$email$" ]}
</div>
<div class="col-md-6">
<div class="col-md-3">
{[ "type": "checkbox", "label": "'.tr('Opt-out per newsletter').'", "name": "disable_newsletter", "id": "disable_newsletter_m", "value": "'.empty($record['enable_newsletter']).'" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('Zona').'", "name": "idzona", "ajax-source": "zone", "value": "$idzona$", "placeholder": "'.tr('Nessuna zona').'", "icon-after": "add|'.Modules::get('Zone')['id'].'" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "'.tr('Note').'", "name": "note", "value": "$note$" ]}

View File

@ -127,3 +127,8 @@ CREATE TABLE IF NOT EXISTS `zz_oauth2` (
ALTER TABLE `em_accounts` ADD `id_oauth2` INT(11) DEFAULT NULL,
ADD FOREIGN KEY (`id_oauth2`) REFERENCES `zz_oauth2`(`id`);
-- Aggiunta opt-out Newsletter per Referenti e Sedi
ALTER TABLE `an_referenti` ADD `enable_newsletter` BOOLEAN DEFAULT TRUE;
ALTER TABLE `an_sedi` ADD `enable_newsletter` BOOLEAN DEFAULT TRUE;