2018-02-09 10:46:13 +01:00
< ? php
include_once __DIR__ . '/../../../core.php' ;
2018-02-18 19:53:23 +01:00
//<form action="plugin_editor.php?id_plugin=$id_plugin$&id_module=$id_module$&id_parent=$id_parent$" method="post" role="form">
2018-02-09 10:46:13 +01:00
2018-05-11 17:53:25 +02:00
//nuovo promemoria
2018-05-09 18:36:32 +02:00
$data_richiesta = date ( 'd/m/Y' );
$disabled = '' ;
$hide = 'hide' ;
2018-05-11 17:53:25 +02:00
$op = 'edit-pianifica' ;
2018-05-09 18:36:32 +02:00
//mi ricavo informazioni del contratto
$data_conclusione = $dbo -> fetchArray ( 'SELECT `data_conclusione` FROM `co_contratti` WHERE `id` = ' . prepare ( $id_record ))[ 0 ][ 'data_conclusione' ];
$idanagrafica = $dbo -> fetchArray ( 'SELECT `idanagrafica` FROM `co_contratti` WHERE `id` = ' . prepare ( $id_record ))[ 0 ][ 'idanagrafica' ];
$list = '\"1\":\"' . tr ( 'Pianificare a partire da oggi ' ) . date ( 'd/m/Y' ) . '\"' ;
2018-05-11 17:53:25 +02:00
//promemoria esistente
2018-06-23 15:41:32 +02:00
if ( ! empty ( $get [ 'idcontratto_riga' ])) {
$idcontratto_riga = $get [ 'idcontratto_riga' ];
$qp = 'SELECT *, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=co_righe_contratti.idtipointervento) AS tipointervento, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = co_righe_contratti.idtipointervento) AS tempo_standard FROM co_righe_contratti WHERE id = ' . $idcontratto_riga ;
$rsp = $dbo -> fetchArray ( $qp );
$data_richiesta = readDate ( $rsp [ 0 ][ 'data_richiesta' ]);
$matricoleimpianti = trim ( $rsp [ 0 ][ 'idimpianti' ]);
$idsede = $rsp [ 0 ][ 'idsede' ];
$tempo_standard = $rsp [ 0 ][ 'tempo_standard' ];
$readonly = 'readonly' ;
$hide = '' ;
$list .= ', \"0\":\"' . tr ( 'Pianificare a partire da questo promemoria ' ) . $data_richiesta . '\"' ;
$op = 'pianificazione' ;
2018-05-09 18:36:32 +02:00
}
2018-05-10 19:06:20 +02:00
//se non è impostata idcontratto_riga allora sono in fase di inserimento di nuovo promemoria e mi calcolo il prossimo id per co_righe_contratti
( empty ( $idcontratto_riga )) ? $idcontratto_riga = $dbo -> fetchArray ( 'SELECT MAX(id) AS max_idcontratto_riga FROM `co_righe_contratti`' )[ 0 ][ 'max_idcontratto_riga' ] : '' ;
2018-05-11 16:22:21 +02:00
( empty ( $idcontratto_riga )) ? $idcontratto_riga = 1 : '' ;
2018-05-10 19:06:20 +02:00
2018-05-21 11:14:37 +02:00
//orari inizio fine interventi (8h standard)
2018-02-09 10:46:13 +01:00
$orario_inizio = '09:00' ;
2018-06-23 15:41:32 +02:00
$orario_fine = ( ! empty ( $tempo_standard )) ? date ( 'H:i' , strtotime ( $orario_inizio ) + (( 60 * 60 ) * $tempo_standard )) : '17:00' ;
2018-02-09 10:46:13 +01:00
echo '
2018-02-18 19:53:23 +01:00
< form id = " add_form " action = " '. $rootdir .'/editor.php?id_module='.Modules::get('Contratti')['id'].'&id_record='. $id_record .'&idcontratto_riga='. $idcontratto_riga .' " method = " post " >
2018-05-11 16:22:21 +02:00
2018-02-09 10:46:13 +01:00
< input type = " hidden " name = " backto " value = " record-edit " >
2018-05-11 16:22:21 +02:00
< input type = " hidden " name = " op " value = " '. $op .' " > ' ;
2018-05-09 18:36:32 +02:00
2018-06-23 15:41:32 +02:00
echo '
2018-05-09 18:36:32 +02:00
<!-- DATI PROMEMORIA ? -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " > '.tr(' Dati ').' </ h3 >
</ div >
2018-02-09 10:46:13 +01:00
2018-05-09 18:36:32 +02:00
< div class = " panel-body " >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " row " >
2018-02-20 16:46:23 +01:00
2018-05-11 16:22:21 +02:00
< div class = " col-md-6 " >
{[ " type " : " date " , " label " : " '.tr('Data promemoria').' " , " name " : " data_richiesta " , " required " : 1 , " value " : " '. $data_richiesta .' " , " extra " : " '. $readonly .' " ]}
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " col-md-6 " >
2018-05-21 15:47:44 +02:00
{[ " type " : " select " , " label " : " '.tr('Tipo intervento').' " , " name " : " idtipointervento " , " required " : 1 , " id " : " idtipointervento_ " , " values " : " query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC " , " value " : " '. $rsp[0] ['idtipointervento'].' " , " extra " : " '. $readonly .' " , " ajax-source " : " tipiintervento " ]}
2018-05-11 16:22:21 +02:00
</ div >
2018-02-09 10:46:13 +01:00
2018-05-11 16:22:21 +02:00
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " row " >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " col-md-6 " >
2018-05-11 17:53:25 +02:00
{[ " type " : " select " , " multiple " : " 1 " , " label " : " '.tr('Impianti').' " , " name " : " idimpianti[] " , " values " : " query=SELECT my_impianti.id AS id, my_impianti.nome AS descrizione FROM my_impianti_contratti INNER JOIN my_impianti ON my_impianti_contratti.idimpianto = my_impianti.id WHERE my_impianti_contratti.idcontratto = '. $id_record .' ORDER BY descrizione " , " value " : " '. $matricoleimpianti .' " , " extra " : " '. $readonly .' " ]}
2018-05-11 16:22:21 +02:00
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " '.tr('Sede').' " , " name " : " idsede_c " , " values " : " query=SELECT 0 AS id, \ 'Sede legale \ ' AS descrizione UNION SELECT id, CONCAT( CONCAT_WS( \ ' ( \ ', CONCAT_WS( \ ', \ ', `nomesede`, `citta`), `indirizzo` ), \ ') \ ') AS descrizione FROM an_sedi WHERE idanagrafica='. $idanagrafica .' " , " value " : " '. $idsede .' " , " extra " : " '. $readonly .' " ]}
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
< div class = " row " >
2018-02-20 16:46:23 +01:00
2018-05-11 16:22:21 +02:00
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " '.tr('Descrizione').' " , " name " : " richiesta " , " id " : " richiesta_ " , " extra " : " '. $readonly .' " , " value " : " '. $rsp[0] ['richiesta'].' " ]}
</ div >
2018-02-20 16:46:23 +01:00
2018-05-11 16:22:21 +02:00
</ div > ' ;
2018-05-23 18:05:49 +02:00
2018-05-09 18:36:32 +02:00
?>
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
<!-- ARTICOLI -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " >< ? php echo tr ( 'Materiale da utilizzare' ); ?> </h3>
</ div >
< div class = " panel-body " >
< div id = " articoli " >
< ? php include $docroot . '/modules/contratti/plugins/ajax_articoli.php' ; ?>
</ div >
< ? php if ( empty ( $readonly )) {
2018-06-23 15:41:32 +02:00
?>
2018-05-11 16:22:21 +02:00
< button type = " button " class = " btn btn-primary " data - title = " <?php echo tr('Aggiungi articolo'); ?> " data - target = " #bs-popup2 " data - toggle = " modal " data - href = " <?php echo $rootdir ; ?>/modules/contratti/plugins/add_articolo.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>&idcontratto_riga=<?php echo $idcontratto_riga ; ?> " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Aggiungi articolo' ); ?> ...</button>
< ? php
2018-06-23 15:41:32 +02:00
} ?>
2018-05-11 16:22:21 +02:00
</ div >
</ div >
2018-06-23 15:41:32 +02:00
2018-05-11 16:22:21 +02:00
<!-- SPESE AGGIUNTIVE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " >< ? php echo tr ( 'Altre spese previste' ); ?> </h3>
</ div >
< div class = " panel-body " >
< div id = " righe " >
2018-06-23 15:41:32 +02:00
< ? php include $docroot . '/modules/contratti/plugins/ajax_righe.php' ; ?>
2018-05-11 16:22:21 +02:00
</ div >
< ? php if ( empty ( $readonly )) {
2018-06-23 15:41:32 +02:00
?>
2018-05-11 16:22:21 +02:00
< button type = " button " class = " btn btn-primary " data - title = " <?php echo tr('Aggiungi altre spese'); ?> " data - target = " #bs-popup2 " data - toggle = " modal " data - href = " <?php echo $rootdir ; ?>/modules/contratti/plugins/add_righe.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>&idcontratto_riga=<?php echo $idcontratto_riga ; ?> " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Aggiungi altre spese' ); ?> ...</button>
< ? php
2018-06-23 15:41:32 +02:00
} ?>
2018-05-11 16:22:21 +02:00
</ div >
</ div >
2018-06-23 15:41:32 +02:00
< ? php
2018-05-15 19:07:28 +02:00
echo '
2018-06-23 15:41:32 +02:00
{( " name " : " filelist_and_upload " , " id_record " : " '. $idcontratto_riga .' " , " id_plugin " : " '. $id_plugin .' " , " ajax " : " true " , '.((!empty($readonly)) ? ' " readonly " : " true " ' : ' " readonly " : " false " ').' )}
2018-05-15 19:07:28 +02:00
</ div >
2018-05-09 18:36:32 +02:00
</ div >
2018-05-15 19:07:28 +02:00
<!-- div class = " col-md-8 " >
{[ " type " : " checkbox " , " label " : " '.tr('Pianifica anche date passate').' " , " name " : " date_passate " , " value " : " 0 " , " help " : " " , " placeholder " : " '.tr('Pianificare promemoria anche con date precedenti ad oggi: ').date('d/m/Y').' " ]}
</ div -->
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
' ;
2018-05-09 18:36:32 +02:00
echo '
<!-- PIANIFICAZIONE CICLICA ? -->
< div class = " panel panel-primary '. $hide .' " >
< div class = " panel-heading " >
< h3 class = " panel-title " > '.tr(' Promemoria ciclico ? ').' </ h3 >
</ div >
< div class = " panel-body " > ' ;
2018-06-23 15:41:32 +02:00
2018-05-09 18:36:32 +02:00
echo ' < div class = " row " >
< div class = " col-md-2 " >
{[ " type " : " number " , " label " : " '.tr('Intervallo').' " , " name " : " intervallo " , " class " : " " , " decimals " : 0 , " required " : 1 , " icon-after " : " GG " , " min-value " : " 1 " ]}
</ div > ' ;
2018-06-23 15:41:32 +02:00
2018-02-09 10:46:13 +01:00
?>
2018-02-20 16:46:23 +01:00
< div class = " col-md-7 " >
2018-06-23 15:41:32 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Inizio pianificazione'); ?> " , " name " : " parti_da_oggi " , " values " : " list=<?php echo $list ; ?> " , " value " : " " ]}
2018-02-09 10:46:13 +01:00
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
< ? php
2018-02-18 19:53:23 +01:00
2018-02-09 10:46:13 +01:00
echo '
2018-02-20 16:46:23 +01:00
2018-05-09 18:36:32 +02:00
< div class = " col-md-3 " >
{[ " type " : " date " , " label " : " '.tr('Fine pianificazione').' " , " help " : " '.tr('Data conclusione contratto').' " , " name " : " data_conclusione " , " id " : " data_conclusione_ " , " extra " : " readonly " , " value " : " '. $data_conclusione .' " ]}
2018-02-09 10:46:13 +01:00
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
</ div >
2018-05-09 18:36:32 +02:00
2018-06-23 15:41:32 +02:00
</ div >
</ div > ' ;
2018-05-09 18:36:32 +02:00
echo '
<!-- PIANIFICARE INTERVENTI ? -->
< div class = " panel panel-primary '. $hide .' " >
< div class = " panel-heading " >
< h3 class = " panel-title " > '.tr(' Pianificare interventi ? ').' </ h3 >
</ div >
< div class = " panel-body " >
2018-06-23 15:41:32 +02:00
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-4 " >
2018-02-15 11:02:43 +01:00
{[ " type " : " checkbox " , " label " : " '.tr('Pianifica anche l \ 'intervento').' " , " name " : " pianifica_intervento " , " value " : " 0 " , " help " : " " , " placeholder " : " '.tr('Pianificare già l \ 'intervento ').' " ]}
2018-02-09 10:46:13 +01:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-4 " >
2018-02-09 10:46:13 +01:00
{[ " type " : " select " , " label " : " '.tr('Tecnici').' " , " multiple " : " 1 " , " name " : " idtecnico[] " , " required " : 0 , " ajax-source " : " tecnici " , " value " : " " , " extra " : " disabled " ]}
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
< div class = " col-xs-6 col-md-2 " >
{[ " type " : " time " , " label " : " '.tr('Orario inizio').' " , " name " : " orario_inizio " , " required " : 0 , " value " : " '. $orario_inizio .' " , " extra " : " disabled " ]}
</ div >
< div class = " col-xs-6 col-md-2 " >
{[ " type " : " time " , " label " : " '.tr('Orario fine').' " , " name " : " orario_fine " , " required " : 0 , " value " : " '. $orario_fine .' " , " extra " : " disabled " ]}
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
</ div >
2018-06-23 15:41:32 +02:00
2018-05-09 18:36:32 +02:00
</ div >
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary " >< i class = " fa fa-plus " ></ i > '.tr(' Pianifica ').' </ button >
</ div >
</ div >
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
</ form > ' ;
echo '
< script src = " '. $rootdir .'/lib/init.js " ></ script > ' ;
echo '
< script >
2018-05-05 09:29:09 +02:00
$ ( document ) . ready ( function () {
2018-02-20 16:46:23 +01:00
2018-05-05 09:29:09 +02:00
$ ( " #pianifica_intervento " ) . click ( function () {
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
if ( $ ( this ) . is ( " :checked " )){
$ ( " #idtecnico " ) . removeAttr ( " disabled " );
2018-03-30 02:17:28 +02:00
$ ( " #idtecnico " ) . prop ( " required " , true );
2018-02-09 10:46:13 +01:00
$ ( " #orario_inizio " ) . removeAttr ( " disabled " );
$ ( " #orario_fine " ) . removeAttr ( " disabled " );
2018-03-30 02:17:28 +02:00
$ ( " #orario_inizio " ) . prop ( " required " , true );
$ ( " #orario_fine " ) . prop ( " required " , true );
2018-02-09 10:46:13 +01:00
} else {
$ ( " #idtecnico " ) . prop ( " disabled " , true );
2018-03-30 02:17:28 +02:00
$ ( " #idtecnico " ) . removeAttr ( " required " );
2018-02-09 10:46:13 +01:00
$ ( " #orario_inizio " ) . prop ( " disabled " , true );
$ ( " #orario_fine " ) . prop ( " disabled " , true );
2018-03-30 02:17:28 +02:00
$ ( " #orario_inizio " ) . removeAttr ( " required " );
$ ( " #orario_fine " ) . removeAttr ( " required " );
2018-02-09 10:46:13 +01:00
}
2018-02-20 16:46:23 +01:00
2018-02-09 10:46:13 +01:00
});
});
2018-02-18 19:53:23 +01:00
</ script > ' ;