query($query); $_SESSION['infos'][] = tr('Aggiunto nuovo referente!'); } break; case 'updatereferenti': foreach ($_POST['idreferente'] as $key => $value) { $query = 'UPDATE `an_referenti` SET `nome`='.prepare($_POST['nome'][$key]).', `mansione`='.prepare($_POST['mansione'][$key]).', `telefono`='.prepare($_POST['telefono'][$key]).', `email`='.prepare($_POST['email'][$key]).', `idsede`='.prepare($_POST['idsede'][$key]).' WHERE `id`='.prepare($value); $dbo->query($query); } $_SESSION['infos'][] = tr('Salvataggio completato!'); break; case 'deletereferente': $idreferente = filter('id'); $dbo->query("DELETE FROM `an_referenti` WHERE `id`=".prepare($idreferente)); $_SESSION['infos'][] = tr('Referente eliminato!'); break; } if (filter('add') != null) { echo '
{[ "type": "text", "label": "'.tr('Nominativo').'", "name": "nome", "required": 1 ]}
{[ "type": "text", "label": "'.tr('Mansione').'", "name": "mansione", "required": 1 ]}
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]}
{[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email" ]}
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT -1 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_record.'" ]}
'; } else { echo '

'.tr('Referenti').'

'.tr('Nuovo referente').'

'.tr('Qui hai la possibilità di gestire i referenti di questa anagrafica').'.

'; $query = 'SELECT * FROM an_referenti WHERE idanagrafica='.prepare($id_record).' ORDER BY id DESC'; $results = $dbo->fetchArray($query); if (count($results) != 0) { echo ' '; foreach ($results as $result) { echo ' '; } echo '
'.tr('Nominativo').' '.tr('Mansione').' '.tr('Telefono').' '.tr('Indirizzo email').' '.tr('Sede').' '.tr('Opzioni').'
{[ "type": "text", "placeholder": "'.tr('Nominativo').'", "name": "nome[]", "required": 1, "value": "'.$result['nome'].'" ]} {[ "type": "text", "placeholder": "'.tr('Mansione').'", "name": "mansione[]", "required": 1, "value": "'.$result['mansione'].'" ]} {[ "type": "text", "placeholder": "'.tr('Telefono').'", "name": "telefono[]", "value": "'.$result['telefono'].'" ]} {[ "type": "text", "placeholder": "'.tr('Indirizzo email').'", "name": "email[]", "value": "'.$result['email'].'" ]} {[ "type": "select", "placeholder": "'.tr('Sede').'", "name": "idsede[]", "values": "query=SELECT -1 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT( CONCAT_WS( \' (\', CONCAT_WS(\', \', `nomesede`, `citta`), `indirizzo` ), \')\') AS descrizione FROM an_sedi WHERE idanagrafica='.$id_record.'", "value": "'.$result['idsede'].'" ]} '.tr('Elimina').'
'; } echo '
'; }