2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-05-05 09:29:09 +02:00
// Rimuovo session usate sui select combinati (sedi, preventivi, contratti, impianti)
2017-08-04 16:28:16 +02:00
unset ( $_SESSION [ 'superselect' ][ 'idanagrafica' ]);
unset ( $_SESSION [ 'superselect' ][ 'idsede' ]);
2018-09-20 09:21:34 +02:00
// Calcolo del nuovo codice
2019-07-04 12:49:40 +02:00
$new_codice = \Modules\Interventi\Intervento :: getNextCodice ( $data );
2018-09-20 09:21:34 +02:00
2017-08-04 16:28:16 +02:00
// Se ho passato l'idanagrafica, carico il tipo di intervento di default
$idanagrafica = filter ( 'idanagrafica' );
$idsede = filter ( 'idsede' );
2018-06-23 18:35:08 +02:00
$idimpianto = null ;
$idzona = null ;
$idtipointervento = null ;
$idstatointervento = null ;
$richiesta = null ;
2017-09-18 18:11:19 +02:00
$impianti = [];
2018-08-11 15:37:38 +02:00
// Come tecnico posso aprire attività solo a mio nome
2018-08-11 11:08:55 +02:00
if ( $user [ 'gruppo' ] == 'Tecnici' && ! empty ( $user [ 'idanagrafica' ])) {
2018-06-26 14:30:26 +02:00
$idtecnico = $user [ 'idanagrafica' ];
} else {
$idtecnico = null ;
2018-06-25 18:25:04 +02:00
}
2017-09-18 18:11:19 +02:00
2017-08-04 16:28:16 +02:00
if ( ! empty ( $idanagrafica )) {
2018-02-23 10:01:48 +01:00
$rs = $dbo -> fetchArray ( 'SELECT idtipointervento_default, idzona FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $idanagrafica ));
2017-08-04 16:28:16 +02:00
$idtipointervento = $rs [ 0 ][ 'idtipointervento_default' ];
2018-03-22 15:40:20 +01:00
$idzona = $rs [ 0 ][ 'idzona' ];
2019-07-11 15:05:36 +02:00
$stato = $dbo -> fetchArray ( " SELECT * FROM in_statiintervento WHERE descrizione = 'In programmazione' " );
$idstatointervento = $stato [ 'idstatointervento' ];
2017-08-04 16:28:16 +02:00
$richiesta = filter ( 'richiesta' );
}
// Calcolo orario di inizio e fine di default
2017-09-18 18:11:19 +02:00
if ( null !== filter ( 'orario_inizio' ) && '00:00:00' != filter ( 'orario_inizio' )) {
2017-08-04 16:28:16 +02:00
$orario_inizio = filter ( 'orario_inizio' );
$orario_fine = filter ( 'orario_fine' );
} else {
2019-03-07 12:39:13 +01:00
$orario_inizio = date ( 'H' ) . ':00:00' ;
$orario_fine = date ( 'H' , time () + 60 * 60 ) . ':00:00' ;
2017-08-04 16:28:16 +02:00
}
2018-10-25 13:46:16 +02:00
$id_intervento = filter ( 'id_intervento' );
2017-08-04 16:28:16 +02:00
$idcontratto = filter ( 'idcontratto' );
2018-10-25 16:17:52 +02:00
$idcontratto_riga = filter ( 'idcontratto_riga' );
2017-08-04 16:28:16 +02:00
// Se sto pianificando un contratto, leggo tutti i dati del contratto per predisporre l'aggiunta intervento
2020-04-20 13:09:55 +02:00
if ( ! empty ( $idcontratto ) && ! empty ( $idcontratto_riga )) {
2018-06-29 17:10:48 +02:00
$rs = $dbo -> fetchArray ( 'SELECT *, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = co_contratti.idanagrafica) AS idzona FROM co_contratti WHERE id=' . prepare ( $idcontratto ));
2017-08-04 16:28:16 +02:00
$idanagrafica = $rs [ 0 ][ 'idanagrafica' ];
2018-03-22 15:40:20 +01:00
$idzona = $rs [ 0 ][ 'idzona' ];
2018-05-21 11:14:37 +02:00
2017-08-04 16:28:16 +02:00
// Info riga pianificata
2018-08-31 11:39:38 +02:00
$rs = $dbo -> fetchArray ( 'SELECT *, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = co_promemoria.idtipointervento) AS tempo_standard FROM co_promemoria WHERE idcontratto=' . prepare ( $idcontratto ) . ' AND id=' . prepare ( $idcontratto_riga ));
2017-08-04 16:28:16 +02:00
$idtipointervento = $rs [ 0 ][ 'idtipointervento' ];
2017-09-18 18:11:19 +02:00
$data = ( null !== filter ( 'data' )) ? filter ( 'data' ) : $rs [ 0 ][ 'data_richiesta' ];
2017-08-04 16:28:16 +02:00
$richiesta = $rs [ 0 ][ 'richiesta' ];
$idsede = $rs [ 0 ][ 'idsede' ];
2018-06-23 18:35:08 +02:00
$idimpianti = $rs [ 0 ][ 'idimpianti' ];
// aumento orario inizio del tempo standard definito dalla tipologia dell'intervento (PRESO DAL PROMEMORIA)
if ( ! empty ( $rs [ 0 ][ 'tempo_standard' ])) {
2018-09-20 09:21:34 +02:00
$orario_fine = date ( 'H:i:s' , strtotime ( $orario_inizio ) + (( 60 * 60 ) * $rs [ 0 ][ 'tempo_standard' ]));
2018-06-23 18:35:08 +02:00
}
// se gli impianti non sono stati definiti nel promemoria, carico tutti gli impianti a contratto
if ( empty ( $idimpianti )) {
$rs = $dbo -> fetchArray ( 'SELECT idimpianto FROM my_impianti_contratti WHERE idcontratto=' . prepare ( $idcontratto ));
$idimpianto = implode ( ',' , array_column ( $rs , 'idimpianto' ));
} else {
$idimpianto = $idimpianti ;
2018-08-11 11:08:55 +02:00
// Spunto il tecnico di default assegnato all'impianto
$rs = $dbo -> fetchArray ( 'SELECT idtecnico FROM my_impianti WHERE id=' . prepare ( $idimpianto ));
$idtecnico = $rs [ 0 ][ 'idtecnico' ] ? : '' ;
2018-06-23 18:35:08 +02:00
}
2017-08-04 16:28:16 +02:00
// Seleziono "In programmazione" come stato
2019-07-11 15:05:36 +02:00
$rs = $dbo -> fetchArray ( " SELECT * FROM in_statiintervento WHERE descrizione = 'In programmazione' " );
2017-08-04 16:28:16 +02:00
$idstatointervento = $rs [ 0 ][ 'idstatointervento' ];
}
2018-09-20 09:21:34 +02:00
// Intervento senza sessioni
elseif ( ! empty ( $id_intervento )) {
// Info riga pianificata
$rs = $dbo -> fetchArray ( '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 ));
$idtipointervento = $rs [ 0 ][ 'idtipointervento' ];
$data = ( null !== filter ( 'data' )) ? filter ( 'data' ) : $rs [ 0 ][ 'data_richiesta' ];
2018-09-20 16:42:35 +02:00
$data_richiesta = $rs [ 0 ][ 'data_richiesta' ];
2019-05-16 04:52:16 +02:00
$data_scadenza = $rs [ 0 ][ 'data_scadenza' ];
2018-09-20 09:21:34 +02:00
$richiesta = $rs [ 0 ][ 'richiesta' ];
$idsede = $rs [ 0 ][ 'idsede' ];
$idanagrafica = $rs [ 0 ][ 'idanagrafica' ];
$idclientefinale = $rs [ 0 ][ 'idclientefinale' ];
$idstatointervento = $rs [ 0 ][ 'idstatointervento' ];
$idcontratto = $rs [ 0 ][ 'idcontratto' ];
$idpreventivo = $rs [ 0 ][ 'idpreventivo' ];
$idzona = $rs [ 0 ][ 'idzona' ];
// Aumento orario inizio del tempo standard definito dalla tipologia dell'intervento (PRESO DAL PROMEMORIA)
if ( ! empty ( $rs [ 0 ][ 'tempo_standard' ])) {
$orario_fine = date ( 'H:i:s' , strtotime ( $orario_inizio ) + (( 60 * 60 ) * $rs [ 0 ][ 'tempo_standard' ]));
}
$rs = $dbo -> fetchArray ( 'SELECT idimpianto FROM my_impianti_interventi WHERE idintervento=' . prepare ( $id_intervento ));
$idimpianto = implode ( ',' , array_column ( $rs , 'idimpianto' ));
}
2020-02-14 11:46:44 +01:00
if ( empty ( $data_fine )) {
if ( null !== filter ( 'data_fine' )) {
$data_fine = filter ( 'data_fine' );
} else {
$data_fine = date ( 'Y-m-d' );
}
}
2017-08-04 16:28:16 +02:00
if ( empty ( $data )) {
2017-09-18 18:11:19 +02:00
if ( null !== filter ( 'data' )) {
2017-08-04 16:28:16 +02:00
$data = filter ( 'data' );
} else {
2020-02-14 11:46:44 +01:00
$data = date ( 'Y-m-d' );
2017-08-04 16:28:16 +02:00
}
}
2020-02-14 11:46:44 +01:00
$data_fine = $data_fine ? : $data ;
2017-08-04 16:28:16 +02:00
$_SESSION [ 'superselect' ][ 'idanagrafica' ] = $idanagrafica ;
2018-09-19 15:12:20 +02:00
$orario_inizio = $data . ' ' . $orario_inizio ;
2020-02-14 11:46:44 +01:00
$orario_fine = $data_fine . ' ' . $orario_fine ;
2018-09-19 15:12:20 +02:00
2017-08-04 16:28:16 +02:00
?>
2018-07-02 15:41:38 +02:00
< form action = " " method = " post " id = " add-form " onsubmit = " if( $ (this).parsley().validate()) { return add_intervento(); } " >
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " op " value = " add " >
2018-06-23 18:35:08 +02:00
< input type = " hidden " name = " ref " value = " <?php echo get('ref'); ?> " >
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " backto " value = " record-edit " >
2019-11-19 16:06:50 +01:00
<!-- Fix creazione da Anagrafica -->
< input type = " hidden " name = " id_record " value = " " >
2018-09-20 09:21:34 +02:00
< ? php
if ( ! empty ( $idcontratto_riga )) {
echo '<input type="hidden" name="idcontratto_riga" value="' . $idcontratto_riga . '">' ;
}
if ( ! empty ( $id_intervento )) {
echo '<input type="hidden" name="id_intervento" value="' . $id_intervento . '">' ;
}
?>
2017-08-04 16:28:16 +02:00
<!-- DATI CLIENTE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Dati cliente' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
<!-- RIGA 1 -->
< div class = " row " >
< div class = " col-md-4 " >
2020-06-26 18:44:36 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " required " : 1 , " value " : " <?php echo $idanagrafica ; ?> " , " ajax-source " : " clienti " , " icon-after " : " add|<?php echo Modules::get('Anagrafiche')['id']; ?>|tipoanagrafica=Cliente&readonly_tipo=1||<?php echo (empty( $idanagrafica )) ? '' : 'disabled'; ?> " , " data-heavy " : 0 , " readonly " : " <?php echo (empty( $idanagrafica )) ? 0 : 1; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2019-11-26 09:39:25 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Sede destinazione'); ?> " , " name " : " idsede_destinazione " , " value " : " <?php echo $idsede ; ?> " , " placheholder " : " <?php echo tr('Seleziona prima un cliente'); ?>... " , " ajax-source " : " sedi " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2018-09-20 09:21:34 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Per conto di'); ?> " , " name " : " idclientefinale " , " value " : " <?php echo $idclientefinale ; ?> " , " ajax-source " : " clienti " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
<!-- RIGA 2 -->
< div class = " row " >
2018-10-26 01:00:44 +02:00
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " <?php echo tr('Zona'); ?> " , " name " : " idzona " , " values " : " query=SELECT id, CONCAT_WS( ' - ', nome, descrizione) AS descrizione FROM an_zone ORDER BY nome " , " value " : " <?php echo $idzona ; ?> " , " placeholder " : " <?php echo tr('Nessuna zona'); ?> " , " help " : " <?php echo 'La zona viene definita automaticamente in base al cliente selezionato'; ?>. " , " extra " : " readonly " , " value " : " <?php echo $idzona ; ?> " ]}
</ div >
2017-08-04 16:28:16 +02:00
< div class = " col-md-4 " >
2020-06-26 18:44:36 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Preventivo'); ?> " , " name " : " idpreventivo " , " value " : " <?php echo $idpreventivo ; ?> " < ? php echo ! empty ( $idanagrafica ) ? '' : ', "placeholder": "' . tr ( 'Seleziona prima un cliente' ) . '..."' ; ?> , "ajax-source": "preventivi", "readonly": "<?php echo (empty($idcontratto)) ? 0 : 1; ?>" ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2020-06-26 18:44:36 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Contratto'); ?> " , " name " : " idcontratto " , " value " : " <?php echo $idcontratto ; ?> " < ? php echo ! empty ( $idanagrafica ) ? '' : ', "placeholder": "' . tr ( 'Seleziona prima un cliente' ) . '..."' ; ?> , "ajax-source": "contratti", "readonly": "<?php echo (empty($idcontratto)) ? 0 : 1; ?>" ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
2018-10-26 01:00:44 +02:00
< div class = " col-md-6 " id = 'impianti' >
2020-02-28 00:22:12 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Impianto'); ?> " , " multiple " : 1 , " name " : " idimpianti[] " , " value " : " <?php echo $idimpianto ; ?> " < ? php echo ! empty ( $idanagrafica ) ? '' : ', "placeholder": "' . tr ( 'Seleziona prima un cliente' ) . '..."' ; ?> , "ajax-source": "impianti-cliente", "icon-after": "add|<?php echo Modules::get('MyImpianti')['id']; ?>|source=Attività||<?php echo (intval($idimpianto)) ? '' : 'disabled'; ?>", "data-heavy": 0 ]}
2018-10-26 01:00:44 +02:00
</ div >
< div class = " col-md-6 " >
2018-06-23 18:35:08 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Componenti'); ?> " , " multiple " : 1 , " name " : " componenti[] " , " placeholder " : " <?php echo tr('Seleziona prima un impianto'); ?>... " , " ajax-source " : " componenti " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
<!-- DATI INTERVENTO -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Dati intervento' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
<!-- RIGA 3 -->
< div class = " row " >
2019-02-27 13:17:47 +01:00
< div class = " col-md-3 " >
2019-12-09 18:31:22 +01:00
{[ " type " : " timestamp " , " label " : " <?php echo tr('Data/ora richiesta'); ?> " , " name " : " data_richiesta " , " required " : 1 , " value " : " <?php echo $data_richiesta ?: '-now-'; ?> " ]}
2019-02-27 13:17:47 +01:00
</ div >
2019-07-26 17:40:52 +02:00
2019-02-27 13:17:47 +01:00
< div class = " col-md-3 " >
2019-12-09 18:31:22 +01:00
{[ " type " : " timestamp " , " label " : " <?php echo tr('Data/ora scadenza'); ?> " , " name " : " data_scadenza " , " required " : 0 , " value " : " <?php echo $data_scadenza ; ?> " ]}
2018-10-26 01:00:44 +02:00
</ div >
2017-08-04 16:28:16 +02:00
2019-02-27 13:17:47 +01:00
< div class = " col-md-3 " >
2018-07-31 19:20:19 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo attività'); ?> " , " name " : " idtipointervento " , " required " : 1 , " values " : " query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC " , " value " : " <?php echo $idtipointervento ; ?> " , " ajax-source " : " tipiintervento " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-02-27 13:17:47 +01:00
< div class = " col-md-3 " >
2018-07-31 19:20:19 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatointervento " , " required " : 1 , " values " : " query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL " , " value " : " <?php echo $idstatointervento ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
<!-- RIGA 5 -->
< div class = " row " >
< div class = " col-md-12 " >
2017-09-18 18:11:19 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Richiesta'); ?> " , " name " : " richiesta " , " required " : 1 , " value " : " <?php echo $richiesta ; ?> " , " extra " : " style='max-height:80px; ' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
2018-09-19 15:12:20 +02:00
<!-- DATI INTERVENTO -->
2018-09-20 09:21:34 +02:00
< div class = " box box-primary collapsable <?php echo get('ref') ? '' : 'collapsed-box'; ?> " >
2018-09-19 15:12:20 +02:00
< div class = " box-header with-border " >
< h3 class = " box-title " >< ? php echo tr ( 'Ore di lavoro' ); ?> </h3>
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-<?php echo get('ref') ? 'minus' : 'plus'; ?> " ></ i >
</ button >
</ div >
</ div >
< div class = " box-body " >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " timestamp " , " label " : " <?php echo tr('Inizio attività'); ?> " , " name " : " orario_inizio " , " required " : < ? php echo get ( 'ref' ) ? 1 : 0 ; ?> , "value": "<?php echo $orario_inizio; ?>" ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " timestamp " , " label " : " <?php echo tr('Fine attività'); ?> " , " name " : " orario_fine " , " required " : < ? php echo get ( 'ref' ) ? 1 : 0 ; ?> , "value": "<?php echo $orario_fine; ?>" ]}
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2019-03-19 19:23:07 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Tecnici'); ?> " , " multiple " : " 1 " , " name " : " idtecnico[] " , " required " : < ? php echo get ( 'ref' ) ? 1 : 0 ; ?> , "ajax-source": "tecnici", "value": "<?php echo $idtecnico; ?>", "icon-after": "add|<?php echo Modules::get('Anagrafiche')['id']; ?>|tipoanagrafica=Tecnico||<?php echo (empty($idtecnico)) ? '' : 'disabled'; ?>" ]}
2018-09-19 15:12:20 +02:00
</ div >
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-primary " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Aggiungi' ); ?> </button>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ form >
2019-07-26 17:40:52 +02:00
< script > $ ( document ) . ready ( init ) </ script >
2017-08-04 16:28:16 +02:00
< script type = " text/javascript " >
$ ( document ) . ready ( function (){
2020-02-05 12:40:44 +01:00
if ( ! $ ( " #modals > div #idanagrafica " ) . val ()){
$ ( " #modals > div #idsede_destinazione " ) . prop ( " disabled " , true );
$ ( " #modals > div #idpreventivo " ) . prop ( " disabled " , true );
$ ( " #modals > div #idcontratto " ) . prop ( " disabled " , true );
$ ( " #modals > div #idimpianti " ) . prop ( " disabled " , true );
$ ( " #modals > div #componenti " ) . prop ( " disabled " , true );
2017-08-04 16:28:16 +02:00
< ? php
if ( ! empty ( $idcontratto ) && ( ! empty ( $idordineservizio ) || ! empty ( $idcontratto_riga ))) {
// Disabilito i campi che non devono essere modificati per poter collegare l'intervento all'ordine di servizio
echo '
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idanagrafica " ) . prop ( " disabled " , true );
$ ( " #modals > div #idclientefinale " ) . prop ( " disabled " , true );
$ ( " #modals > div #idzona " ) . prop ( " disabled " , true );
$ ( " #modals > div #idtipointervento " ) . prop ( " disabled " , true );
$ ( " #modals > div #impianti " ) . find ( " button " ) . prop ( " disabled " , true ); ' ;
2017-08-04 16:28:16 +02:00
}
?>
2018-07-04 17:56:51 +02:00
}
2018-09-20 09:21:34 +02:00
< ? php
if ( ! empty ( $id_intervento )) {
echo '
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idsede_destinazione " ) . prop ( " disabled " , true );
$ ( " #modals > div #idpreventivo " ) . prop ( " disabled " , true );
$ ( " #modals > div #idcontratto " ) . prop ( " disabled " , true );
$ ( " #modals > div #idimpianti " ) . prop ( " disabled " , true );
$ ( " #modals > div #componenti " ) . prop ( " disabled " , true );
$ ( " #modals > div #idanagrafica " ) . prop ( " disabled " , true );
$ ( " #modals > div #idanagrafica " ) . find ( " button " ) . prop ( " disabled " , true );
$ ( " #modals > div #idclientefinale " ) . prop ( " disabled " , true );
$ ( " #modals > div #idzona " ) . prop ( " disabled " , true );
$ ( " #modals > div #idtipointervento " ) . prop ( " disabled " , true );
$ ( " #modals > div #idstatointervento " ) . prop ( " disabled " , true );
$ ( " #modals > div #richiesta " ) . prop ( " disabled " , true );
$ ( " #modals > div #data_richiesta " ) . prop ( " disabled " , true );
$ ( " #modals > div #impianti " ) . find ( " button " ) . prop ( " disabled " , true );
2018-09-20 09:21:34 +02:00
' ;
}
?>
// Quando modifico orario inizio, allineo anche l'orario fine
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #orario_inizio " ) . on ( " dp.change " , function ( e ) {
$ ( " #modals > div #orario_fine " ) . data ( " DateTimePicker " ) . minDate ( e . date );
$ ( " #modals > div #orario_fine " ) . change ();
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
2018-03-14 11:27:58 +01:00
if ( $ ( 'input[name=idcontratto_riga]' ) . val () != undefined ){
2020-02-05 12:40:44 +01:00
$ ( '#modals > div button.close' ) . on ( 'click' , function (){
2018-03-14 11:27:58 +01:00
location . reload ();
});
}
2017-08-04 16:28:16 +02:00
});
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idanagrafica' ) . change ( function (){
2017-08-04 16:28:16 +02:00
session_set ( 'superselect,idanagrafica' , $ ( this ) . val (), 0 );
var value = ! $ ( this ) . val () ? true : false ;
2019-07-08 18:10:52 +02:00
var placeholder = ! $ ( this ) . val () ? " <?php echo tr('Seleziona prima un cliente...'); ?> " : " <?php echo tr( " Seleziona un ' opzione " ); ?> " ;
2017-08-04 16:28:16 +02:00
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idsede_destinazione " ) . prop ( " disabled " , value );
$ ( " #modals > div #idsede_destinazione " ) . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idpreventivo " ) . prop ( " disabled " , value );
$ ( " #modals > div #idpreventivo " ) . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idcontratto " ) . prop ( " disabled " , value );
$ ( " #modals > div #idcontratto " ) . selectReset ( placeholder );
2017-08-04 16:28:16 +02:00
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idimpianti " ) . prop ( " disabled " , value );
$ ( " #modals > div #impianti " ) . find ( " button " ) . prop ( " disabled " , value );
$ ( " #modals > div #idimpianti " ) . selectReset ( placeholder );
2018-06-23 18:35:08 +02:00
2018-02-15 12:22:21 +01:00
if (( $ ( this ) . val ())) {
if (( $ ( this ) . selectData () . idzona )){
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idzona' ) . val ( $ ( this ) . selectData () . idzona ) . change ();
2018-02-20 16:46:23 +01:00
2018-02-15 12:22:21 +01:00
} else {
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idzona' ) . val ( '' ) . change ();
2018-02-15 12:22:21 +01:00
}
2018-06-23 18:35:08 +02:00
// session_set('superselect,idzona', $(this).selectData().idzona, 0);
2018-02-15 12:22:21 +01:00
}
2020-07-24 08:33:28 +02:00
// Settaggio tipo intervento da anagrafica
$ ( '#modals > div #idtipointervento' ) . selectSetNew ( $ ( this ) . selectData () . idtipointervento , $ ( this ) . selectData () . idtipointervento_descrizione );
2017-08-04 16:28:16 +02:00
});
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idsede_destinazione' ) . change ( function (){
2019-12-09 17:47:07 +01:00
session_set ( 'superselect,idsede_destinazione' , $ ( this ) . val (), 0 );
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #idimpianti " ) . selectReset ();
2018-02-20 16:46:23 +01:00
2018-02-15 12:22:21 +01:00
if (( $ ( this ) . val ())) {
if (( $ ( this ) . selectData () . idzona )){
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idzona' ) . val ( $ ( this ) . selectData () . idzona ) . change ();
2018-02-15 12:22:21 +01:00
} else {
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idzona' ) . val ( '' ) . change ();
2018-02-15 12:22:21 +01:00
}
2018-06-23 18:35:08 +02:00
// session_set('superselect,idzona', $(this).selectData().idzona, 0);
2018-02-15 12:22:21 +01:00
}
2017-08-04 16:28:16 +02:00
});
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idpreventivo' ) . change ( function (){
if ( $ ( '#modals > div #idcontratto' ) . val () && $ ( this ) . val ()){
$ ( " #modals > div #idcontratto " ) . selectReset ();
2017-08-04 16:28:16 +02:00
}
if ( $ ( this ) . val ()){
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idtipointervento' ) . selectSetNew ( $ ( this ) . selectData () . idtipointervento , $ ( this ) . selectData () . idtipointervento_descrizione );
2017-08-04 16:28:16 +02:00
}
});
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idcontratto' ) . change ( function (){
if ( $ ( '#modals > div #idpreventivo' ) . val () && $ ( this ) . val ()){
$ ( " #modals > div #idpreventivo " ) . selectReset ();
2017-08-04 16:28:16 +02:00
$ ( 'input[name=idcontratto_riga]' ) . val ( '' );
}
});
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idimpianti' ) . change ( function (){
2017-08-04 16:28:16 +02:00
session_set ( 'superselect,marticola' , $ ( this ) . val (), 0 );
2020-02-05 12:40:44 +01:00
$ ( " #modals > div #componenti " ) . prop ( " disabled " , ! $ ( this ) . val () ? true : false );
$ ( " #modals > div #componenti " ) . selectReset ();
2017-08-04 16:28:16 +02:00
});
2018-06-23 18:35:08 +02:00
2018-11-23 17:58:59 +01:00
// tempo standard
// TODO: tempo_standard da preventivo e contratto attraverso selectData() relativi
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idtipointervento' ) . change ( function (){
2018-11-13 16:02:44 +01:00
2018-11-23 17:58:59 +01:00
if ( $ ( this ) . selectData () && (( $ ( this ) . selectData () . tempo_standard ) > 0 ) && ( '<?php echo filter(' orario_fine '); ?>' == '' )){
2020-04-20 13:09:55 +02:00
2020-03-10 18:58:40 +01:00
orario_inizio = moment ( $ ( '#modals > div #orario_inizio' ) . val (), globals . timestamp_format , globals . locale ) . isValid () ? $ ( '#modals > div #orario_inizio' ) . val () : false ;
2020-07-02 15:56:32 +02:00
2020-03-10 18:58:40 +01:00
//da sistemare
if ( orario_inizio ){
tempo_standard = ( $ ( this ) . selectData () . tempo_standard ) * 60 ;
orario_fine = moment ( orario_inizio ) . add ( tempo_standard , 'm' );
$ ( '#modals > div #orario_fine' ) . val ( moment ( orario_fine ) . format ( globals . timestamp_format ));
}
2018-05-21 12:33:07 +02:00
}
2018-11-23 17:58:59 +01:00
2018-05-21 12:33:07 +02:00
});
2018-06-23 18:35:08 +02:00
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #idtecnico' ) . change ( function (){
2018-06-23 18:35:08 +02:00
< ? php if ( ! get ( 'ref' )) {
?>
2018-05-21 15:47:44 +02:00
var value = ( $ ( this ) . val () > 0 ) ? true : false ;
2020-02-05 12:40:44 +01:00
$ ( '#modals > div #orario_inizio' ) . prop ( " required " , value );
$ ( '#modals > div #orario_fine' ) . prop ( " required " , value );
$ ( '#modals > div #data' ) . prop ( " required " , value );
2018-06-23 18:35:08 +02:00
< ? php
} ?>
});
var ref = " <?php echo get('ref'); ?> " ;
2017-08-04 16:28:16 +02:00
function add_intervento (){
// Se l'aggiunta intervento proviene dal calendario, faccio il submit via ajax e ricarico gli eventi...
if ( ref ){
$ ( '#add-form' ) . find ( '[type=submit]' ) . prop ( " disabled " , true ) . addClass ( " disabled " );
$ ( '#add-form' ) . find ( 'input:disabled, select:disabled, textarea:disabled' ) . removeAttr ( 'disabled' );
2017-09-22 15:19:59 +02:00
$ . post ( globals . rootdir + '/actions.php?id_module=<?php echo Modules::get(' Interventi ')[' id ']; ?>' , $ ( '#add-form' ) . serialize (), function ( data , response ){
2017-08-04 16:28:16 +02:00
if ( response == " success " ){
// Se l'aggiunta intervento proviene dalla scheda di pianificazione ordini di servizio della dashboard, la ricarico
if ( ref == " dashboard " ){
2020-02-05 12:40:44 +01:00
$ ( " #modals > div " ) . modal ( 'hide' );
2017-08-04 16:28:16 +02:00
// Aggiornamento elenco interventi da pianificare
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
$ ( '#calendar' ) . fullCalendar ( 'render' );
}
// Se l'aggiunta intervento proviene dai contratti, faccio il submit via ajax e ricarico la tabella dei contratti
else if ( ref == " interventi_contratti " ){
2018-11-23 17:58:59 +01:00
2020-02-05 12:40:44 +01:00
$ ( " #modals > div " ) . modal ( 'hide' );
2018-07-20 15:45:53 +02:00
parent . window . location . reload ();
2018-11-13 14:51:19 +01:00
//TODO: da gestire via ajax
//$('#elenco_interventi > tbody').load(globals.rootdir + '/modules/contratti/plugins/contratti.pianificazioneinterventi.php?op=get_interventi_pianificati&idcontratto=<?php echo $idcontratto; ?>');
2018-11-23 17:58:59 +01:00
2017-08-04 16:28:16 +02:00
}
}
});
return false ;
}
}
</ script >