mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Sistema di opt-out da newsletter
This commit is contained in:
@@ -31,6 +31,9 @@ switch (post('op')) {
|
|||||||
$sede->idzona = post('idzona');
|
$sede->idzona = post('idzona');
|
||||||
$sede->email = post('email');
|
$sede->email = post('email');
|
||||||
|
|
||||||
|
$opt_out_newsletter = post('disable_newsletter');
|
||||||
|
$sede->enable_newsletter = empty($opt_out_newsletter);
|
||||||
|
|
||||||
$sede->save();
|
$sede->save();
|
||||||
|
|
||||||
// Informazioni sull'anagrafica
|
// Informazioni sull'anagrafica
|
||||||
|
@@ -4,134 +4,134 @@ include_once __DIR__.'/../../../core.php';
|
|||||||
|
|
||||||
switch ($resource) {
|
switch ($resource) {
|
||||||
case 'clienti':
|
case 'clienti':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = "descrizione='Cliente'";
|
$where[] = "descrizione='Cliente'";
|
||||||
if (empty($filter)) {
|
if (empty($filter)) {
|
||||||
$where[] = 'deleted_at IS NULL';
|
$where[] = 'deleted_at IS NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom['idtipointervento'] = 'idtipointervento_default';
|
$custom['idtipointervento'] = 'idtipointervento_default';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'fornitori':
|
case 'fornitori':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = "descrizione='Fornitore'";
|
$where[] = "descrizione='Fornitore'";
|
||||||
if (empty($filter)) {
|
if (empty($filter)) {
|
||||||
$where[] = 'deleted_at IS NULL';
|
$where[] = 'deleted_at IS NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom['idtipointervento'] = 'idtipointervento_default';
|
$custom['idtipointervento'] = 'idtipointervento_default';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vettori':
|
case 'vettori':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = "descrizione='Vettore'";
|
$where[] = "descrizione='Vettore'";
|
||||||
if (empty($filter)) {
|
if (empty($filter)) {
|
||||||
$where[] = 'deleted_at IS NULL';
|
$where[] = 'deleted_at IS NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom['idtipointervento'] = 'idtipointervento_default';
|
$custom['idtipointervento'] = 'idtipointervento_default';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'agenti':
|
case 'agenti':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = "descrizione='Agente'";
|
$where[] = "descrizione='Agente'";
|
||||||
if (empty($filter)) {
|
if (empty($filter)) {
|
||||||
$where[] = 'deleted_at IS NULL';
|
$where[] = 'deleted_at IS NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = AJAX::selectResults($query, $where, $filter, $search, $limit, $custom);
|
$results = AJAX::selectResults($query, $where, $filter, $search, $limit, $custom);
|
||||||
|
|
||||||
// Evidenzia l'agente di default
|
// Evidenzia l'agente di default
|
||||||
if ($superselect['idanagrafica']) {
|
if ($superselect['idanagrafica']) {
|
||||||
$rsa = $dbo->fetchArray('SELECT idagente FROM an_anagrafiche WHERE idanagrafica='.prepare($superselect['idanagrafica']));
|
$rsa = $dbo->fetchArray('SELECT idagente FROM an_anagrafiche WHERE idanagrafica='.prepare($superselect['idanagrafica']));
|
||||||
$idagente_default = $rsa[0]['idagente'];
|
$idagente_default = $rsa[0]['idagente'];
|
||||||
} else {
|
} else {
|
||||||
$idagente_default = 0;
|
$idagente_default = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = array_column($results, 'idanagrafica');
|
$ids = array_column($results, 'idanagrafica');
|
||||||
$pos = array_search($idagente_default, $ids);
|
$pos = array_search($idagente_default, $ids);
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$results[$pos]['_bgcolor_'] = '#ff0';
|
$results[$pos]['_bgcolor_'] = '#ff0';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tecnici':
|
case 'tecnici':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta IS NULL OR citta = '', '', CONCAT(' (', citta, ')')), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, idtipointervento_default FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY ragione_sociale";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
$where[] = "descrizione='Tecnico'";
|
||||||
|
if (empty($filter)) {
|
||||||
|
$where[] = 'deleted_at IS NULL';
|
||||||
|
|
||||||
|
//come tecnico posso aprire attività solo a mio nome
|
||||||
|
$user = Auth::user();
|
||||||
|
if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) {
|
||||||
|
$where[] = 'an_anagrafiche.idanagrafica='.$user['idanagrafica'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$where[] = "descrizione='Tecnico'";
|
if (!empty($search)) {
|
||||||
if (empty($filter)) {
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
$where[] = 'deleted_at IS NULL';
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
|
}
|
||||||
|
|
||||||
//come tecnico posso aprire attività solo a mio nome
|
// $custom['idtipointervento'] = 'idtipointervento_default';
|
||||||
$user = Auth::user();
|
|
||||||
if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) {
|
|
||||||
$where[] = 'an_anagrafiche.idanagrafica='.$user['idanagrafica'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($search)) {
|
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
// $custom['idtipointervento'] = 'idtipointervento_default';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'clienti_fornitori':
|
case 'clienti_fornitori':
|
||||||
$query = "SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT_WS('', ragione_sociale, IF(citta !='' OR provincia != '', CONCAT(' (', citta, IF(provincia!='', CONCAT(' ', provincia), ''), ')'), ''), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup, idtipointervento_default, an_tipianagrafiche.idtipoanagrafica FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC, ragione_sociale ASC";
|
$query = "SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT_WS('', ragione_sociale, IF(citta !='' OR provincia != '', CONCAT(' (', citta, IF(provincia!='', CONCAT(' ', provincia), ''), ')'), ''), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup, idtipointervento_default, an_tipianagrafiche.idtipoanagrafica FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC, ragione_sociale ASC";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
@@ -179,46 +179,46 @@ switch ($resource) {
|
|||||||
|
|
||||||
// Nota Bene: nel campo id viene specificato idtipoanagrafica-idanagrafica -> modulo Utenti e permessi, creazione nuovo utente
|
// Nota Bene: nel campo id viene specificato idtipoanagrafica-idanagrafica -> modulo Utenti e permessi, creazione nuovo utente
|
||||||
case 'anagrafiche':
|
case 'anagrafiche':
|
||||||
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT_WS('', ragione_sociale, IF(citta !='' OR provincia != '', CONCAT(' (', citta, IF(provincia!='', CONCAT(' ', provincia), ''), ')'), ''), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY `optgroup` ASC, ragione_sociale ASC";
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT_WS('', ragione_sociale, IF(citta !='' OR provincia != '', CONCAT(' (', citta, IF(provincia!='', CONCAT(' ', provincia), ''), ')'), ''), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY `optgroup` ASC, ragione_sociale ASC";
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($filter)) {
|
||||||
|
$where[] = 'deleted_at IS NULL';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($search)) {
|
||||||
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiunta filtri di ricerca
|
||||||
|
if (!empty($search_fields)) {
|
||||||
|
$where[] = '('.implode(' OR ', $search_fields).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filter)) {
|
||||||
|
$where[] = '('.implode(' OR ', $filter).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query);
|
||||||
|
|
||||||
|
$rs = $dbo->fetchArray($query);
|
||||||
|
foreach ($rs as $r) {
|
||||||
|
if ($prev != $r['optgroup']) {
|
||||||
|
$results[] = ['text' => $r['optgroup'], 'children' => []];
|
||||||
|
$prev = $r['optgroup'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($filter)) {
|
$results[count($results) - 1]['children'][] = [
|
||||||
$where[] = 'deleted_at IS NULL';
|
'id' => $r['id'],
|
||||||
}
|
'text' => $r['descrizione'],
|
||||||
|
'descrizione' => $r['descrizione'],
|
||||||
if (!empty($search)) {
|
];
|
||||||
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
}
|
||||||
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
|
||||||
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aggiunta filtri di ricerca
|
|
||||||
if (!empty($search_fields)) {
|
|
||||||
$where[] = '('.implode(' OR ', $search_fields).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($filter)) {
|
|
||||||
$where[] = '('.implode(' OR ', $filter).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query);
|
|
||||||
|
|
||||||
$rs = $dbo->fetchArray($query);
|
|
||||||
foreach ($rs as $r) {
|
|
||||||
if ($prev != $r['optgroup']) {
|
|
||||||
$results[] = ['text' => $r['optgroup'], 'children' => []];
|
|
||||||
$prev = $r['optgroup'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$results[count($results) - 1]['children'][] = [
|
|
||||||
'id' => $r['id'],
|
|
||||||
'text' => $r['descrizione'],
|
|
||||||
'descrizione' => $r['descrizione'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sedi':
|
case 'sedi':
|
||||||
|
@@ -87,8 +87,6 @@ if (!$is_cliente) {
|
|||||||
<?php
|
<?php
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
{[ "type": "text", "label": "<?php echo tr('Codice anagrafica'); ?>", "name": "codice", "required": 1, "class": "text-center alphanumeric-mask", "value": "$codice$", "maxlength": 20, "validation": "codice" ]}
|
{[ "type": "text", "label": "<?php echo tr('Codice anagrafica'); ?>", "name": "codice", "required": 1, "class": "text-center alphanumeric-mask", "value": "$codice$", "maxlength": 20, "validation": "codice" ]}
|
||||||
@@ -498,6 +496,12 @@ echo '
|
|||||||
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
|
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
{[ "type": "checkbox", "label": "<?php echo tr('Opt-out newsletter'); ?>", "name": "disable_newsletter", "value": "<?php echo empty($record['enable_newsletter']); ?>" ]}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
49
modules/newsletter/ajax/select.php
Normal file
49
modules/newsletter/ajax/select.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once __DIR__.'/../../../core.php';
|
||||||
|
|
||||||
|
switch ($resource) {
|
||||||
|
case 'anagrafiche_newsletter':
|
||||||
|
$query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT_WS('', ragione_sociale, IF(citta !='' OR provincia != '', CONCAT(' (', citta, IF(provincia!='', CONCAT(' ', provincia), ''), ')'), ''), IF(deleted_at IS NULL, '', ' (".tr('eliminata').")')) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY `optgroup` ASC, ragione_sociale ASC";
|
||||||
|
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
$filter[] = 'an_anagrafiche.idanagrafica='.prepare($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($filter)) {
|
||||||
|
$where[] = 'deleted_at IS NULL';
|
||||||
|
$where[] = 'enable_newsletter = 1';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($search)) {
|
||||||
|
$search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%');
|
||||||
|
$search_fields[] = 'citta LIKE '.prepare('%'.$search.'%');
|
||||||
|
$search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiunta filtri di ricerca
|
||||||
|
if (!empty($search_fields)) {
|
||||||
|
$where[] = '('.implode(' OR ', $search_fields).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filter)) {
|
||||||
|
$where[] = '('.implode(' OR ', $filter).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query);
|
||||||
|
|
||||||
|
$rs = $dbo->fetchArray($query);
|
||||||
|
foreach ($rs as $r) {
|
||||||
|
if ($prev != $r['optgroup']) {
|
||||||
|
$results[] = ['text' => $r['optgroup'], 'children' => []];
|
||||||
|
$prev = $r['optgroup'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$results[count($results) - 1]['children'][] = [
|
||||||
|
'id' => $r['id'],
|
||||||
|
'text' => $r['descrizione'],
|
||||||
|
'descrizione' => $r['descrizione'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
@@ -82,7 +82,7 @@ echo '
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
{[ "type": "select", "label": "'.tr('Destinatari').'", "name": "receivers[]", "ajax-source": "anagrafiche", "multiple": 1 ]}
|
{[ "type": "select", "label": "'.tr('Destinatari').'", "name": "receivers[]", "ajax-source": "anagrafiche_newsletter", "multiple": 1 ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3 text-right">
|
<div class="col-md-3 text-right">
|
||||||
@@ -116,19 +116,19 @@ if (!$anagrafiche->isEmpty()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td>'.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).'</td>
|
<td>'.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).'</td>
|
||||||
<td class="text-center">'.$data.'</td>
|
<td class="text-center">'.$data.'</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a class="btn btn-danger ask btn-sm" data-backto="record-edit" data-op="remove_receiver" data-id="'.$anagrafica->id.'">
|
<a class="btn btn-danger ask btn-sm" data-backto="record-edit" data-op="remove_receiver" data-id="'.$anagrafica->id.'">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>';
|
</table>';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
echo '
|
||||||
|
@@ -72,7 +72,7 @@ class Newsletter extends Model
|
|||||||
|
|
||||||
public function emails()
|
public function emails()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Mail::class, 'id_newsletter');
|
return $this->belongsToMany(Mail::class, 'em_newsletter_anagrafica', 'id_newsletter', 'id_email')->withPivot('id_anagrafica');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function account()
|
public function account()
|
||||||
|
@@ -433,3 +433,4 @@ INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`,
|
|||||||
ALTER TABLE `em_templates` CHANGE `id_smtp` `id_account` INT(11) NOT NULL;
|
ALTER TABLE `em_templates` CHANGE `id_smtp` `id_account` INT(11) NOT NULL;
|
||||||
ALTER TABLE `em_print_template` CHANGE `id_email` `id_template` INT(11) NOT NULL;
|
ALTER TABLE `em_print_template` CHANGE `id_email` `id_template` INT(11) NOT NULL;
|
||||||
ALTER TABLE `em_accounts` ADD `timeout` INT(11) NOT NULL DEFAULT 1000;
|
ALTER TABLE `em_accounts` ADD `timeout` INT(11) NOT NULL DEFAULT 1000;
|
||||||
|
ALTER TABLE `an_anagrafiche` ADD `enable_newsletter` BOOLEAN DEFAULT TRUE;
|
||||||
|
Reference in New Issue
Block a user