Introduzione del modulo per la gestione degli account email

This commit is contained in:
Thomas Zilio 2017-09-22 11:13:36 +02:00
parent 34f136a024
commit 057e4bb8a1
5 changed files with 187 additions and 0 deletions

43
modules/smtp/actions.php Normal file
View File

@ -0,0 +1,43 @@
<?php
include_once __DIR__.'/../../core.php';
switch (post('op')) {
case 'add':
$dbo->insert('zz_smtp', [
'name' => $post['name'],
'from_name' => $post['from_name'],
'from_address' => $post['from_address'],
]);
$id_record = $dbo->last_inserted_id();
$_SESSION['infos'][] = tr('Nuovo account email aggiunto!');
break;
case 'update':
$dbo->update('zz_smtp', [
'name' => $post['name'],
'note' => $post['note'],
'server' => $post['server'],
'port' => $post['port'],
'username' => $post['username'],
'password' => $post['password'],
'from_name' => $post['from_name'],
'from_address' => $post['from_address'],
'encryption' => $post['encryption'],
'pec' => $post['pec'],
], ['id' => $id_record]);
$_SESSION['infos'][] = tr('Informazioni salvate correttamente!');
break;
case 'delete':
$dbo->query('UPDATE zz_smtp SET deleted = 1 WHERE id='.prepare($id_record));
$_SESSION['infos'][] = tr('Account email eliminato!');
break;
}

31
modules/smtp/add.php Normal file
View 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 account') ?>", "name": "name", "required": 1 ]}
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
{[ "type": "text", "label": "<?php echo tr('Nome visualizzato') ?>", "name": "from_name" ]}
</div>
<div class="col-xs-12 col-md-6">
{[ "type": "email", "label": "<?php echo tr('Email mittente') ?>", "name": "from_address" ]}
</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>

79
modules/smtp/edit.php Normal file
View File

@ -0,0 +1,79 @@
<?php
include_once __DIR__.'/../../core.php';
?>
<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-9">
{[ "type": "text", "label": "<?php echo tr('Nome account') ?>", "name": "name", "value": "$name$", "required": 1 ]}
</div>
<div class="col-md-3">
{[ "type": "checkbox", "label": "<?php echo tr('Indirizzo PEC?') ?>", "name": "pec", "value": "$pec$", "placeholder": "PEC" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Nome visualizzato') ?>", "name": "from_name", "value": "$from_name$" ]}
</div>
<div class="col-md-6">
{[ "type": "email", "label": "<?php echo tr('Email mittente') ?>", "name": "from_address", "value": "$from_address$" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Server SMTP') ?>", "name": "server", "required": 1, "value": "$server$" ]}
</div>
<div class="col-md-3">
{[ "type": "text", "label": "<?php echo tr('Porta SMTP') ?>", "name": "port", "required": 1, "class": "text-center", "value": "$port$" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Sicurezza SMTP') ?>", "name": "encryption", "values": "list=\"\": \"<?php echo tr('Nessuna') ?>\", \"tls\": \"TLS\", \"ssl\": \"SSL\"", "value": "$encryption$" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Username SMTP') ?>", "name": "username", "value": "$username$" ]}
</div>
<div class="col-md-6">
{[ "type": "password", "label": "<?php echo tr('Password SMTP') ?>", "name": "password", "value": "$password$" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note') ?>", "name": "note", "value": "$note$" ]}
</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>

5
modules/smtp/init.php Normal file
View File

@ -0,0 +1,5 @@
<?php
if (isset($id_record)) {
$records = $dbo->fetchArray("SELECT * FROM zz_smtp WHERE id=".prepare($id_record)." AND deleted = 0");
}

View File

@ -65,3 +65,32 @@ UPDATE `zz_prints` SET `icon` = 'fa fa-print' WHERE `icon` = '';
-- DELETE FROM `zz_settings` WHERE `nome` = 'Visualizza i costi sulle stampe degli interventi';
-- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sugli ordini';
-- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui preventivi';
--
-- Struttura della tabella `zz_smtp`
--
CREATE TABLE IF NOT EXISTS `zz_smtp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`note` varchar(255) NOT NULL,
`server` varchar(255) NOT NULL,
`port` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`from_name` varchar(255) NOT NULL,
`from_address` varchar(255) NOT NULL,
`encryption` enum('','tls','ssl') NOT NULL,
`pec` tinyint(1) NOT NULL,
`deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
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 HAVING 2=2 ORDER BY `name`', 'fa fa-envelope', '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);