mirror of
https://github.com/devcode-it/openstamanager.git
synced 2024-12-23 05:54:03 +01:00
Introduzione della gestione dei template per le email
This commit is contained in:
parent
2ecf10376d
commit
60612585b1
@ -24,7 +24,8 @@ if (!$cliente) {
|
||||
|
||||
}
|
||||
|
||||
?><form action="" method="post" role="form">
|
||||
?>
|
||||
<form action="" method="post" role="form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="update">
|
||||
|
||||
|
41
modules/emails/actions.php
Normal file
41
modules/emails/actions.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (post('op')) {
|
||||
case 'add':
|
||||
$dbo->insert('zz_emails', [
|
||||
'name' => $post['name'],
|
||||
'id_module' => $post['module'],
|
||||
'subject' => $post['subject'],
|
||||
]);
|
||||
|
||||
$id_record = $dbo->last_inserted_id();
|
||||
|
||||
$_SESSION['infos'][] = tr('Aggiunto nuovo template per le email!');
|
||||
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$dbo->update('zz_emails', [
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'subject' => $post['subject'],
|
||||
'reply_to' => $post['reply_to'],
|
||||
'cc' => $post['cc'],
|
||||
'bcc' => $post['bcc'],
|
||||
'body' => $_POST['body'],// $post['body'],
|
||||
'read_notify' => $post['read_notify'],
|
||||
], ['id' => $id_record]);
|
||||
|
||||
$_SESSION['infos'][] = tr('Informazioni salvate correttamente!');
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->query('UPDATE zz_emails SET deleted = 1 WHERE id='.prepare($id_record));
|
||||
|
||||
$_SESSION['infos'][] = tr('Template delle email eliminato!');
|
||||
|
||||
break;
|
||||
}
|
31
modules/emails/add.php
Normal file
31
modules/emails/add.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="editor.php?id_module=$id_module$" method="post">
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome') ?>", "name": "name", "required": 1 ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
{[ "type": "select", "label": "<?php echo tr('Modulo del template') ?>", "name": "module", "values": "query=SELECT id, title AS descrizione FROM zz_modules WHERE enabled = 1" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Oggetto') ?>", "name": "subject" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
87
modules/emails/edit.php
Normal file
87
modules/emails/edit.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/assets/dist/js/ckeditor.js"></script>';
|
||||
|
||||
?>
|
||||
<form action="" method="post" id="add-form">
|
||||
<input type="hidden" name="op" value="update">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<!-- DATI -->
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo tr('Dati') ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="pull-right">
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> <?php echo tr('Salva modifiche'); ?></button>
|
||||
</div>
|
||||
<div class="clearfix"></div><br>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome') ?>", "name": "name", "value": "$name$", "required": 1 ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
{[ "type": "span", "label": "<?php echo tr('Modulo del template') ?>", "name": "module", "values": "query=SELECT id, title AS descrizione FROM zz_modules WHERE enabled = 1", "value": "<?php echo Modules::getModule($records[0]['id_module'])['title']; ?>" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Notifica di lettura') ?>", "name": "read_notify", "value": "$read_notify$", "placeholder": "<?php echo tr('Abilita la notifica di lettura') ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "email", "label": "<?php echo tr('Oggetto') ?>", "name": "subject", "value": "$subject$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Icona') ?>", "name": "icon", "value": "$icon$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('CC') ?>", "name": "cc", "value": "$cc$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('BCC') ?>", "name": "port", "value": "$bcc$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Reply to') ?>", "name": "reply_to", "value": "$reply_to$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Contenuto') ?>", "name": "body", "value": "$body$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||
</a>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
CKEDITOR.replace("body", {
|
||||
toolbar: [
|
||||
{ name: "document", items: [ "NewPage", "Preview", "-", "Templates" ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups
|
||||
["Bold","Italic","Underline","Superscript","-","NumberedList","BulletedList","Outdent","Indent","Blockquote","-","Format",], // Defines toolbar group without name
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
5
modules/emails/init.php
Normal file
5
modules/emails/init.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
if (isset($id_record)) {
|
||||
$records = $dbo->fetchArray("SELECT * FROM zz_emails WHERE id=".prepare($id_record)." AND deleted = 0");
|
||||
}
|
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `zz_prints` (
|
||||
`directory` varchar(50) NOT NULL,
|
||||
`previous` varchar(50) NOT NULL,
|
||||
`options` text NOT NULL,
|
||||
`icon` varchar(255) NOT NULL,
|
||||
`icon` varchar(50) NOT NULL,
|
||||
`version` varchar(15) NOT NULL,
|
||||
`compatibility` varchar(1000) NOT NULL,
|
||||
`order` int(11) NOT NULL,
|
||||
@ -86,11 +86,65 @@ CREATE TABLE IF NOT EXISTS `zz_smtp` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--
|
||||
-- Struttura della tabella `zz_emails`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `zz_emails` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_module` int(11) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`icon` varchar(50) NOT NULL,
|
||||
`subject` varchar(255) NOT NULL,
|
||||
`reply_to` varchar(255) NOT NULL,
|
||||
`cc` varchar(255) NOT NULL,
|
||||
`bcc` varchar(255) NOT NULL,
|
||||
`body` text NOT NULL,
|
||||
`read_notify` tinyint(1) NOT NULL,
|
||||
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--
|
||||
-- Struttura della tabella `zz_email_smtp_user`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `zz_email_smtp_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_email` int(11) NOT NULL,
|
||||
`id_smtp` int(11) NOT NULL,
|
||||
`id_user` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_smtp`) REFERENCES `zz_smtp`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--
|
||||
-- Struttura della tabella `zz_emails`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `zz_email_print` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_email` int(11) NOT NULL,
|
||||
`id_print` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_print`) REFERENCES `zz_prints`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Aggiunta dei moduli dedicati alla gestione delle email
|
||||
INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Account email', 'Account email', 'smtp', 'SELECT |select| FROM zz_smtp WHERE 1=1 AND deleted = 0 HAVING 2=2 ORDER BY `name`', 'fa fa-envelope', '2.3', '2.3', '10', NULL, 1, 1);
|
||||
INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Template email', 'Template email', 'emails', 'SELECT |select| FROM zz_emails WHERE 1=1 AND deleted = 0 HAVING 2=2 ORDER BY `name`', 'fa fa-pencil-square-o', '2.3', '2.3', '10', NULL, 1, 1);
|
||||
|
||||
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'id', 'id', 1, 1, 0, 0, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), '#', 'id', 2, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Nome account', 'name', 3, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Nome visualizzato', 'from_name', 4, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Email mittente', 'from_address', 5, 1, 0, 1, 1);
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Email mittente', 'from_address', 5, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'id', 'id', 1, 1, 0, 0, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), '#', 'id', 2, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'Nome', 'name', 3, 1, 0, 1, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'Oggetto', 'subject', 4, 1, 0, 1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user