1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-14 00:24:28 +01:00

Validazione email newsletter

This commit is contained in:
Luca 2021-05-31 18:16:58 +02:00
parent cfb8b8721d
commit 32740866be
2 changed files with 64 additions and 2 deletions

View File

@ -162,7 +162,7 @@ if (!$anagrafiche->isEmpty()) {
<th>'.tr('Tipologia').'</th>
<th class="text-center">'.tr('E-mail').'</th>
<th class="text-center">'.tr('Data di invio').'</th>
<th class="text-center">'.tr('Newsletter').'</th>
<th class="text-center" width="200">'.tr('Newsletter').'</th>
<th class="text-center" width="60">#</th>
</tr>
</thead>
@ -184,7 +184,8 @@ if (!$anagrafiche->isEmpty()) {
<td>'.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).'</td>
<td class="text-left">'.$database->fetchOne('SELECT GROUP_CONCAT(an_tipianagrafiche.descrizione) AS descrizione FROM an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica WHERE an_tipianagrafiche_anagrafiche.idanagrafica='.prepare($anagrafica->id))['descrizione'].'</td>
<td class="text-left">'.$anagrafica->tipo.'</td>
<td class="text-left">'.$anagrafica->email.'</td>
<td class="text-left">
{[ "type": "text", "name": "email", "id": "email_'.rand(0,99999).'", "readonly": "1", "class": "email-mask", "value": "'.$anagrafica->email.'", "validation": "email" ]}</td>
<td class="text-center">'.$data.'</td>
<td class="text-left">
{[ "type": "checkbox", "readonly": "1","name": "disable_newsletter", "value": "'.!empty($anagrafica->enable_newsletter).'" ]}

View File

@ -0,0 +1,61 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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';
$name = filter('name');
$value = filter('value');
switch ($name) {
case 'email':
$check = Validate::isValidEmail($value);
if (empty($check['valid-format'])) {
$result = false;
$errors[] = tr("L'email inserita non possiede un formato valido");
}else{
$result = true;
}
if (isset($check['smtp-check']) && empty($check['smtp-check'])) {
$result = false;
$errors[] = tr("Impossibile verificare l'origine dell'email");
}
if (!empty($errors)) {
$message = tr('Attenzione').':<ul>';
foreach ($errors as $error) {
$message .= '<li>'.$error.'</li>';
}
$message .= '</ul>';
}
$response = [
'result' => $result,
'message' => $message,
];
break;
}