openstamanager/modules/emails/edit.php

232 lines
9.3 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
2024-03-05 16:01:45 +01:00
use Models\Module;
if (!$record['predefined']) {
$attr = '';
} else {
$attr = 'readonly';
echo '<div class="alert alert-warning">'.tr('Alcune impostazioni non possono essere modificate per questo template.').'</div>';
}
?>
2018-02-23 16:04:50 +01:00
<form action="" method="post" id="edit-form">
<input type="hidden" name="op" value="update">
<input type="hidden" name="backto" value="record-edit">
<!-- DATI -->
2024-05-16 18:02:50 +02:00
<div class="card card-primary">
2024-05-17 12:11:00 +02:00
<div class="card-header">
2024-05-16 18:02:50 +02:00
<h3 class="card-title"><?php echo tr('Dati'); ?></h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<div class="row">
2024-09-20 10:34:38 +02:00
<div class="col-md-6">
2024-04-19 16:44:08 +02:00
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "value": "$title$", "required": 1, "extra": "<?php echo $attr; ?>" ]}
</div>
2018-02-20 16:46:23 +01:00
<div class="col-md-4">
2024-03-22 15:52:24 +01:00
{[ "type": "span", "label": "<?php echo tr('Modulo del template'); ?>", "name": "module", "values": "query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) WHERE `enabled` = 1", "value": "<?php echo Module::find($record['id_module'])->getTranslation('title'); ?>" ]}
</div>
2024-09-20 10:34:38 +02:00
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Attivo'); ?>", "name": "enabled", "value": "$enabled$", "values": "Sì,No" ]}
</div>
2018-02-20 16:46:23 +01:00
</div>
<div class="row">
<div class="col-md-8">
2019-08-29 10:25:14 +02:00
{[ "type": "select", "label": "<?php echo tr('Indirizzo email'); ?>", "name": "smtp", "value": "$id_account$", "ajax-source": "smtp" ]}
2018-02-20 16:46:23 +01:00
</div>
<div class="col-md-4">
2018-12-28 00:04:41 +01:00
{[ "type": "checkbox", "label": "<?php echo tr('Richiedi notifica di lettura'); ?>", "name": "read_notify", "value": "$read_notify$", "placeholder": "<?php echo tr('Richiedi la notifica di lettura al destinatario.'); ?>" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
2018-02-18 19:53:23 +01:00
{[ "type": "text", "label": "<?php echo tr('Oggetto'); ?>", "name": "subject", "value": "$subject$" ]}
</div>
<div class="col-md-3">
2024-09-10 12:38:16 +02:00
{[ "type": "select", "label": "<?php echo tr('Proponi destinatari'); ?>", "name": "indirizzi_proposti", "value": "$indirizzi_proposti$", "values":"list=\"0\":\"<?php echo tr('Nessuno'); ?>\", \"1\":\"<?php echo tr('Clienti'); ?>\", \"2\":\"<?php echo tr('Fornitori'); ?>\", \"3\":\"<?php echo tr('Tutti'); ?>\" " ]}
</div>
<div class="col-md-3">
2024-09-10 12:38:16 +02:00
{[ "type": "select", "label": "<?php echo tr('Tipologia destinatari'); ?>", "name": "type", "value": "$type$", "values":"list=\"a\":\"<?php echo tr('A'); ?>\", \"cc\":\"<?php echo tr('CC'); ?>\", \"bcc\":\"<?php echo tr('CCN'); ?>\" ", "required":1 ]}
</div>
</div>
<div class="row">
<div class="col-md-4">
2018-12-28 08:07:56 +01:00
{[ "type": "text", "label": "<?php echo tr('CC'); ?>", "name": "cc", "value": "$cc$", "help": "<?php echo 'Copia carbone.'; ?>" ]}
</div>
<div class="col-md-4">
2018-12-28 08:07:56 +01:00
{[ "type": "text", "label": "<?php echo tr('CCN'); ?>", "name": "bcc", "value": "$bcc$", "help": "<?php echo 'Copia carbone nascosta.'; ?>" ]}
</div>
<div class="col-md-4">
2023-07-05 15:16:22 +02:00
<?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">
2024-10-30 12:16:43 +01:00
{[ "type": "text", "class": "email-mask", "label": "<?php echo tr('Destinatario fisso'); ?>", "name": "reply_to", "value": "$reply_to$", "help": "<?php echo 'Rispondi a questo indirizzo e-mail.'; ?>" ]}
</div>
</div>
<?php
// Stampe
2019-08-29 10:25:14 +02:00
$selected_prints = $dbo->fetchArray('SELECT id_print FROM em_print_template WHERE id_template = '.prepare($id_record));
$selected_prints = array_column($selected_prints, 'id_print');
$selected_mansioni = $dbo->fetchArray('SELECT idmansione FROM em_mansioni_template WHERE id_template = '.prepare($id_record));
$selected_mansioni = array_column($selected_mansioni, 'idmansione');
echo '
<div class="row">
<div class="col-md-12">
2024-03-22 15:52:24 +01:00
{[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected_prints).'", "values": "query=SELECT `zz_prints`.`id`, `zz_prints_lang`.`title` AS text FROM `zz_prints` LEFT JOIN `zz_prints_lang` ON (`zz_prints`.`id` = `zz_prints_lang`.`id_record` AND `zz_prints_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `id_module` = '.prepare($record['id_module']).' AND `enabled`=1 AND `is_record`=1" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "type": "select", "multiple": "1", "label": "'.tr('Mansioni').'", "name": "idmansioni[]", "value": "'.implode(',', $selected_mansioni).'", "ajax-source": "mansioni" ]}
</div>
</div>';
?>
<div class="row">
<div class="col-md-12">
2023-08-04 14:54:28 +02:00
<?php echo input([
2023-02-24 13:36:37 +01:00
'type' => 'ckeditor',
'use_full_ckeditor' => 1,
2023-02-24 13:36:37 +01:00
'label' => tr('Contenuto'),
'name' => 'body',
'value' => $record['body'],
]);
2024-01-15 15:30:45 +01:00
?>
</div>
</div>
2021-12-03 10:39:57 +01:00
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note interne'); ?>", "name": "note_aggiuntive", "value": "$note_aggiuntive$", "class": "unblockable" ]}
</div>
</div>
2018-02-23 09:51:42 +01:00
<?php
// Variabili utilizzabili
2024-03-05 16:01:45 +01:00
$module = Module::find($record['id_module']);
2021-03-29 09:11:17 +02:00
$variables = $module->getPlaceholders($id_record);
2018-02-23 09:51:42 +01:00
echo '
<!-- Istruzioni per il contenuto -->
2024-05-16 18:02:50 +02:00
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">'.tr('Variabili').'</h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">';
if (!empty($variables)) {
2018-02-23 09:51:42 +01:00
echo '
2020-03-19 13:35:56 +01:00
<p>'.tr("Puoi utilizzare le seguenti variabili nell'oggetto e nel corpo della mail").':</p>
<ul>';
2018-02-23 09:51:42 +01:00
foreach ($variables as $variable => $value) {
echo '
<li><code>'.$variable.'</code></li>';
2018-02-23 09:51:42 +01:00
}
echo '
</ul>';
2018-02-23 09:51:42 +01:00
} else {
echo '
<p><i class="fa fa-warning"></i> '.tr('Non sono state definite variabili da utilizzare nel template').'.</p>';
2018-02-23 09:51:42 +01:00
}
echo '
</div>
</div>
<hr>';
2018-02-23 09:51:42 +01:00
?>
</div>
</div>
</form>
<?php
2021-11-15 11:19:54 +01:00
if (!empty($newsletters[0])) {
2021-07-16 10:44:20 +02:00
echo '
<div class="alert alert-danger">
'.tr('Questo template non può essere rimosso dal sistema perchè collegato alle seguenti newsletter:').'
<ul>';
foreach ($newsletters as $newsletter) {
echo '
2024-09-25 12:02:08 +02:00
<li>'.Modules::link('Newsletter', $newsletter->id, $newsletter->name, null, '').'</li>';
}
2021-07-16 10:44:20 +02:00
echo '
</ul>
</div>';
} elseif (!$record['predefined']) {
?>
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
2019-08-26 18:02:05 +02:00
</a>
<?php
}
2020-09-07 15:04:06 +02:00
?>
2023-07-05 15:16:22 +02:00
<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>