1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-31 07:55:17 +01:00

Gestione input telefono e gestione referenti da sede

This commit is contained in:
MatteoPistorello 2023-10-06 12:44:54 +02:00
parent 6ea89e29dc
commit 7276a0a913
8 changed files with 79 additions and 29 deletions

View File

@ -103,10 +103,10 @@ echo '
</div>
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "class": "text-center", "icon-before": "<i class=\"fa fa-phone\"></i>" ]}
{[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "class": "text-center" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare", "class": "text-center", "icon-before": "<i class=\"fa fa-mobile\"></i>" ]}
{[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare", "class": "text-center" ]}
</div>
</div>

View File

@ -203,11 +203,11 @@ if (sizeof($problemi_anagrafica) > 0) {
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Telefono'); ?>", "name": "telefono", "class": "text-center", "value": "$telefono$", "icon-before": "<i class='fa fa-phone'></i>" ]}
{[ "type": "telefono", "label": "<?php echo tr('Telefono'); ?>", "name": "telefono", "class": "text-center", "value": "$telefono$" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Cellulare'); ?>", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-before": "<i class='fa fa-mobile'></i>", "icon-after": "<?php echo !empty($record['cellulare']) ? "<btn class='clickable' onclick=sendWhatsAppMessage(".prepare($record['cellulare']).") ><i class='fa fa-whatsapp'></i></btn>" : ''; ?>" ]}
{[ "type": "telefono", "label": "<?php echo tr('Cellulare'); ?>", "name": "cellulare", "class": "text-center", "value": "$cellulare$", "icon-after": "<?php echo !empty($record['cellulare']) ? "<btn class='clickable' onclick=sendWhatsAppMessage(".prepare($record['cellulare']).") ><i class='fa fa-whatsapp'></i></btn>" : ''; ?>" ]}
</div>
<div class="col-md-4">

View File

@ -40,7 +40,7 @@ echo '
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]}
{[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono" ]}
</div>
<div class="col-md-6">
@ -50,7 +50,7 @@ echo '
<div class="row">
<div class="col-md-6">
{[ "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.'" ]}
</div>
<div class="col-md-6">

View File

@ -39,7 +39,7 @@ echo '
<div class="row">
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value" : "$telefono$" ]}
{[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "value" : "$telefono$" ]}
</div>
<div class="col-md-6">
@ -49,7 +49,7 @@ echo '
<div class="row">
<div class="col-md-6">
{[ "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.'" ]}
</div>
<div class="col-md-6">

View File

@ -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;

View File

@ -78,11 +78,11 @@ echo '
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare" ]}
{[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]}
{[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono" ]}
</div>
<div class="col-md-4">
@ -96,6 +96,11 @@ echo '
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "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.'" ]}
</div>
</div>
<!-- PULSANTI -->
<div class="row">

View File

@ -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 '
<form action="" method="post" role="form" id="form_sedi">
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
@ -67,7 +70,7 @@ echo '
</div>
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value": "$telefono$" ]}
{[ "type": "telefono", "label": "'.tr('Telefono').'", "name": "telefono", "value": "$telefono$" ]}
</div>
</div>
@ -77,7 +80,7 @@ echo '
</div>
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare", "value": "$cellulare$" ]}
{[ "type": "telefono", "label": "'.tr('Cellulare').'", "name": "cellulare", "value": "$cellulare$" ]}
</div>
</div>
@ -95,6 +98,12 @@ echo '
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "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.'" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "'.tr('Note').'", "name": "note", "value": "$note$" ]}
@ -102,11 +111,11 @@ echo '
</div>
<div class="row">
<div class="col-md-6" id="geocomplete">
<div class="col-md-5" id="geocomplete">
{[ "type": "text", "label": "'.tr('Indirizzo Mappa').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]}
</div>
<div class="col-md-2">
<div class="col-md-1">
<label>&nbsp;</label>
<br><button type="button" class="btn btn-primary" onclick="initGeocomplete();"><i class="fa fa-search"></i> '.tr('Cerca').'</button>
</div>
@ -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 ]}
</div>';
if (!empty($record['indirizzo']) || (empty($record['citta']))) {
echo '
<div class="col-md-2" >
if (!empty($record['indirizzo']) || (empty($record['citta']))) {
echo '
<div class="col-md-2">
<label>&nbsp;</label><br>
<a class="btn btn-info" title="'.tr('Mostra la sede su Mappa').'" onclick="cercaOpenStreetMap();">&nbsp;<i class="fa fa-map-marker">&nbsp;</i></a>
';
echo '
<a title="'.tr('Calcola percorso da sede legale a questa sede').'" class="btn btn-primary" onclick="calcolaPercorso();"><i class="fa fa-car"></i></a>
</div> <div class="clearfix"></div><br>';
}
</div>
<div class="clearfix"></div><br>';
}
echo '
</div>';
</div>';
if (!empty($record['gaddress']) || (!empty($record['lat']) && !empty($record['lng']))) {
echo '
<div id="map" style="height:400px; width:100%"></div><br>';
<div id="map" style="height:400px; width:100%"></div><br>';
}
// Permetto eliminazione tipo sede solo se non è utilizzata da nessun'altra parte nel gestionale

View File

@ -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'] ? '<a href="tel:'.$values['value'].'" target="_blank"><i class="fa fa-phone"></i></a>' : '<i class="fa fa-phone"></i>';
// 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" ]}.