2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
use Modules\Interventi\Intervento ;
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2020-08-04 18:33:28 +02:00
// Lettura dei parametri di interesse
2020-08-04 16:29:01 +02:00
$id_anagrafica = filter ( 'idanagrafica' );
$id_sede = filter ( 'idsede' );
$richiesta = filter ( 'richiesta' );
2023-03-31 14:15:09 +02:00
$descrizione = filter ( 'descrizione' );
2021-07-16 18:18:10 +02:00
$id_tipo = filter ( 'id_tipo' );
2018-08-11 15:37:38 +02:00
2020-08-04 16:29:01 +02:00
$origine_dashboard = get ( 'ref' ) !== null ;
$module_anagrafiche = Modules :: get ( 'Anagrafiche' );
2021-11-18 14:46:13 +01:00
$id_plugin_sedi = Plugins :: get ( 'Sedi' )[ 'id' ];
2017-09-18 18:11:19 +02:00
2020-08-04 16:29:01 +02:00
// Calcolo dell'orario di inizio e di fine sulla base delle informazioni fornite
$orario_inizio = filter ( 'orario_inizio' );
$orario_fine = filter ( 'orario_fine' );
if ( null == $orario_inizio || '00:00:00' == $orario_inizio ) {
$orario_inizio = date ( 'H' ) . ':00:00' ;
2022-02-15 16:56:20 +01:00
$orario_fine = date ( 'H' ) . ':00:00' ;
2020-08-04 16:29:01 +02:00
}
2019-07-11 15:05:36 +02:00
2020-08-04 16:29:01 +02:00
// Un utente del gruppo Tecnici può aprire attività solo a proprio nome
2020-09-15 12:30:25 +02:00
$id_tecnico = filter ( 'id_tecnico' );
2020-08-04 16:29:01 +02:00
if ( $user [ 'gruppo' ] == 'Tecnici' && ! empty ( $user [ 'idanagrafica' ])) {
$id_tecnico = $user [ 'idanagrafica' ];
2020-10-16 08:31:10 +02:00
} elseif ( $user [ 'gruppo' ] == 'Clienti' && ! empty ( $user [ 'idanagrafica' ])) {
2020-10-06 12:29:14 +02:00
$id_cliente = $user [ 'idanagrafica' ];
2017-08-04 16:28:16 +02:00
}
2020-08-04 16:29:01 +02:00
// Se è indicata un'anagrafica relativa, si carica il tipo di intervento di default impostato
if ( ! empty ( $id_anagrafica )) {
$anagrafica = $dbo -> fetchOne ( 'SELECT idtipointervento_default, idzona FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $id_anagrafica ));
2021-07-19 09:40:49 +02:00
$id_tipo = $id_tipo ? : $anagrafica [ 'idtipointervento_default' ];
2020-08-04 16:29:01 +02:00
$id_zona = $anagrafica [ 'idzona' ];
2017-08-04 16:28:16 +02:00
}
2020-08-04 16:29:01 +02:00
// Gestione dell'impostazione dei Contratti
2018-10-25 13:46:16 +02:00
$id_intervento = filter ( 'id_intervento' );
2020-08-04 16:29:01 +02:00
$id_contratto = filter ( 'idcontratto' );
$id_promemoria_contratto = filter ( 'idcontratto_riga' );
2021-03-01 16:32:08 +01:00
$id_ordine = null ;
2020-08-04 16:29:01 +02:00
// Trasformazione di un Promemoria dei Contratti in Intervento
if ( ! empty ( $id_contratto ) && ! empty ( $id_promemoria_contratto )) {
$contratto = $dbo -> fetchOne ( 'SELECT *, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = co_contratti.idanagrafica) AS idzona FROM co_contratti WHERE id = ' . prepare ( $id_contratto ));
$id_anagrafica = $contratto [ 'idanagrafica' ];
$id_zona = $contratto [ 'idzona' ];
// Informazioni del Promemoria
$promemoria = $dbo -> fetchOne ( 'SELECT *, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = co_promemoria.idtipointervento) AS tempo_standard FROM co_promemoria WHERE idcontratto=' . prepare ( $id_contratto ) . ' AND id = ' . prepare ( $id_promemoria_contratto ));
$id_tipo = $promemoria [ 'idtipointervento' ];
$data = ( null !== filter ( 'data' )) ? filter ( 'data' ) : $promemoria [ 'data_richiesta' ];
$richiesta = $promemoria [ 'richiesta' ];
2023-03-31 14:15:09 +02:00
$descrizione = $promemoria [ 'descrizione' ];
2020-08-04 16:29:01 +02:00
$id_sede = $promemoria [ 'idsede' ];
$impianti_collegati = $promemoria [ 'idimpianti' ];
// Generazione dell'orario di fine sulla base del tempo standard definito dal Promemoria
if ( ! empty ( $promemoria [ 'tempo_standard' ])) {
$orario_fine = date ( 'H:i:s' , strtotime ( $orario_inizio ) + (( 60 * 60 ) * $promemoria [ 'tempo_standard' ]));
2018-06-23 18:35:08 +02:00
}
2020-08-04 16:29:01 +02:00
// Caricamento degli impianti a Contratto se non definiti in Promemoria
if ( empty ( $impianti_collegati )) {
$rs = $dbo -> fetchArray ( 'SELECT idimpianto FROM my_impianti_contratti WHERE idcontratto = ' . prepare ( $id_contratto ));
$impianti_collegati = implode ( ',' , array_column ( $rs , 'idimpianto' ));
2018-06-23 18:35:08 +02:00
}
2017-08-04 16:28:16 +02:00
}
2020-08-04 16:29:01 +02:00
// Gestione dell'aggiunta di una sessione a un Intervento senza sessioni (Promemoria intervento) da Dashboard
2018-09-20 09:21:34 +02:00
elseif ( ! empty ( $id_intervento )) {
2020-08-04 16:29:01 +02:00
$intervento = $dbo -> fetchOne ( 'SELECT *, (SELECT idcontratto FROM co_promemoria WHERE idintervento = in_interventi.id LIMIT 0,1) AS idcontratto, in_interventi.id_preventivo as idpreventivo, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = in_interventi.idtipointervento) AS tempo_standard FROM in_interventi WHERE id = ' . prepare ( $id_intervento ));
$id_tipo = $intervento [ 'idtipointervento' ];
$data = ( null !== filter ( 'data' )) ? filter ( 'data' ) : $intervento [ 'data_richiesta' ];
$data_richiesta = $intervento [ 'data_richiesta' ];
$data_scadenza = $intervento [ 'data_scadenza' ];
$richiesta = $intervento [ 'richiesta' ];
2023-03-31 14:15:09 +02:00
$descrizione = $intervento [ 'descrizione' ];
2023-02-15 16:47:13 +01:00
$id_sede = $intervento [ 'idsede_destinazione' ];
2020-08-04 16:29:01 +02:00
$id_anagrafica = $intervento [ 'idanagrafica' ];
$id_cliente_finale = $intervento [ 'idclientefinale' ];
$id_contratto = $intervento [ 'idcontratto' ];
$id_preventivo = $intervento [ 'idpreventivo' ];
$id_zona = $intervento [ 'idzona' ];
// Generazione dell'orario di fine sulla base del tempo standard definito dall'Intervento
if ( ! empty ( $intervento [ 'tempo_standard' ])) {
$orario_fine = date ( 'H:i:s' , strtotime ( $orario_inizio ) + (( 60 * 60 ) * $intervento [ 'tempo_standard' ]));
2018-09-20 09:21:34 +02:00
}
2020-08-04 16:29:01 +02:00
$rs = $dbo -> fetchArray ( 'SELECT idimpianto FROM my_impianti_interventi WHERE idintervento = ' . prepare ( $id_intervento ));
$impianti_collegati = implode ( ',' , array_column ( $rs , 'idimpianto' ));
2023-01-31 10:58:05 +01:00
$rs = $dbo -> fetchArray ( 'SELECT id_tecnico FROM in_interventi_tecnici_assegnati WHERE id_intervento = ' . prepare ( $id_intervento ));
$tecnici_assegnati = implode ( ',' , array_column ( $rs , 'id_tecnico' ));
2018-09-20 09:21:34 +02:00
}
2023-01-31 10:58:05 +01:00
// Selezione dei tecnici predefiniti per gli impianti selezionati
2020-08-04 16:29:01 +02:00
if ( ! empty ( $impianti_collegati )) {
$tecnici_impianti = $dbo -> fetchArray ( 'SELECT idtecnico FROM my_impianti WHERE id IN (' . prepare ( $impianti_collegati ) . ')' );
$id_tecnico = array_unique ( array_column ( $tecnici_impianti , 'idtecnico' ));
2020-02-14 11:46:44 +01:00
}
2020-08-04 16:29:01 +02:00
// Impostazione della data se mancante
2017-08-04 16:28:16 +02:00
if ( empty ( $data )) {
2020-08-04 16:29:01 +02:00
$data = filter ( 'data' );
if ( null == $data ) {
2020-02-14 11:46:44 +01:00
$data = date ( 'Y-m-d' );
2017-08-04 16:28:16 +02:00
}
}
2020-08-04 16:29:01 +02:00
// Impostazione della data di fine da Dashboard
if ( empty ( $data_fine )) {
$data_fine = filter ( 'data_fine' );
if ( null == $data_fine ) {
2021-05-17 17:35:48 +02:00
$data_fine = $data ;
2020-08-04 16:29:01 +02:00
}
}
2020-02-14 11:46:44 +01:00
$data_fine = $data_fine ? : $data ;
2020-08-04 16:29:01 +02:00
$inizio_sessione = $data . ' ' . $orario_inizio ;
$fine_sessione = $data_fine . ' ' . $orario_fine ;
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
echo '
< form action = " " method = " post " id = " add-form " >
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " op " value = " add " >
2020-08-04 16:29:01 +02:00
< input type = " hidden " name = " ref " value = " '.get('ref').' " >
2022-03-09 10:33:55 +01:00
< input type = " hidden " name = " backto " value = " record-edit " >
<!-- Fix creazione da Anagrafica -->
< input type = " hidden " name = " id_record " value = " " > ' ;
2019-11-19 16:06:50 +01:00
2020-08-04 16:29:01 +02:00
if ( ! empty ( $id_promemoria_contratto )) {
echo '<input type="hidden" name="idcontratto_riga" value="' . $id_promemoria_contratto . '">' ;
2018-09-20 09:21:34 +02:00
}
if ( ! empty ( $id_intervento )) {
echo '<input type="hidden" name="id_intervento" value="' . $id_intervento . '">' ;
}
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
echo '
2020-08-04 18:33:28 +02:00
< div class = " row " >
< div class = " col-md-4 " >
2020-10-16 08:31:10 +02:00
{[ " type " : " select " , " label " : " '.tr('Cliente').' " , " name " : " idanagrafica " , " required " : 1 , " value " : " '.(! $id_cliente ? $id_anagrafica : $id_cliente ).' " , " ajax-source " : " clienti " , " icon-after " : " add|'. $module_anagrafiche['id'] .'|tipoanagrafica=Cliente&readonly_tipo=1 " , " readonly " : " '.((empty( $id_anagrafica ) && empty( $id_cliente )) ? 0 : 1).' " ]}
2020-08-04 18:33:28 +02:00
</ div >
2021-07-15 17:35:46 +02:00
< div class = " col-md-4 " >
2022-01-17 16:46:26 +01:00
{[ " type " : " select " , " label " : " '.tr('Sede destinazione').' " , " name " : " idsede_destinazione " , " value " : " '. $id_sede .' " , " ajax-source " : " sedi " , " select-options " : '.json_encode([' idanagrafica ' => $id_anagrafica]).' , " icon-after " : " add|'. $module_anagrafiche['id'] .'|id_plugin='. $id_plugin_sedi .'&id_parent='. $id_anagrafica .' " ]}
2021-07-15 17:35:46 +02:00
</ div >
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Per conto di').' " , " name " : " idclientefinale " , " value " : " '. $id_cliente_finale .' " , " ajax-source " : " clienti " ]}
</ div >
2021-03-01 16:32:08 +01:00
</ div >
2020-08-04 18:33:28 +02:00
2021-03-01 16:32:08 +01:00
< div class = " row " >
2020-08-04 18:33:28 +02:00
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Impianto').' " , " multiple " : 1 , " name " : " idimpianti[] " , " value " : " '. $impianti_collegati .' " , " ajax-source " : " impianti-cliente " , " select-options " : { " idanagrafica " : '.($id_anagrafica ?: ' " " ').' , " idsede_destinazione " : '.($id_sede ?: ' " " ').' }, " icon-after " : " add|'.Modules::get('Impianti')['id'].'|id_anagrafica='. $id_anagrafica .' " ]}
2020-08-04 18:33:28 +02:00
</ div >
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Componenti').' " , " multiple " : 1 , " name " : " componenti[] " , " placeholder " : " '.tr('Seleziona prima un impianto').' " , " ajax-source " : " componenti " ]}
2020-08-04 18:33:28 +02:00
</ div >
2021-03-01 15:01:02 +01:00
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Sezionale').' " , " name " : " id_segment " , " required " : 1 , " ajax-source " : " segmenti " , " select-options " : '.json_encode([' id_module ' => $id_module, ' is_sezionale ' => 1]).' , " value " : " '. $_SESSION['module_'.$id_module] ['id_segment'].' " ]}
</ div >
2021-03-01 16:32:08 +01:00
</ div >
2021-03-01 15:01:02 +01:00
2022-02-16 17:47:19 +01:00
< div class = " row " >
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Preventivo').' " , " name " : " idpreventivo " , " value " : " '. $id_preventivo .' " , " ajax-source " : " preventivi " , " readonly " : " '.(empty( $id_preventivo ) ? 0 : 1).' " , " select-options " : '.json_encode([' idanagrafica ' => $id_anagrafica]).' ]}
2022-02-16 17:47:19 +01:00
</ div >
2022-11-28 09:27:25 +01:00
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Contratto').' " , " name " : " idcontratto " , " value " : " '. $id_contratto .' " , " ajax-source " : " contratti " , " readonly " : " '.(empty( $id_contratto ) ? 0 : 1).' " , " select-options " : '.json_encode([' idanagrafica ' => $id_anagrafica]).' , " icon-after " : " add|'.Modules::get('Contratti')['id'].'|pianificabile=1&idanagrafica='. $id_anagrafica .' " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Ordine').' " , " name " : " idordine " , " ajax-source " : " ordini-cliente " , " value " : " '. $id_ordine .' " , " select-options " : '.json_encode([' idanagrafica ' => $id_anagrafica]).' ]}
</ div >
2022-02-16 17:47:19 +01:00
</ div >
2021-03-01 16:32:08 +01:00
< div class = " row " >
2020-08-04 18:33:28 +02:00
< div class = " col-md-4 " >
{[ " type " : " timestamp " , " label " : " '.tr('Data/ora richiesta').' " , " name " : " data_richiesta " , " required " : 1 , " value " : " '.( $data_richiesta ?: '-now-').' " ]}
</ div >
< div class = " col-md-4 " >
2022-02-15 16:56:20 +01:00
{[ " type " : " select " , " label " : " '.tr('Tipo').' " , " name " : " idtipointervento " , " required " : 1 , " value " : " '. $id_tipo .' " , " ajax-source " : " tipiintervento " ]}
2020-08-04 18:33:28 +02:00
</ div >
2023-08-04 15:19:21 +02:00
< div class = " col-md-4 " >
2023-02-10 15:37:45 +01:00
{[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstatointervento " , " required " : 1 , " values " : " query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL ORDER BY descrizione " , " value " : " '.( $origine_dashboard ? setting('Stato predefinito dell \ 'attività da Dashboard') : setting('Stato predefinito dell \ 'attività')).' " ]}
2020-08-04 18:33:28 +02:00
</ div >
2021-03-01 16:32:08 +01:00
</ div >
2020-08-04 18:33:28 +02:00
2021-03-01 16:32:08 +01:00
< div class = " row " >
2023-03-31 14:15:09 +02:00
< div class = " col-md-6 " > ' ;
2023-02-24 13:36:37 +01:00
echo input ([
'type' => 'ckeditor' ,
'label' => tr ( 'Richiesta' ),
'name' => 'richiesta' ,
'id' => 'richiesta_add' ,
2023-07-19 11:09:00 +02:00
'required' => 1 ,
2023-03-13 21:17:05 +01:00
'value' => htmlentities ( $richiesta ),
2023-02-24 13:36:37 +01:00
'extra' => 'style=\'max-height:80px;\'' ,
]);
echo '
2023-03-31 14:15:09 +02:00
</ div >
< div class = " col-md-6 " > ' ;
echo input ([
'type' => 'ckeditor' ,
'label' => tr ( 'Descrizione' ),
'name' => 'descrizione' ,
'id' => 'descrizione_add' ,
'value' => htmlentities ( $descrizione ),
'extra' => 'style=\'max-height:80px;\'' ,
]);
echo '
</ div >
2023-06-29 09:49:21 +02:00
</ div >
2022-12-31 19:28:46 +01:00
2023-06-29 09:49:21 +02:00
<!-- POSIZIONE -->
< div class = " box box-info collapsable collapsed-box " >
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Posizione ').' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " onclick = " autoload_mappa=true; caricaMappa(); " >
< i class = " fa fa-plus " ></ i >
</ button >
2022-12-31 19:28:46 +01:00
</ div >
2023-06-29 09:49:21 +02:00
</ div >
2022-12-31 19:28:46 +01:00
2023-06-29 09:49:21 +02:00
< div class = " box-body " >
< div id = " map-add " style = " height: 300px;width: 100%;display: flex;align-items: center;justify-content: center; " ></ div >
</ div >
</ div > ' ;
2022-12-31 19:28:46 +01:00
2020-08-04 18:37:53 +02:00
$espandi_dettagli = setting ( 'Espandi automaticamente la sezione "Dettagli aggiuntivi"' );
echo '
2020-08-04 18:33:28 +02:00
<!-- DATI AGGIUNTIVI -->
2021-10-25 19:25:20 +02:00
< div class = " box box-info collapsable '.(empty( $espandi_dettagli ) ? 'collapsed-box' : '').' " >
2020-08-04 18:33:28 +02:00
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Dettagli aggiuntivi ').' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
2020-08-04 18:37:53 +02:00
< i class = " fa fa-'.(empty( $espandi_dettagli ) ? 'plus' : 'minus').' " ></ i >
2020-08-04 18:33:28 +02:00
</ button >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
2020-08-04 18:33:28 +02:00
< div class = " box-body " >
2017-08-04 16:28:16 +02:00
< div class = " row " >
2020-08-04 18:33:28 +02:00
< div class = " col-md-4 " >
{[ " type " : " timestamp " , " label " : " '.tr('Data/ora scadenza').' " , " name " : " data_scadenza " , " required " : 0 , " value " : " '. $data_scadenza .' " ]}
2018-10-26 01:00:44 +02:00
</ div >
2020-08-04 18:33:28 +02:00
< div class = " col-md-4 " >
2023-03-27 14:41:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Referente').' " , " name " : " idreferente " , " ajax-source " : " referenti " , " select-options " : '.json_encode([' idanagrafica ' => $id_anagrafica, ' idclientefinale ' => $id_cliente_finale]).' , " icon-after " : " add|'.Modules::get('Anagrafiche')['id'].'|id_plugin='.Plugins::get('Referenti')['id'].'&id_parent='. $id_anagrafica .' " ]}
2018-10-26 01:00:44 +02:00
</ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2020-08-04 19:04:53 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
2023-01-31 10:58:05 +01:00
//if (empty($id_intervento)) {
2020-08-04 19:04:53 +02:00
echo '
2020-08-04 18:33:28 +02:00
<!-- ASSEGNAZIONE TECNICI -->
< div class = " box box-info collapsable collapsed-box " >
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Assegnazione tecnici ').' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
2017-08-04 16:28:16 +02:00
</ div >
2020-08-04 18:33:28 +02:00
< div class = " box-body " >
< div class = " row " >
2020-11-06 19:24:11 +01:00
< div class = " col-md-12 " >
2023-01-31 10:58:05 +01:00
{[ " type " : " select " , " label " : " '.tr('Tecnici assegnati').' " , " multiple " : " 1 " , " name " : " tecnici_assegnati[] " , " ajax-source " : " tecnici " , " value " : " '. $tecnici_assegnati .' " , " icon-after " : " add|'. $module_anagrafiche['id'] .'|tipoanagrafica=Tecnico&readonly_tipo=1 " , " readonly " : '.intval($id_intervento).' ]}
2020-11-06 19:24:11 +01:00
< div class = " row " >
< div class = " col-md-12 " >
2023-01-31 10:58:05 +01:00
< div class = " btn-group " >
2023-08-04 14:54:28 +02:00
< button type = " button " class = " btn btn-xs btn-primary '.(intval( $id_intervento ) ? 'disabled' : '').' " onclick = " assegnaTuttiTecnici() " >
2020-11-06 19:24:11 +01:00
'.tr(' Tutti ').'
</ button >
2023-08-04 14:54:28 +02:00
< button type = " button " class = " btn btn-xs btn-danger '.(intval( $id_intervento ) ? 'disabled' : '').' " onclick = " deassegnaTuttiTecnici() " >
2020-11-20 16:25:26 +01:00
< i class = " fa fa-times " ></ i >
2020-11-06 19:24:11 +01:00
</ button >
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2020-08-04 18:33:28 +02:00
</ div >
2020-08-04 19:04:53 +02:00
</ div > ' ;
2023-01-31 10:58:05 +01:00
//}
2017-08-04 16:28:16 +02:00
2020-08-04 19:04:53 +02:00
echo '
2021-10-25 19:25:20 +02:00
<!-- ORE LAVORO -->
< div class = " box box-info collapsable '.( $origine_dashboard ? '' : 'collapsed-box').' " >
2018-09-19 15:12:20 +02:00
< div class = " box-header with-border " >
2021-10-25 19:25:20 +02:00
< h3 class = " box-title " > '.tr(' Ore lavoro ').' </ h3 >
2018-09-19 15:12:20 +02:00
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
2020-08-04 16:29:01 +02:00
< i class = " fa fa-'.( $origine_dashboard ? 'minus' : 'plus').' " ></ i >
2018-09-19 15:12:20 +02:00
</ button >
</ div >
</ div >
< div class = " box-body " >
< div class = " row " >
2021-07-15 17:35:46 +02:00
< div class = " col-md-4 " >
2020-08-04 16:29:01 +02:00
{[ " type " : " timestamp " , " label " : " '.tr('Inizio attività').' " , " name " : " orario_inizio " , " required " : '.($origine_dashboard ? 1 : 0).' , " value " : " '. $inizio_sessione .' " ]}
2018-09-19 15:12:20 +02:00
</ div >
2021-07-15 17:35:46 +02:00
< div class = " col-md-4 " >
2020-08-04 16:29:01 +02:00
{[ " type " : " timestamp " , " label " : " '.tr('Fine attività').' " , " name " : " orario_fine " , " required " : '.($origine_dashboard ? 1 : 0).' , " value " : " '. $fine_sessione .' " ]}
2018-09-19 15:12:20 +02:00
</ div >
2021-07-15 17:35:46 +02:00
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Zona').' " , " name " : " idzona " , " values " : " query=SELECT id, CONCAT_WS( \ ' - \ ', nome, descrizione) AS descrizione FROM an_zone ORDER BY nome " , " placeholder " : " '.tr('Nessuna zona').' " , " help " : " '.tr('La zona viene definita automaticamente in base al cliente selezionato').'. " , " readonly " : " 1 " , " value " : " '. $id_zona .' " ]}
</ div >
2018-09-19 15:12:20 +02:00
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2022-02-05 15:37:10 +01:00
{[ " type " : " select " , " label " : " '.tr('Tecnici').' " , " multiple " : " 1 " , " name " : " idtecnico[] " , " required " : '.($origine_dashboard ? 1 : 0).' , " ajax-source " : " tecnici " , " value " : " '. $id_tecnico .' " , " icon-after " : " add|'. $module_anagrafiche['id'] .'|tipoanagrafica=Tecnico&readonly_tipo=1||'.(empty( $id_tecnico ) ? '' : 'disabled').' " ]}
2018-09-19 15:12:20 +02:00
</ div >
</ div >
2020-08-17 09:47:18 +02:00
2020-08-24 17:22:52 +02:00
< div id = " info-conflitti-add " ></ div >
2020-08-17 09:47:18 +02:00
2018-09-19 15:12:20 +02:00
</ div >
</ div >
2021-09-22 11:22:03 +02:00
<!-- RICORRENZA -->
2021-10-25 19:25:20 +02:00
< div class = " box box-info collapsable collapsed-box " >
2021-09-22 11:22:03 +02:00
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Ricorrenza ').' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
</ div >
< div class = " box-body " >
< div class = " row " >
< div class = " col-md-4 " >
2021-10-25 19:25:20 +02:00
{[ " type " : " checkbox " , " label " : " '.tr('Attività ricorrente').' " , " name " : " ricorsiva " , " value " : " " ]}
2021-09-22 11:22:03 +02:00
</ div >
< div class = " col-md-4 ricorrenza " >
{[ " type " : " timestamp " , " label " : " '.tr('Data/ora inizio').' " , " name " : " data_inizio_ricorrenza " , " value " : " '.( $data_richiesta ?: '-now-').' " ]}
</ div >
< div class = " col-md-4 ricorrenza " >
{[ " type " : " number " , " label " : " '.tr('Periodicità').' " , " name " : " periodicita " , " decimals " : " 0 " , " icon-after " : " choice|period|months " , " value " : " 1 " ]}
</ div >
</ div >
< div class = " row ricorrenza " >
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Metodo fine ricorrenza').' " , " name " : " metodo_ricorrenza " , " values " : " list= \" data \" : \" Data fine \" , \" numero \" : \" Numero ricorrenze \" " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " timestamp " , " label " : " '.tr('Data/ora fine').' " , " name " : " data_fine_ricorrenza " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " '.tr('Numero ricorrenze').' " , " name " : " numero_ricorrenze " , " decimals " : " 0 " ]}
</ div >
</ div >
< div class = " row ricorrenza " >
< div class = " col-md-4 " >
2022-02-22 14:53:07 +01:00
{[ " type " : " select " , " label " : " '.tr('Stato ricorrenze').' " , " name " : " idstatoricorrenze " , " values " : " query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL AND is_completato=0 ORDER BY descrizione " ]}
2021-09-22 11:22:03 +02:00
</ div >
< div class = " col-md-4 " >
{[ " type " : " checkbox " , " label " : " '.tr('Riporta sessioni di lavoro').' " , " name " : " riporta_sessioni " , " value " : " " ]}
</ div >
</ div >
</ div >
</ div >
2021-06-28 18:44:27 +02:00
<!-- DETTAGLI CLIENTE -->
2021-10-25 19:25:20 +02:00
< div class = " box box-info collapsable collapsed-box " >
2021-06-28 18:44:27 +02:00
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Dettagli cliente ').' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
</ div >
2021-07-16 14:44:43 +02:00
< div class = " box-body " id = " dettagli_cliente " >
2021-10-25 19:25:20 +02:00
'.tr(' Seleziona prima un cliente ').' ...
2021-06-28 18:44:27 +02:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
2020-08-04 16:29:01 +02:00
< button type = " button " class = " btn btn-primary " onclick = " salva(this) " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2020-10-20 14:12:53 +02:00
</ form > ' ;
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
if ( ! empty ( $id_intervento )) {
echo '
2017-08-04 16:28:16 +02:00
< script type = " text/javascript " >
2020-08-04 16:29:01 +02:00
$ ( document ) . ready ( function () {
input ( " idsede_destinazione " ) . disable ();
input ( " idpreventivo " ) . disable ();
input ( " idcontratto " ) . disable ();
2021-05-17 17:31:03 +02:00
input ( " idordine " ) . disable ();
2022-02-16 17:47:19 +01:00
input ( " idreferente " ) . disable ();
2020-08-04 16:29:01 +02:00
input ( " componenti " ) . disable ();
input ( " idanagrafica " ) . disable ();
input ( " idclientefinale " ) . disable ();
input ( " idzona " ) . disable ();
input ( " idtipointervento " ) . disable ();
input ( " idstatointervento " ) . disable ();
input ( " data_richiesta " ) . disable ();
});
</ script > ' ;
}
2018-09-20 09:21:34 +02:00
2020-08-04 16:29:01 +02:00
// Disabilito i campi che non devono essere modificati per poter collegare l'Intervento al Promemoria del Contratto
if ( ! empty ( $id_contratto ) && ! empty ( $id_promemoria_contratto )) {
2018-09-20 09:21:34 +02:00
echo '
2020-08-04 16:29:01 +02:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
input ( " idanagrafica " ) . disable ();
input ( " idclientefinale " ) . disable ();
input ( " idzona " ) . disable ();
input ( " idtipointervento " ) . disable ();
});
</ script > ' ;
2018-09-20 09:21:34 +02:00
}
2020-08-04 16:29:01 +02:00
echo '
< script type = " text/javascript " >
var anagrafica = input ( " idanagrafica " );
var sede = input ( " idsede_destinazione " );
var contratto = input ( " idcontratto " );
var preventivo = input ( " idpreventivo " );
2021-03-01 16:32:08 +01:00
var ordine = input ( " idordine " );
2022-02-16 17:47:19 +01:00
var referente = input ( " idreferente " );
var cliente_finale = input ( " idclientefinale " );
2022-12-31 19:28:46 +01:00
var autoload_mappa = false ;
2020-08-04 16:29:01 +02:00
$ ( document ) . ready ( function () {
if ( ! anagrafica . get ()){
sede . disable ();
2021-03-01 16:32:08 +01:00
preventivo . disable ();
contratto . disable ();
ordine . disable ();
2022-02-16 17:47:19 +01:00
referente . disable ();
2020-08-04 16:29:01 +02:00
input ( " componenti " ) . disable ();
2022-01-11 16:05:39 +01:00
} else {
let value = anagrafica . get ();
updateSelectOption ( " idanagrafica " , value );
session_set ( " superselect,idanagrafica " , value , 0 );
2023-01-17 11:34:14 +01:00
// Carico nel panel i dettagli del cliente
$ . get ( " '.base_path().'/ajax_complete.php?module=Interventi&op=dettagli&id_anagrafica= " + value , function ( data ){
$ ( " #dettagli_cliente " ) . html ( data );
});
2020-08-04 16:29:01 +02:00
}
// Quando modifico orario inizio, allineo anche l\'orario fine
let orario_inizio = input ( " orario_inizio " ) . getElement ();
let orario_fine = input ( " orario_fine " ) . getElement ();
orario_inizio . on ( " dp.change " , function ( e ) {
2022-09-15 15:38:13 +02:00
if ( orario_fine . data ( " DateTimePicker " ) . date () < e . date ){
orario_fine . data ( " DateTimePicker " ) . date ( e . date );
}
});
orario_fine . on ( " dp.change " , function ( e ) {
if ( orario_inizio . data ( " DateTimePicker " ) . date () > e . date ){
orario_inizio . data ( " DateTimePicker " ) . date ( e . date );
}
2017-08-04 16:28:16 +02:00
});
2018-03-24 14:24:17 +01:00
2018-03-14 11:27:58 +01:00
// Refresh modulo dopo la chiusura di una pianificazione attività derivante dalle attività
// da pianificare, altrimenti il promemoria non si vede più nella lista a destra
2018-11-13 14:51:19 +01:00
// TODO: da gestire via ajax
2020-08-04 16:29:01 +02:00
if ( $ ( " input[name=idcontratto_riga] " ) . val ()) {
$ ( " #modals > div button.close " ) . on ( " click " , function () {
2018-03-14 11:27:58 +01:00
location . reload ();
});
}
2021-09-22 11:22:03 +02:00
// Ricorrenza
$ ( " .ricorrenza " ) . addClass ( " hidden " );
2017-08-04 16:28:16 +02:00
});
2020-08-17 09:47:18 +02:00
input ( " idtecnico " ) . change ( function () {
calcolaConflittiTecnici ();
});
2020-08-04 16:29:01 +02:00
// Gestione della modifica dell\'anagrafica
anagrafica . change ( function () {
2021-07-16 14:44:43 +02:00
let value = $ ( this ) . val ();
updateSelectOption ( " idanagrafica " , value );
session_set ( " superselect,idanagrafica " , value , 0 );
2017-08-04 16:28:16 +02:00
2021-07-16 14:44:43 +02:00
let selected = ! $ ( this ) . val ();
let placeholder = selected ? " '.tr('Seleziona prima un cliente').' " : " '.tr( " Seleziona un 'opzione").' " ;
2017-08-04 16:28:16 +02:00
2023-03-27 14:41:36 +02:00
let selected_sede = ! $ ( this ) . val () || $ ( this ) . prop ( " disabled " ) ? 1 : 0 ;
sede . setDisabled ( selected_sede )
2020-08-04 16:29:01 +02:00
. getElement () . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2021-07-16 14:44:43 +02:00
preventivo . setDisabled ( selected )
2021-03-01 16:32:08 +01:00
. getElement () . selectReset ( placeholder );
2021-07-16 14:44:43 +02:00
contratto . setDisabled ( selected )
2020-08-04 16:29:01 +02:00
. getElement () . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2021-07-16 14:44:43 +02:00
ordine . setDisabled ( selected )
2020-08-04 16:29:01 +02:00
. getElement () . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2022-02-16 17:47:19 +01:00
referente . setDisabled ( selected )
. getElement () . selectReset ( placeholder );
2018-06-23 18:35:08 +02:00
2020-08-04 16:29:01 +02:00
let data = anagrafica . getData ();
if ( data ) {
input ( " idzona " ) . set ( data . idzona ? data . idzona : " " );
// session_set("superselect,idzona", $(this).selectData().idzona, 0);
2018-02-20 16:46:23 +01:00
2020-08-04 16:29:01 +02:00
// Impostazione del tipo intervento da anagrafica
input ( " idtipointervento " ) . getElement ()
2020-08-04 18:33:28 +02:00
. selectSetNew ( data . idtipointervento , data . idtipointervento_descrizione );
2022-03-23 16:51:28 +01:00
// Impostazione del contratto predefinito da anagrafica
2022-03-24 14:52:56 +01:00
if ( data . id_contratto ) {
input ( " idcontratto " ) . getElement ()
. selectSetNew ( data . id_contratto , data . descrizione_contratto );
}
2022-12-31 19:28:46 +01:00
caricaMappa ( data . lat , data . lng );
2018-02-15 12:22:21 +01:00
}
2021-06-28 18:44:27 +02:00
if ( data !== undefined ) {
2021-07-16 14:44:43 +02:00
// Carico nel panel i dettagli del cliente
$ . get ( " '.base_path().'/ajax_complete.php?module=Interventi&op=dettagli&id_anagrafica= " + value , function ( data ){
$ ( " #dettagli_cliente " ) . html ( data );
2021-06-28 18:44:27 +02:00
});
2021-07-16 14:44:43 +02:00
} else {
$ ( " #dettagli_cliente " ) . html ( " '.tr('Seleziona prima un cliente').'... " );
2021-06-28 18:44:27 +02:00
}
2021-11-18 14:46:13 +01:00
2022-02-06 10:06:48 +01:00
plus_sede = $ ( " .modal #idsede_destinazione " ) . parent () . find ( " .btn " );
2021-11-18 14:46:13 +01:00
plus_sede . attr ( " onclick " , plus_sede . attr ( " onclick " ) . replace ( / id_parent = [ 0 - 9 ] */ , " id_parent= " + value ));
2022-02-06 10:06:48 +01:00
plus_impianto = $ ( " .modal #idimpianti " ) . parent () . find ( " .btn " );
2021-11-18 14:46:13 +01:00
plus_impianto . attr ( " onclick " , plus_impianto . attr ( " onclick " ) . replace ( / id_anagrafica = [ 0 - 9 ] */ , " id_anagrafica= " + value ));
2022-02-16 17:47:19 +01:00
plus_contratto = $ ( " .modal #idcontratto " ) . parent () . find ( " .btn " );
plus_contratto . attr ( " onclick " , plus_contratto . attr ( " onclick " ) . replace ( / idanagrafica = [ 0 - 9 ] */ , " idanagrafica= " + value ));
plus_referente = $ ( " .modal #idreferente " ) . parent () . find ( " .btn " );
plus_referente . attr ( " onclick " , plus_referente . attr ( " onclick " ) . replace ( / id_parent = [ 0 - 9 ] */ , " id_parent= " + value ));
2017-08-04 16:28:16 +02:00
});
2022-02-16 17:47:19 +01:00
//gestione del cliente finale
cliente_finale . change ( function () {
updateSelectOption ( " idclientefinale " , $ ( this ) . val ());
session_set ( " superselect,idclientefinale " , $ ( this ) . val (), 0 );
referente . getElement ()
. selectReset ( " '.tr( " Seleziona un 'opzione").' " );
});
2020-08-04 16:29:01 +02:00
// Gestione della modifica della sede selezionato
sede . change ( function () {
2020-08-17 10:57:51 +02:00
updateSelectOption ( " idsede_destinazione " , $ ( this ) . val ());
2020-08-04 16:29:01 +02:00
session_set ( " superselect,idsede_destinazione " , $ ( this ) . val (), 0 );
2023-03-27 14:41:36 +02:00
2020-08-04 16:29:01 +02:00
let data = sede . getData ();
if ( data ) {
input ( " idzona " ) . set ( data . idzona ? data . idzona : " " );
// session_set("superselect,idzona", $(this).selectData().idzona, 0);
2022-12-31 19:28:46 +01:00
caricaMappa ( data . lat , data . lng );
2018-02-15 12:22:21 +01:00
}
2017-08-04 16:28:16 +02:00
});
2021-03-01 16:32:08 +01:00
// Gestione della modifica dell\'ordine selezionato
ordine . change ( function () {
if ( ordine . get ()) {
contratto . getElement () . selectReset ();
preventivo . getElement () . selectReset ();
}
});
2020-08-04 16:29:01 +02:00
// Gestione della modifica del preventivo selezionato
preventivo . change ( function () {
2021-03-01 16:32:08 +01:00
if ( preventivo . get ()){
2020-08-04 16:29:01 +02:00
contratto . getElement () . selectReset ();
2021-03-01 16:32:08 +01:00
ordine . getElement () . selectReset ();
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
input ( " idtipointervento " ) . getElement ()
. selectSetNew ( $ ( this ) . selectData () . idtipointervento , $ ( this ) . selectData () . idtipointervento_descrizione );
2017-08-04 16:28:16 +02:00
}
});
2020-08-04 16:29:01 +02:00
// Gestione della modifica del contratto selezionato
contratto . change ( function () {
2021-03-01 16:32:08 +01:00
if ( contratto . get ()){
2020-08-04 16:29:01 +02:00
preventivo . getElement () . selectReset ();
2021-03-01 16:32:08 +01:00
ordine . getElement () . selectReset ();
2020-08-04 16:29:01 +02:00
$ ( " input[name=idcontratto_riga] " ) . val ( " " );
}
2017-08-04 16:28:16 +02:00
});
2018-06-23 18:35:08 +02:00
2020-08-04 16:29:01 +02:00
// Gestione delle modifiche agli impianti selezionati
input ( " idimpianti " ) . change ( function () {
2020-08-17 16:25:01 +02:00
updateSelectOption ( " matricola " , $ ( this ) . val ());
session_set ( " superselect,matricola " , $ ( this ) . val (), 0 );
2020-04-20 13:09:55 +02:00
2020-08-04 16:29:01 +02:00
input ( " componenti " ) . setDisabled ( ! $ ( this ) . val ())
. getElement () . selectReset ();
2023-03-27 14:41:36 +02:00
// Selezione anagrafica in automatico in base impianto
if ( $ ( this ) . val ()[ 0 ]) {
input ( " idanagrafica " ) . disable ();
input ( " idsede_destinazione " ) . disable ();
let data = $ ( this ) . selectData ()[ 0 ];
input ( " idanagrafica " ) . getElement ()
. selectSetNew ( data . idanagrafica , data . ragione_sociale );
input ( " idsede_destinazione " ) . getElement ()
. selectSetNew ( data . idsede , data . nomesede );
} else {
input ( " idanagrafica " ) . enable ();
input ( " idsede_destinazione " ) . enable ();
}
2022-02-15 16:56:20 +01:00
});
2020-07-02 15:56:32 +02:00
2022-02-15 16:56:20 +01:00
// Automatismo del tempo standard
2020-08-04 16:29:01 +02:00
input ( " idtipointervento " ) . change ( function () {
2022-02-15 16:56:20 +01:00
let data = $ ( " #idtipointervento " ) . selectData ();
if ( data && data . tempo_standard > 0 ) {
2020-08-04 16:29:01 +02:00
let orario_inizio = input ( " orario_inizio " ) . get ();
2022-02-15 16:56:20 +01:00
let tempo_standard = data . tempo_standard * 60 ;
let nuovo_orario_fine = moment ( orario_inizio , " DD/MM/YYYY HH:mm " ) . add ( tempo_standard , " m " ) . format ( " DD/MM/YYYY HH:mm " );
input ( " orario_fine " ) . set ( nuovo_orario_fine );
}
}); ' ;
2018-11-23 17:58:59 +01:00
2020-08-04 16:29:01 +02:00
if ( ! $origine_dashboard ) {
echo '
input ( " idtecnico " ) . change ( function () {
var value = $ ( this ) . val () > 0 ? true : false ;
input ( " orario_inizio " ) . setRequired ( value );
input ( " orario_fine " ) . setRequired ( value );
input ( " data " ) . setRequired ( value );
}); ' ;
}
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
echo '
var ref = " '.get('ref').' " ;
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
async function salva ( button ) {
// Submit attraverso ricaricamento della pagina
if ( ! ref ) {
$ ( " #add-form " ) . submit ();
return ;
}
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
// Submit dinamico tramite AJAX
2021-03-29 18:31:23 +02:00
let response = await salvaForm ( " #add-form " , {
2020-08-04 18:33:28 +02:00
id_module : " '. $id_module .' " , // Fix creazione da Dashboard
2021-03-29 18:31:23 +02:00
}, button );
2018-11-23 17:58:59 +01:00
2020-08-04 16:29:01 +02:00
// Se l\'aggiunta intervento proviene dalla scheda di pianificazione ordini di servizio della dashboard, la ricarico
if ( ref == " dashboard " ) {
$ ( " #modals > div " ) . modal ( " hide " );
2018-11-23 17:58:59 +01:00
2020-08-04 16:29:01 +02:00
// Aggiornamento elenco interventi da pianificare
2023-01-26 17:11:32 +01:00
globals . dashboard . calendar . refetchEvents ();
2020-08-04 16:29:01 +02:00
}
2017-08-04 16:28:16 +02:00
2020-08-04 16:29:01 +02:00
// Se l\'aggiunta intervento proviene dai contratti, faccio il submit via ajax e ricarico la tabella dei contratti
else if ( ref == " interventi_contratti " ) {
$ ( " #modals > div " ) . modal ( " hide " );
parent . window . location . reload ();
//TODO: da gestire via ajax
//$("#elenco_interventi > tbody").load(globals.rootdir + "/modules/contratti/plugins/contratti.pianificazioneinterventi.php?op=get_interventi_pianificati&idcontratto='.$id_contratto.'");
2017-08-04 16:28:16 +02:00
}
2020-08-04 16:29:01 +02:00
}
2020-08-17 09:47:18 +02:00
function calcolaConflittiTecnici () {
let tecnici = input ( " idtecnico " ) . get ();
2023-08-04 14:54:28 +02:00
return $ ( " #info-conflitti-add " ) . load ( " '. $module->fileurl ('occupazione_tecnici.php').' " , {
2020-08-17 09:47:18 +02:00
" id_module " : globals . id_module ,
" tecnici[] " : tecnici ,
" inizio " : input ( " orario_inizio " ) . get (),
" fine " : input ( " orario_fine " ) . get (),
});
}
2020-11-20 16:25:26 +01:00
function assegnaTuttiTecnici () {
deassegnaTuttiTecnici ();
$ . getJSON ( globals . rootdir + " /ajax_select.php?op=tecnici " , function ( response ) {
let input_tecnici = input ( " tecnici_assegnati " ) . getElement ();
$ . each ( response . results , function ( key , result ) {
input_tecnici . append ( `<option value="` + result [ " id " ] + `">` + result [ " descrizione " ] + `</option>` );
input_tecnici . find ( " option " ) . prop ( " selected " , true );
});
$ ( " #tecnici_assegnati " ) . trigger ( " change " );
});
}
function deassegnaTuttiTecnici () {
input ( " tecnici_assegnati " ) . getElement () . selectReset ();
}
2021-09-22 11:22:03 +02:00
$ ( " #ricorsiva " ) . on ( " change " , function (){
if ( $ ( this ) . is ( " :checked " )) {
$ ( " .ricorrenza " ) . removeClass ( " hidden " );
$ ( " #data_inizio_ricorrenza " ) . attr ( " required " , true );
$ ( " #metodo_ricorrenza " ) . attr ( " required " , true );
$ ( " #idstatoricorrenze " ) . attr ( " required " , true );
} else {
$ ( " .ricorrenza " ) . addClass ( " hidden " );
$ ( " #data_inizio_ricorrenza " ) . attr ( " required " , false );
$ ( " #metodo_ricorrenza " ) . attr ( " required " , false );
$ ( " #idstatoricorrenze " ) . attr ( " required " , false );
}
});
$ ( " #metodo_ricorrenza " ) . on ( " change " , function (){
if ( $ ( this ) . val () == " data " ) {
input ( " data_fine_ricorrenza " ) . enable ();
$ ( " #data_fine_ricorrenza " ) . attr ( " required " , true );
input ( " numero_ricorrenze " ) . disable ();
input ( " numero_ricorrenze " ) . set ( " " );
} else {
input ( " numero_ricorrenze " ) . enable ();
input ( " data_fine_ricorrenza " ) . disable ();
input ( " data_fine_ricorrenza " ) . set ( " " );
$ ( " #data_fine_ricorrenza " ) . attr ( " required " , false );
}
});
2022-12-31 19:28:46 +01:00
var map = null ;
function caricaMappa ( lat , lng ) {
if ( ! autoload_mappa ){
return false ;
}
2023-08-03 17:40:09 +02:00
//console.log(lat, lng);
if ( typeof lat === " undefined " || typeof lng === " undefined " ){
2023-08-04 14:54:28 +02:00
swal ( " '.tr('Errore').' " , " '.tr('La posizione non è stata definita. Impossibile caricare la mappa.').' " , " error " );
2023-08-03 17:40:09 +02:00
return false ;
}
2023-06-29 09:49:21 +02:00
2022-12-31 19:28:46 +01:00
if ( input ( " idanagrafica " ) . getData ( " select-options " )) {
2023-06-29 09:49:21 +02:00
var container = L . DomUtil . get ( " map-add " );
if ( container . _leaflet_id != null ){
map . eachLayer ( function ( layer ) {
if ( layer instanceof L . Marker ) {
map . removeLayer ( layer );
}
});
2022-12-31 19:28:46 +01:00
} else {
2023-06-29 09:49:21 +02:00
map = L . map ( " map-add " , {
gestureHandling : true
});
2023-08-04 14:54:28 +02:00
L . tileLayer ( " '.setting('Tile server OpenStreetMap').' " , {
2023-06-29 09:49:21 +02:00
maxZoom : 17 ,
attribution : " © OpenStreetMap "
}) . addTo ( map );
2022-12-31 19:28:46 +01:00
}
2023-06-29 09:49:21 +02:00
var icon = new L . Icon ({
iconUrl : globals . rootdir + " /assets/dist/img/marker-icon.png " ,
shadowUrl : globals . rootdir + " /assets/dist/img/leaflet/marker-shadow.png " ,
iconSize : [ 25 , 41 ],
iconAnchor : [ 12 , 41 ],
popupAnchor : [ 1 , - 34 ],
shadowSize : [ 41 , 41 ]
});
var marker = L . marker ([ lat , lng ], {
icon : icon
}) . addTo ( map );
map . setView ([ lat , lng ], 14 );
2022-12-31 19:28:46 +01:00
}
}
2020-08-04 16:29:01 +02:00
</ script > ' ;