diff --git a/modules/anagrafiche/actions.php b/modules/anagrafiche/actions.php index ac299bb49..47ea5f92c 100644 --- a/modules/anagrafiche/actions.php +++ b/modules/anagrafiche/actions.php @@ -264,9 +264,15 @@ switch (post('op')) { // Se l'anagrafica non è l'azienda principale, la disattivo if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) { $dbo->query('UPDATE an_anagrafiche SET deleted = 1 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module)); - + + // Se l'anagrafica è collegata ad un utente lo disabilito + $dbo->query('UPDATE zz_users SET enabled = 0 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module)); + + $_SESSION['infos'][] = tr('Anagrafica eliminata!'); } + + break; } diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index e421d1ea0..ff5409df3 100644 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -24,354 +24,356 @@ if (!$cliente) { } ?> -
- - - -
-
-

-
+ +
> + + -
-
-
- {[ "type": "text", "label": "", "name": "ragione_sociale", "required": 1, "value": "$ragione_sociale$" ]} -
- -
- {[ "type": "select", "label": "", "name": "tipo", "values": "list=\"\": \"\", \"Azienda\": \"\", \"Privato\": \"\", \"Ente pubblico\": \"\"", "value": "$tipo$" ]} -
+ +
+
+

-
-
- {[ "type": "text", "label": "", "maxlength": 13, "name": "piva", "class": "text-center alphanumeric-mask", "value": "$piva$" ]} +
+
+
+ {[ "type": "text", "label": "", "name": "ragione_sociale", "required": 1, "value": "$ragione_sociale$" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "tipo", "values": "list=\"\": \"\", \"Azienda\": \"\", \"Privato\": \"\", \"Ente pubblico\": \"\"", "value": "$tipo$" ]} +
-
- {[ "type": "text", "label": "", "maxlength": 16, "name": "codice_fiscale", "class": "text-center alphanumeric-mask", "value": "$codice_fiscale$" ]} +
+
+ {[ "type": "text", "label": "", "maxlength": 13, "name": "piva", "class": "text-center alphanumeric-mask", "value": "$piva$" ]} +
+ +
+ {[ "type": "text", "label": "", "maxlength": 16, "name": "codice_fiscale", "class": "text-center alphanumeric-mask", "value": "$codice_fiscale$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "codice", "required": 1, "class": "text-center", "value": "$codice$" ]} +
-
- {[ "type": "text", "label": "", "name": "codice", "required": 1, "class": "text-center", "value": "$codice$" ]} -
-
+
+
+ {[ "type": "text", "label": "", "name": "luogo_nascita", "value": "$luogo_nascita$" ]} +
-
-
- {[ "type": "text", "label": "", "name": "luogo_nascita", "value": "$luogo_nascita$" ]} +
+ {[ "type": "date", "label": "", "maxlength": 10, "name": "data_nascita", "value": "$data_nascita$" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "sesso", "values": "list=\"\": \"Non specificato\", \"M\": \"\", \"F\": \"\"", "value": "$sesso$" ]} +
-
- {[ "type": "date", "label": "", "maxlength": 10, "name": "data_nascita", "value": "$data_nascita$" ]} +
+
+ {[ "type": "text", "label": "", "name": "indirizzo", "value": "$indirizzo$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "indirizzo2", "value": "$indirizzo2$" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idzona", "values": "query=SELECT id, CONCAT_WS( ' - ', nome, descrizione) AS descrizione FROM an_zone ORDER BY descrizione ASC", "value": "$idzona$", "placeholder": "", "icon-after": "add|" ]} +
-
- {[ "type": "select", "label": "", "name": "sesso", "values": "list=\"\": \"Non specificato\", \"M\": \"\", \"F\": \"\"", "value": "$sesso$" ]} -
-
+
+
+ {[ "type": "select", "label": "", "name": "id_nazione", "values": "query=SELECT id AS id, nome AS descrizione FROM an_nazioni ORDER BY nome ASC", "value": "$id_nazione$" ]} +
-
-
- {[ "type": "text", "label": "", "name": "indirizzo", "value": "$indirizzo$" ]} -
+
+ {[ "type": "text", "label": "", "name": "cap", "maxlength": 5, "class": "text-center", "value": "$cap$" ]} +
-
- {[ "type": "text", "label": "", "name": "indirizzo2", "value": "$indirizzo2$" ]} -
+
+ {[ "type": "text", "label": "", "name": "citta", "class": "text-center", "value": "$citta$" ]} +
-
- {[ "type": "select", "label": "", "name": "idzona", "values": "query=SELECT id, CONCAT_WS( ' - ', nome, descrizione) AS descrizione FROM an_zone ORDER BY descrizione ASC", "value": "$idzona$", "placeholder": "", "icon-after": "add|" ]} -
-
+
+ {[ "type": "text", "label": "", "name": "provincia", "maxlength": 2, "class": "text-center", "value": "$provincia$" ]} +
-
-
- {[ "type": "select", "label": "", "name": "id_nazione", "values": "query=SELECT id AS id, nome AS descrizione FROM an_nazioni ORDER BY nome ASC", "value": "$id_nazione$" ]} -
- -
- {[ "type": "text", "label": "", "name": "cap", "maxlength": 5, "class": "text-center", "value": "$cap$" ]} -
- -
- {[ "type": "text", "label": "", "name": "citta", "class": "text-center", "value": "$citta$" ]} -
- -
- {[ "type": "text", "label": "", "name": "provincia", "maxlength": 2, "class": "text-center", "value": "$provincia$" ]} -
- -
- {[ "type": "number", "label": "", "name": "km", "decimals":"1", "class": "text-center", "value": "$km$", "icon-after": "Km" ]} +
+ {[ "type": "number", "label": "", "name": "km", "decimals":"1", "class": "text-center", "value": "$km$", "icon-after": "Km" ]} +
-
- -
-
-

-
- -
-
-
- {[ "type": "text", "label": "", "name": "telefono", "class": "text-center", "value": "$telefono$", "icon-before": "" ]} -
- -
- {[ "type": "text", "label": "", "name": "fax", "class": "text-center", "value": "$fax$", "icon-before": "" ]} -
- -
- {[ "type": "text", "label": "", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-before": "" ]} -
+ +
+
+

-
-
- {[ "type": "text", "label": "", "name": "email", "class": "email-mask", "placeholder":"casella@dominio.ext", "value": "$email$", "icon-before": "" ]} +
+
+
+ {[ "type": "text", "label": "", "name": "telefono", "class": "text-center", "value": "$telefono$", "icon-before": "" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "fax", "class": "text-center", "value": "$fax$", "icon-before": "" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-before": "" ]} +
-
- {[ "type": "text", "label": "", "name": "pec", "class": "email-mask", "placeholder":"pec@dominio.ext", "value": "$pec$", "icon-before": "" ]} -
+
+
+ {[ "type": "text", "label": "", "name": "email", "class": "email-mask", "placeholder":"casella@dominio.ext", "value": "$email$", "icon-before": "" ]} +
-
- {[ "type": "text", "label": "", "name": "sitoweb", "placeholder":"www.dominio.ext", "value": "$sitoweb$", "icon-before": "" ]} -
+
+ {[ "type": "text", "label": "", "name": "pec", "class": "email-mask", "placeholder":"pec@dominio.ext", "value": "$pec$", "icon-before": "" ]} +
- +
+ {[ "type": "text", "label": "", "name": "sitoweb", "placeholder":"www.dominio.ext", "value": "$sitoweb$", "icon-before": "" ]} +
+ + +
-
- - - - -
-
-
-
-

-
- -
- -
-
- {[ "type": "select", "label": "", "name": "idpagamento_acquisti", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_acquisti$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idbanca_acquisti", "values": "query=SELECT id, nome AS descrizione FROM co_banche ORDER BY nome ASC", "value": "$idbanca_acquisti$", "extra": "", "icon-after": "add||||" ]} -
- -
- {[ "type": "select", "label": "", "name": "idiva_acquisti", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_acquisti$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idlistino_acquisti", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_acquisti$", "extra": "" ]} -
- + if ($cliente || $fornitore) { + ?> + + + +
+
+
+
+

-
-
-
- -
- -
-
-

-
+
-
- -
-
- {[ "type": "select", "label": "", "name": "idpagamento_vendite", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_vendite$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idbanca_vendite", "values": "query=SELECT id, nome AS descrizione FROM co_banche ORDER BY nome ASC", "value": "$idbanca_vendite$", "extra": "", "icon-after": "add||||" ]} -
- -
- {[ "type": "select", "label": "", "name": "idiva_vendite", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_vendite$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idlistino_vendite", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_vendite$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idsede_fatturazione", "values": "query=SELECT id, IF(citta = '', nomesede, CONCAT_WS(', ', nomesede, citta)) AS descrizione FROM an_sedi WHERE idanagrafica='' UNION SELECT '0' AS id, 'Sede legale' AS descrizione ORDER BY descrizione", "value": "$idsede_fatturazione$" , "extra": "" ]} -
- -
- {[ "type": "select", "label": "", "name": "idtipointervento_default", "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "$idtipointervento_default$", "extra": "" ]} -
- -
- {[ "type": "select", "label": "Agente principale", "name": "idagente", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, IF(deleted=1, CONCAT(ragione_sociale, ' (Eliminato)'), ragione_sociale ) AS descrizione 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 (descrizione='Agente' AND deleted=0)ORDER BY ragione_sociale", "value": "$idagente$", "extra": "" ]} -
- -
-
-
-
-
-
- - - -
-
-

-
- -
-
-
- {[ "type": "text", "label": "", "name": "codiceri", "value": "$codiceri$" ]} -
- -
- {[ "type": "text", "label": "('.tr('provincia/C.C.I.A.A.').')'; ?>", "name": "codicerea", "value": "$codicerea$" ]} -
- -
- {[ "type": "text", "label": "", "name": "cciaa", "value": "$cciaa$" ]} -
- -
- {[ "type": "text", "label": "", "name": "cciaa_citta", "value": "$cciaa_citta$" ]} -
-
-
-
- {[ "type": "text", "label": "", "name": "iscrizione_tribunale", "value": "$iscrizione_tribunale$" ]} -
- -
- {[ "type": "text", "label": "", "name": "n_alboartigiani", "value": "$n_alboartigiani$" ]} -
- -
- {[ "type": "text", "label": "", "name": "foro_competenza", "value": "$foro_competenza$" ]} -
- -
- {[ "type": "text", "label": "", "name": "capitale_sociale", "value": "$capitale_sociale$" ]} -
-
- - -
-
- {[ "type": "text", "label": "", "name": "appoggiobancario", "value": "$appoggiobancario$" ]} -
- -
- {[ "type": "text", "label": "", "name": "filiale", "value": "$filiale$" ]} -
- -
- {[ "type": "text", "label": "", "name": "codiceiban", "value": "$codiceiban$" ]} -
- -
- {[ "type": "text", "label": "", "name": "bic", "value": "$bic$" ]} -
-
- - - -
-
- {[ "type": "text", "label": "", "name": "diciturafissafattura", "value": "$diciturafissafattura$" ]} -
-
- -
-
- {[ "type": "text", "label": "", "name": "settore", "value": "$settore$" ]} -
- -
- {[ "type": "text", "label": "", "name": "marche", "value": "$marche$" ]} -
- -
- {[ "type": "number", "label": "", "name": "dipendenti", "decimals": 0, "value": "$dipendenti$" ]} -
- -
- {[ "type": "number", "label": "", "name": "macchine", "decimals": 0, "value": "$macchine$" ]} -
-
- - -
-
- {[ "type": "select", "multiple": "1", "label": "", "name": "idtipoanagrafica[]", "values": "query=SELECT idtipoanagrafica AS id, descrizione FROM an_tipianagrafiche WHERE idtipoanagrafica NOT IN (SELECT DISTINCT(x.idtipoanagrafica) FROM an_tipianagrafiche_anagrafiche x INNER JOIN an_tipianagrafiche t ON x.idtipoanagrafica = t.idtipoanagrafica INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = x.idanagrafica WHERE t.descrizione = 'Azienda' AND deleted = 0) ORDER BY descrizione", "value": "$idtipianagrafica$" ]} - '.tr('Questa anagrafica appartiene alla tipologia "Azienda"').'.

'; - } - ?> -
-
-
- -
- {[ "type": "text", "label": "", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
" ]} -
- - +
- {[ "type": "select", "label": "Agenti secondari", "multiple": "1", "name": "idagenti[]", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, IF(deleted=1, CONCAT(ragione_sociale, ' (Eliminato)'), ragione_sociale ) AS descrizione 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 (descrizione='Agente' AND deleted=0 AND an_anagrafiche.idanagrafica NOT IN (SELECT idagente FROM an_anagrafiche WHERE idanagrafica = )) OR (an_anagrafiche.idanagrafica IN (SELECT idagente FROM an_anagrafiche_agenti WHERE idanagrafica = ) ) ORDER BY ragione_sociale", "value": "$idagenti$" ]} + {[ "type": "select", "label": "", "name": "idpagamento_acquisti", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_acquisti$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idbanca_acquisti", "values": "query=SELECT id, nome AS descrizione FROM co_banche ORDER BY nome ASC", "value": "$idbanca_acquisti$", "extra": "", "icon-after": "add||||" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idiva_acquisti", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_acquisti$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idlistino_acquisti", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_acquisti$", "extra": "" ]} +
+ +
+ +
+
+
+ +
+ +
+
+

+
+ +
+ +
+
+ {[ "type": "select", "label": "", "name": "idpagamento_vendite", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_vendite$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idbanca_vendite", "values": "query=SELECT id, nome AS descrizione FROM co_banche ORDER BY nome ASC", "value": "$idbanca_vendite$", "extra": "", "icon-after": "add||||" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idiva_vendite", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_vendite$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idlistino_vendite", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_vendite$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idsede_fatturazione", "values": "query=SELECT id, IF(citta = '', nomesede, CONCAT_WS(', ', nomesede, citta)) AS descrizione FROM an_sedi WHERE idanagrafica='' UNION SELECT '0' AS id, 'Sede legale' AS descrizione ORDER BY descrizione", "value": "$idsede_fatturazione$" , "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idtipointervento_default", "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "$idtipointervento_default$", "extra": "" ]} +
+ +
+ {[ "type": "select", "label": "Agente principale", "name": "idagente", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, IF(deleted=1, CONCAT(ragione_sociale, ' (Eliminato)'), ragione_sociale ) AS descrizione 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 (descrizione='Agente' AND deleted=0)ORDER BY ragione_sociale", "value": "$idagente$", "extra": "" ]} +
+ +
+
+
+
+
+
+ + + +
+
+

+
+ +
+
+
+ {[ "type": "text", "label": "", "name": "codiceri", "value": "$codiceri$" ]}
- {[ "type": "select", "label": "", "name": "idrelazione", "values": "query=SELECT id, descrizione, colore AS _bgcolor_ FROM an_relazioni ORDER BY descrizione", "value": "$idrelazione$" ]} + {[ "type": "text", "label": "('.tr('provincia/C.C.I.A.A.').')'; ?>", "name": "codicerea", "value": "$codicerea$" ]}
- -
+
+ {[ "type": "text", "label": "", "name": "cciaa", "value": "$cciaa$" ]} +
-
-
- {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} +
+ {[ "type": "text", "label": "", "name": "cciaa_citta", "value": "$cciaa_citta$" ]} +
+
+
+
+ {[ "type": "text", "label": "", "name": "iscrizione_tribunale", "value": "$iscrizione_tribunale$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "n_alboartigiani", "value": "$n_alboartigiani$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "foro_competenza", "value": "$foro_competenza$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "capitale_sociale", "value": "$capitale_sociale$" ]} +
+
+ + +
+
+ {[ "type": "text", "label": "", "name": "appoggiobancario", "value": "$appoggiobancario$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "filiale", "value": "$filiale$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "codiceiban", "value": "$codiceiban$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "bic", "value": "$bic$" ]} +
+
+ + + +
+
+ {[ "type": "text", "label": "", "name": "diciturafissafattura", "value": "$diciturafissafattura$" ]} +
+
+ +
+
+ {[ "type": "text", "label": "", "name": "settore", "value": "$settore$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "marche", "value": "$marche$" ]} +
+ +
+ {[ "type": "number", "label": "", "name": "dipendenti", "decimals": 0, "value": "$dipendenti$" ]} +
+ +
+ {[ "type": "number", "label": "", "name": "macchine", "decimals": 0, "value": "$macchine$" ]} +
+
+ + +
+
+ {[ "type": "select", "multiple": "1", "label": "", "name": "idtipoanagrafica[]", "values": "query=SELECT idtipoanagrafica AS id, descrizione FROM an_tipianagrafiche WHERE idtipoanagrafica NOT IN (SELECT DISTINCT(x.idtipoanagrafica) FROM an_tipianagrafiche_anagrafiche x INNER JOIN an_tipianagrafiche t ON x.idtipoanagrafica = t.idtipoanagrafica INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = x.idanagrafica WHERE t.descrizione = 'Azienda' AND deleted = 0) ORDER BY descrizione", "value": "$idtipianagrafica$" ]} + '.tr('Questa anagrafica appartiene alla tipologia "Azienda"').'.

'; + } + ?> +
+
+
+ +
+ {[ "type": "text", "label": "", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
" ]} +
+ + +
+ {[ "type": "select", "label": "Agenti secondari", "multiple": "1", "name": "idagenti[]", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, IF(deleted=1, CONCAT(ragione_sociale, ' (Eliminato)'), ragione_sociale ) AS descrizione 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 (descrizione='Agente' AND deleted=0 AND an_anagrafiche.idanagrafica NOT IN (SELECT idagente FROM an_anagrafiche WHERE idanagrafica = )) OR (an_anagrafiche.idanagrafica IN (SELECT idagente FROM an_anagrafiche_agenti WHERE idanagrafica = ) ) ORDER BY ragione_sociale", "value": "$idagenti$" ]} +
+ +
+ {[ "type": "select", "label": "", "name": "idrelazione", "values": "query=SELECT id, descrizione, colore AS _bgcolor_ FROM an_relazioni ORDER BY descrizione", "value": "$idrelazione$" ]} +
+ +
+ + +
+
+ {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} +
-
+
-
+
{( "name": "filelist_and_upload", "id_module": "", "id_record": "" )} fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idanagrafica` = '.prepare($id_record).') +if (!$records[0]['deleted']){ + + //fatture, ddt, preventivi, contratti, ordini, interventi, utenti collegati a questa anagrafica + $elementi = $dbo->fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idanagrafica` = '.prepare($id_record).') + + UNION + SELECT `zz_users`.`id`, `zz_users`.`created_at` AS data, `zz_users`.`username` AS numero, 0 AS `numero_esterno`, "Utente" AS tipo_documento, 0 AS `dir` FROM `zz_users` WHERE `zz_users`.`idanagrafica` = '.prepare($id_record).' + + UNION + SELECT `or_ordini`.`id`, `or_ordini`.`data`, `or_ordini`.`numero`, `or_ordini`.`numero_esterno`, `or_tipiordine`.`descrizione` AS tipo_documento, `or_tipiordine`.`dir` FROM `or_ordini` JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` WHERE `or_ordini`.`idanagrafica` = '.prepare($id_record).' + + UNION + SELECT `dt_ddt`.`id`, `dt_ddt`.`data`, `dt_ddt`.`numero`, `dt_ddt`.`numero_esterno`, `dt_tipiddt`.`descrizione` AS tipo_documento, `dt_tipiddt`.`dir` FROM `dt_ddt` JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `dt_ddt`.`idanagrafica` = '.prepare($id_record).' UNION -SELECT `or_ordini`.`id`, `or_ordini`.`data`, `or_ordini`.`numero`, `or_ordini`.`numero_esterno`, `or_tipiordine`.`descrizione` AS tipo_documento, `or_tipiordine`.`dir` FROM `or_ordini` JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` WHERE `or_ordini`.`idanagrafica` = '.prepare($id_record).' + SELECT `in_interventi`.`id`, `in_interventi`.`data_richiesta`, `in_interventi`.`codice` AS numero, 0 AS numero_esterno, "Intervento" AS tipo_documento, 0 AS dir FROM `in_interventi` JOIN `in_interventi_tecnici` ON `in_interventi`.`id` = `in_interventi_tecnici`.`idintervento` WHERE `in_interventi`.`id` IN (SELECT `idintervento` FROM `in_interventi_tecnici` WHERE `idtecnico` = '.prepare($id_record).' OR `in_interventi`.`idanagrafica` = '.prepare($id_record).' ) UNION -SELECT `dt_ddt`.`id`, `dt_ddt`.`data`, `dt_ddt`.`numero`, `dt_ddt`.`numero_esterno`, `dt_tipiddt`.`descrizione` AS tipo_documento, `dt_tipiddt`.`dir` FROM `dt_ddt` JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `dt_ddt`.`idanagrafica` = '.prepare($id_record).' + SELECT `co_contratti`.`id`, `co_contratti`.`data_bozza`, `co_contratti`.`numero`, 0 AS numero_esterno , "Contratto" AS tipo_documento, 0 AS dir FROM `co_contratti` WHERE `co_contratti`.`id` IN (SELECT `idcontratto` FROM `co_righe_contratti` WHERE `idanagrafica` = '.prepare($id_record).') -UNION -SELECT `in_interventi`.`id`, `in_interventi`.`data_richiesta`, `in_interventi`.`codice` AS numero, 0 AS numero_esterno, "Intervento" AS tipo_documento, 0 AS dir FROM `in_interventi` JOIN `in_interventi_tecnici` ON `in_interventi`.`id` = `in_interventi_tecnici`.`idintervento` WHERE `in_interventi`.`id` IN (SELECT `idintervento` FROM `in_interventi_tecnici` WHERE `idtecnico` = '.prepare($id_record).' OR `in_interventi`.`idanagrafica` = '.prepare($id_record).' ) + UNION + SELECT `co_preventivi`.`id`, `co_preventivi`.`data_bozza`, `co_preventivi`.`numero`, 0 AS numero_esterno , "Preventivo" AS tipo_documento, 0 AS dir FROM `co_preventivi` WHERE `co_preventivi`.`id` IN (SELECT `idpreventivo` FROM `co_righe_preventivi` WHERE `idanagrafica` = '.prepare($id_record).') ORDER BY `data`'); -UNION -SELECT `co_contratti`.`id`, `co_contratti`.`data_bozza`, `co_contratti`.`numero`, 0 AS numero_esterno , "Contratto" AS tipo_documento, 0 AS dir FROM `co_contratti` WHERE `co_contratti`.`id` IN (SELECT `idcontratto` FROM `co_righe_contratti` WHERE `idanagrafica` = '.prepare($id_record).') + if (!empty($elementi)) { + echo ' +
+

'.tr('_NUM_ altr_I_ document_I_ collegat_I_', [ + '_NUM_' => count($elementi), + '_I_' => (count($elementi) > 1) ? tr('i') : tr('o'), + ]).':

+
    '; -UNION -SELECT `co_preventivi`.`id`, `co_preventivi`.`data_bozza`, `co_preventivi`.`numero`, 0 AS numero_esterno , "Preventivo" AS tipo_documento, 0 AS dir FROM `co_preventivi` WHERE `co_preventivi`.`id` IN (SELECT `idpreventivo` FROM `co_righe_preventivi` WHERE `idanagrafica` = '.prepare($id_record).') ORDER BY `data`'); + foreach ($elementi as $elemento) { + $descrizione = tr('_DOC_ _NUM_ del _DATE_', [ + '_DOC_' => $elemento['tipo_documento'], + '_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'], + '_DATE_' => Translator::dateToLocale($elemento['data']), + ]); -if (!empty($elementi)) { - echo ' -
    -

    '.tr('_NUM_ altr_I_ document_I_ collegat_I_', [ - '_NUM_' => count($elementi), - '_I_' => (count($elementi) > 1) ? tr('i') : tr('o'), - ]).':

    -
      '; + //se non è un preventivo è un ddt o una fattura + //se non è un ddt è una fattura. + if (in_array($elemento['tipo_documento'], ['Utente'])) { + $modulo = 'Utenti e permessi'; + } + elseif (in_array($elemento['tipo_documento'], ['Intervento'])) { + $modulo = 'Interventi'; + } + elseif (in_array($elemento['tipo_documento'], ['Preventivo'])) { + $modulo = 'Preventivi'; + } + elseif (in_array($elemento['tipo_documento'], ['Contratto'])) { + $modulo = 'Contratti'; + } + elseif (in_array($elemento['tipo_documento'], ['Ordine cliente', 'Ordine fornitore'])) { + $modulo = ($elemento['dir'] == 'entrata') ? 'Ordini cliente' : 'Ordini fornitore'; + } + elseif (in_array($elemento['tipo_documento'], ['Ddt di vendita', 'Ddt di acquisto'])) { + $modulo = ($elemento['dir'] == 'entrata') ? 'Ddt di vendita' : 'Ddt di acquisto'; + } + else { + $modulo = ($elemento['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; + } - foreach ($elementi as $elemento) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $elemento['tipo_documento'], - '_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'], - '_DATE_' => Translator::dateToLocale($elemento['data']), - ]); + $id = $elemento['id']; - //se non è un preventivo è un ddt o una fattura - //se non è un ddt è una fattura. - if (in_array($elemento['tipo_documento'], ['Intervento'])) { - $modulo = 'Interventi'; - } - elseif (in_array($elemento['tipo_documento'], ['Preventivo'])) { - $modulo = 'Preventivi'; - } - elseif (in_array($elemento['tipo_documento'], ['Contratto'])) { - $modulo = 'Contratti'; - } - elseif (in_array($elemento['tipo_documento'], ['Ordine cliente', 'Ordine fornitore'])) { - $modulo = ($elemento['dir'] == 'entrata') ? 'Ordini cliente' : 'Ordini fornitore'; - } - elseif (in_array($elemento['tipo_documento'], ['Ddt di vendita', 'Ddt di acquisto'])) { - $modulo = ($elemento['dir'] == 'entrata') ? 'Ddt di vendita' : 'Ddt di acquisto'; - } - else { - $modulo = ($elemento['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; - } + echo ' +
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; + } - $id = $elemento['id']; - - echo ' -
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; - } - - echo ' -
    -

    '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale.').'

    -
    '; -} + echo ' +
+

'.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale.').'

+
'; + } -if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) { - echo ' - - '.tr('Elimina').' -'; + if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) { + echo ' + + '.tr('Elimina').' + '; + }else{ + + echo ' +
'.tr('Questa è l\'anagrafica "Azienda" e non è possibile eliminarla').'.
'; + } + }else{ - - echo ' -
'.tr('Questa è l\'anagrafica "Azienda" e non è possibile eliminarla').'.
'; + + echo ' +
'.tr('Questa anagrafica è stata eliminata').'.
'; + } ?> diff --git a/modules/utenti/user.php b/modules/utenti/user.php index a710d0d23..e4bc2265d 100644 --- a/modules/utenti/user.php +++ b/modules/utenti/user.php @@ -17,8 +17,14 @@ if ($self_edit) { $idgruppo = intval(filter('idgruppo')); $id_utente = filter('id_utente'); + //gruppo della selezione $nome_gruppo = $dbo->fetchArray('SELECT nome FROM zz_groups WHERE id='.prepare($idgruppo))[0]['nome']; - $nome_gruppo = substr($nome_gruppo, 0, -1).'o'; + $gruppi = [ + 'Clienti' => 'Cliente', + 'Tecnici' => 'Tecnico', + 'Agenti' => 'Agente', + ]; + $nome_gruppo = $gruppi[$nome_gruppo]; }