Gestione opzioni reply to email

This commit is contained in:
MatteoPistorello 2023-07-05 15:16:22 +02:00
parent d5cecabdae
commit 26f9432527
4 changed files with 48 additions and 10 deletions

View File

@ -40,6 +40,7 @@ switch (post('op')) {
'id_account' => post('smtp'),
'icon' => post('icon'),
'subject' => post('subject'),
'tipo_reply_to' => post('tipo_reply_to'),
'reply_to' => post('reply_to'),
'cc' => post('cc'),
'bcc' => post('bcc'),

View File

@ -59,14 +59,9 @@ if (!$record['predefined']) {
</div>
<div class="row">
<div class="col-md-8">
<div class="col-md-12">
{[ "type": "text", "label": "<?php echo tr('Oggetto'); ?>", "name": "subject", "value": "$subject$" ]}
</div>
<div class="col-md-4">
<?php $records[0]['icon'] = (empty($records[0]['icon'])) ? 'fa fa-envelope' : $records[0]['icon']; ?>
{[ "type": "text", "label": "<?php echo tr('Icona'); ?>", "name": "icon", "value": "<?php echo $records[0]['icon']; ?>" ,"help":"<?php echo tr('Es. \'fa fa-envelope\''); ?>" ]}
</div>
</div>
<div class="row">
@ -79,7 +74,18 @@ if (!$record['predefined']) {
</div>
<div class="col-md-4">
{[ "type": "email", "label": "<?php echo tr('Rispondi a'); ?>", "name": "reply_to", "value": "$reply_to$", "help": "<?php echo 'Rispondi a questo indirizzo e-mail.'; ?>" ]}
<?php $records[0]['icon'] = (empty($records[0]['icon'])) ? 'fa fa-envelope' : $records[0]['icon']; ?>
{[ "type": "text", "label": "<?php echo tr('Icona'); ?>", "name": "icon", "value": "<?php echo $records[0]['icon']; ?>" ,"help":"<?php echo tr('Es. \'fa fa-envelope\''); ?>" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Rispondi a'); ?>", "name": "tipo_reply_to", "values": "list=\"0\":\"Mittente (predefinito)\", \"email_user\":\"Email dell'utente che esegue l'invio\", \"email_fissa\":\"Destinatario fisso\"", "value": "$tipo_reply_to$", "help": "<?php echo 'Indirizzo email a cui rispondere'; ?>" ]}
</div>
<div class="col-md-6">
{[ "type": "email", "label": "<?php echo tr('Destinatario fisso'); ?>", "name": "reply_to", "value": "$reply_to$", "help": "<?php echo 'Rispondi a questo indirizzo e-mail.'; ?>" ]}
</div>
</div>
@ -96,7 +102,7 @@ echo '
<div class="row">
<div class="col-md-12">
{[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected_prints).'", "values": "query=SELECT id, title AS text FROM zz_prints WHERE id_module = '.prepare($record['id_module']).' AND enabled=1" ]}
{[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected_prints).'", "values": "query=SELECT id, title AS text FROM zz_prints WHERE id_module = '.prepare($record['id_module']).' AND enabled=1 AND is_record=1" ]}
</div>
</div>
@ -196,3 +202,21 @@ if (!empty($newsletters[0])) {
<?php
}
?>
<script>
$(document).ready(function () {
if ($("#tipo_reply_to").val() != 'email_fissa') {
$("#reply_to").val("");
$("#reply_to").attr("readonly", true)
}
});
$("#tipo_reply_to").on("change", function () {
if ($(this).val() == 'email_fissa') {
$("#reply_to").attr("readonly", false)
} else {
$("#reply_to").val("");
$("#reply_to").attr("readonly", true)
}
});
</script>

View File

@ -225,8 +225,18 @@ class Mail extends Model
$this->subject = $template->subject;
// Reply To
if (!empty($template['reply_to'])) {
$this->options['reply_to'] = $template['reply_to'];
if (!empty($template['tipo_reply_to'])) {
$reply_to = '';
if ($template['tipo_reply_to'] == 'email_fissa') {
$reply_to = $template['reply_to'];
} else {
$user = \Auth::user();
$reply_to = $user->email;
}
if (!empty($reply_to)) {
$this->options['reply_to'] = $reply_to;
}
}
// CC

3
update/2_4_48.sql Normal file
View File

@ -0,0 +1,3 @@
-- Aggiunta tipologia reply to
ALTER TABLE `em_templates` ADD `tipo_reply_to` VARCHAR(255) NOT NULL AFTER `subject`;
UPDATE `em_templates` SET `tipo_reply_to` = 'email_fissa' WHERE `reply_to` != '';