query($query); array_push($_SESSION['infos'], "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); } array_push($_SESSION['infos'], _("Salvataggio completato!")); break; case "deletereferente" : $idreferente = filter('id'); $dbo->query("DELETE FROM `an_referenti` WHERE `id`='" . $idreferente . "'"); array_push($_SESSION['infos'], "Referente eliminato!"); redirect($rootdir."/editor.php?id_module=".$id_module."&id_record=".$id_record."#tab_3"); break; } } if (filter('add') != null) { echo '
{[ "type": "text", "label": "' . _("Nominativo") . '", "name": "nome", "required": 1 ]}
{[ "type": "text", "label": "' . _("Mansione") . '", "name": "mansione", "required": 1 ]}
{[ "type": "text", "label": "' . _("Telefono") . '", "name": "telefono" ]}
{[ "type": "text", "label": "' . _("Indirizzo email") . '", "name": "email" ]}
{[ "type": "select", "label": "' . _("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 '

' . _("Referenti") . '

' . _("Nuovo referente") . '

' . _("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 '
' . _("Nominativo") . ' ' . _("Mansione") . ' ' . _("Telefono") . ' ' . _("Indirizzo email") . ' ' . _("Sede") . ' ' . _("Opzioni") . '
{[ "type": "text", "label": "' . _("Nominativo") . '", "name": "nome[]", "required": 1, "value": "' . $result['nome'] . '", "no-label": "1" ]} {[ "type": "text", "label": "' . _("Mansione") . '", "name": "mansione[]", "required": 1, "value": "' . $result['mansione'] . '", "no-label": "1" ]} {[ "type": "text", "label": "' . _("Telefono") . '", "name": "telefono[]", "value": "' . $result['telefono'] . '", "no-label": "1" ]} {[ "type": "text", "label": "' . _("Indirizzo email") . '", "name": "email[]", "value": "' . $result['email'] . '", "no-label": "1" ]} {[ "type": "select", "label": "' . _("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'] . '", "no-label": "1" ]} ' . _("Elimina") . '
'; } echo '
'; } ?>