diff --git a/modules/anagrafiche/add.php b/modules/anagrafiche/add.php index 70e01ea7b..202120a82 100755 --- a/modules/anagrafiche/add.php +++ b/modules/anagrafiche/add.php @@ -103,10 +103,10 @@ echo '
- {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "class": "text-center", "icon-before": "" ]} + {[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "class": "text-center" ]}
- {[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare", "class": "text-center", "icon-before": "" ]} + {[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare", "class": "text-center" ]}
diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index e05e7ab60..b95487855 100755 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -203,11 +203,11 @@ if (sizeof($problemi_anagrafica) > 0) {
- {[ "type": "text", "label": "", "name": "telefono", "class": "text-center", "value": "$telefono$", "icon-before": "" ]} + {[ "type": "telefono", "label": "", "name": "telefono", "class": "text-center", "value": "$telefono$" ]}
- {[ "type": "text", "label": "", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-before": "", "icon-after": "" : ''; ?>" ]} + {[ "type": "telefono", "label": "", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-after": "" : ''; ?>" ]}
diff --git a/plugins/referenti/add.php b/plugins/referenti/add.php index 581fd7b82..9e129d7f4 100755 --- a/plugins/referenti/add.php +++ b/plugins/referenti/add.php @@ -40,7 +40,7 @@ echo '
- {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]} + {[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono" ]}
@@ -50,7 +50,7 @@ echo '
- {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value": "0", "required": 1, "icon-after": "add|'.$id_module.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$id_parent.'" ]} + {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value": "0", "icon-after": "add|'.$id_module.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$id_parent.'" ]}
diff --git a/plugins/referenti/edit.php b/plugins/referenti/edit.php index ab1b1b1d2..65c1b8354 100755 --- a/plugins/referenti/edit.php +++ b/plugins/referenti/edit.php @@ -39,7 +39,7 @@ echo '
- {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value" : "$telefono$" ]} + {[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "value" : "$telefono$" ]}
@@ -49,7 +49,7 @@ echo '
- {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value" : "$idsede$", "required": 1, "icon-after": "add|'.$id_module.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$id_parent.'" ]} + {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value" : "$idsede$", "icon-after": "add|'.$id_module.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$id_parent.'" ]}
diff --git a/plugins/sedi/actions.php b/plugins/sedi/actions.php index 585c1801a..f34ae0699 100755 --- a/plugins/sedi/actions.php +++ b/plugins/sedi/actions.php @@ -41,13 +41,22 @@ switch ($operazione) { 'idzona' => !empty(post('idzona')) ? post('idzona') : 0, 'enable_newsletter' => empty($opt_out_newsletter), ]); - $id_record = $dbo->lastInsertedID(); + $id_record = $dbo->lastInsertedID(); - if (isAjaxRequest() && !empty($id_record)) { - echo json_encode(['id' => $id_record, 'text' => post('nomesede').' - '.post('citta')]); - } + $id_referenti = (array)post('id_referenti'); + foreach ($id_referenti as $id_referente) { + $dbo->update('an_referenti', [ + 'idsede' => $id_record + ], [ + 'id' => $id_referente + ]); + } - flash()->info(tr('Aggiunta una nuova sede!')); + if (isAjaxRequest() && !empty($id_record)) { + echo json_encode(['id' => $id_record, 'text' => post('nomesede').' - '.post('citta')]); + } + + flash()->info(tr('Aggiunta una nuova sede!')); } else { flash()->warning(tr('Errore durante aggiunta della sede')); } @@ -81,6 +90,15 @@ switch ($operazione) { 'enable_newsletter' => empty($opt_out_newsletter), ], ['id' => $id_record]); + $id_referenti = (array)post('id_referenti'); + foreach ($id_referenti as $id_referente) { + $dbo->update('an_referenti', [ + 'idsede' => $id_record + ], [ + 'id' => $id_referente + ]); + } + flash()->info(tr('Salvataggio completato!')); break; diff --git a/plugins/sedi/add.php b/plugins/sedi/add.php index dc84c737a..e683b53ff 100755 --- a/plugins/sedi/add.php +++ b/plugins/sedi/add.php @@ -78,11 +78,11 @@ echo '
- {[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare" ]} + {[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare" ]}
- {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]} + {[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono" ]}
@@ -96,6 +96,11 @@ echo '
+
+
+ {[ "type": "select", "multiple": "1", "label": "'.tr('Referenti').'", "name": "id_referenti[]", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$id_parent.'}, "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|id_plugin='.Plugins::get('Referenti')['id'].'&id_parent='.$id_parent.'" ]} +
+
diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php index 319b2bbaf..434272b7b 100755 --- a/plugins/sedi/edit.php +++ b/plugins/sedi/edit.php @@ -19,6 +19,9 @@ include_once __DIR__.'/../../core.php'; +$referenti = $dbo->select('an_referenti', 'id', [], ['idsede' => $id_record, 'idanagrafica' => $id_parent]); +$referenti = implode(',', array_column($referenti, 'id')); + echo '
@@ -67,7 +70,7 @@ echo '
- {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value": "$telefono$" ]} + {[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "value": "$telefono$" ]}
@@ -77,7 +80,7 @@ echo '
- {[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare", "value": "$cellulare$" ]} + {[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare", "value": "$cellulare$" ]}
@@ -95,6 +98,12 @@ echo '
+
+
+ {[ "type": "select", "multiple": "1", "label": "'.tr('Referenti').'", "name": "id_referenti[]", "value": "'.$referenti.'", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$id_parent.'}, "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|id_plugin='.Plugins::get('Referenti')['id'].'&id_parent='.$id_parent.'" ]} +
+
+
{[ "type": "textarea", "label": "'.tr('Note').'", "name": "note", "value": "$note$" ]} @@ -102,11 +111,11 @@ echo '
-
+
{[ "type": "text", "label": "'.tr('Indirizzo Mappa').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]}
-
+

@@ -119,24 +128,23 @@ echo ' {[ "type": "text", "label": "'.tr('Longitudine').'", "name": "lng", "id": "lng_", "value": "$lng$", "extra": "data-geo=\'lng\'", "class": "text-right", "readonly": true ]}
'; -if (!empty($record['indirizzo']) || (empty($record['citta']))) { - echo ' -
+ if (!empty($record['indirizzo']) || (empty($record['citta']))) { + echo ' +

   - '; - echo ' -

'; -} +
+

'; + } echo ' -
'; +
'; if (!empty($record['gaddress']) || (!empty($record['lat']) && !empty($record['lng']))) { echo ' -

'; +

'; } // Permetto eliminazione tipo sede solo se non รจ utilizzata da nessun'altra parte nel gestionale diff --git a/src/HTMLBuilder/Handler/DefaultHandler.php b/src/HTMLBuilder/Handler/DefaultHandler.php index d3696930d..f14d5330a 100755 --- a/src/HTMLBuilder/Handler/DefaultHandler.php +++ b/src/HTMLBuilder/Handler/DefaultHandler.php @@ -20,7 +20,7 @@ namespace HTMLBuilder\Handler; /** - * Gestione dell'input di tipo "text", "file", "password", "email", "number", "textarea" e "hidden". + * Gestione dell'input di tipo "text", "file", "password", "telefono", "email", "number", "textarea" e "hidden". * * @since 2.3 */ @@ -206,6 +206,25 @@ class DefaultHandler implements HandlerInterface return $result; } + /** + * Gestione dell'input di tipo "telefono". + * Esempio: {[ "type": "telefono", "label": "Telefono", "name": "telefono" ]}. + * + * @param array $values + * @param array $extras + * + * @return string + */ + protected function telefono(&$values, &$extras) + { + $values['icon-before'] = $values['value'] ? '' : ''; + + // Delega al metodo "text", per la generazione del codice HTML + $result = $this->text($values, $extras); + + return $result; + } + /** * Gestione dell'input di tipo "hidden". * Esempio: {[ "type": "hidden", "label": "Hidden di test", "placeholder": "Test", "name": "hidden" ]}.