2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../../core.php' ;
2018-09-20 16:42:35 +02:00
// TODO: aggiornare con la funzione months()
2017-08-04 16:28:16 +02:00
$mesi = [
2017-09-04 12:02:29 +02:00
tr ( 'Gennaio' ),
tr ( 'Febbraio' ),
tr ( 'Marzo' ),
tr ( 'Aprile' ),
tr ( 'Maggio' ),
tr ( 'Giugno' ),
tr ( 'Luglio' ),
tr ( 'Agosto' ),
tr ( 'Settembre' ),
tr ( 'Ottobre' ),
tr ( 'Novembre' ),
tr ( 'Dicembre' ),
2017-08-04 16:28:16 +02:00
];
// Righe inserite
2019-03-22 11:35:26 +01:00
$qp = " SELECT *, DATE_FORMAT( data_richiesta, '%m-%Y') AS mese, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=co_promemoria.idtipointervento) AS tipointervento, (SELECT idanagrafica FROM co_contratti WHERE id=idcontratto) AS idcliente, (SELECT ragione_sociale FROM co_contratti INNER JOIN an_anagrafiche ON co_contratti.idanagrafica=an_anagrafiche.idanagrafica WHERE co_contratti.id=idcontratto) AS ragione_sociale, (SELECT CONCAT('Contratto ', numero, ' del ', DATE_FORMAT(data_bozza, '%d/%m/%Y'), ' - ', nome, ' [', (SELECT `descrizione` FROM `co_staticontratti` WHERE `co_staticontratti`.`id` = `idstato`) , ']') FROM co_contratti WHERE id = co_promemoria.idcontratto) contratto, (SELECT id FROM co_contratti WHERE id = co_promemoria.idcontratto) idcontratto FROM co_promemoria WHERE idcontratto IN ( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE is_pianificabile = 1) ) AND idintervento IS NULL ORDER BY DATE_FORMAT( data_richiesta, '%Y-%m') ASC, ragione_sociale ASC " ;
2017-08-04 16:28:16 +02:00
$rsp = $dbo -> fetchArray ( $qp );
if ( ! empty ( $rsp )) {
// Elenco interventi da pianificare
foreach ( $rsp as $i => $r ) {
2018-08-11 15:49:46 +02:00
// Se cambia il mese ricreo l'intestazione della tabella
2017-08-04 16:28:16 +02:00
if ( ! isset ( $rsp [ $i - 1 ]) || $r [ 'mese' ] != $rsp [ $i - 1 ][ 'mese' ]) {
if ( $i == 0 ) {
$attr = '' ;
$class = 'fa-minus-circle' ;
} else {
$attr = 'style="display:none;"' ;
$class = 'fa-plus-circle' ;
}
echo "
< h4 >
< a class = 'clickable' onclick = \ " if( $ ('#t1_ " . $i . " ').css('display') == 'none' ) { $ (this).children('i').removeClass('fa-plus-circle'); $ (this).children('i').addClass('fa-minus-circle'); }else { $ (this).children('i').addClass('fa-plus-circle'); $ (this).children('i').removeClass('fa-minus-circle'); } $ ('#t1_ " . $i . " ').slideToggle(); \" >
< i class = 'fa ".$class."' ></ i > " . $mesi [intval(date('m', strtotime( $r['data_richiesta'] ))) - 1].' '.date('Y', strtotime( $r['data_richiesta'] )).'
</ a >
</ h4 > ' ;
echo '
< div id = " t1_'. $i .' " '.$attr.' >
2018-07-23 16:50:07 +02:00
< table class = " table table-hover table-striped datatables " >
2017-08-04 16:28:16 +02:00
< thead >
< tr >
2018-03-05 12:25:57 +01:00
< th width = " 120 " > '.tr(' Cliente ').' </ th >
2018-07-23 16:50:07 +02:00
< th width = " 200 " > '.tr(' Contratto ').' </ th >
2017-09-04 12:02:29 +02:00
< th width = " 70 " > '.tr(' Entro il ').' </ th >
< th width = " 200 " > '.tr(' Tipo intervento ').' </ th >
2018-03-05 12:25:57 +01:00
< th > '.tr(' Descrizione ').' </ th >
2017-09-04 12:02:29 +02:00
< th width = " 100 " > '.tr(' Sede ').' </ th >
2017-08-04 16:28:16 +02:00
< th width = " 18 " ></ th >
</ tr >
</ thead >
< tbody > ' ;
}
echo '
< tr id = " int_'. $r['id'] .' " >
2018-07-23 16:50:07 +02:00
< td >< a target = " _blank " > '.Modules::link(Modules::get(' Anagrafiche ')[' id '], $r[' idcliente '], $r[' ragione_sociale ']).' </ a ></ td >
< td >< a target = " _blank " > '.Modules::link(Modules::get(' Contratti ')[' id '], $r[' idcontratto '], $r[' contratto ']).' </ a ></ td >
2017-08-04 16:28:16 +02:00
< td > '.Translator::dateToLocale($r[' data_richiesta ']).' </ td >
< td > '.$r[' tipointervento '].' </ td >
2018-07-23 16:50:07 +02:00
< td > '.nl2br($r[' richiesta ']).' </ td > ' ;
2018-08-11 15:49:46 +02:00
2017-08-04 16:28:16 +02:00
echo '
< td > ' ;
// Sede
if ( $r [ 'idsede' ] == '-1' ) {
echo '- ' . ( 'Nessuna' ) . ' -' ;
} elseif ( empty ( $r [ 'idsede' ])) {
2017-09-04 12:02:29 +02:00
echo tr ( 'Sede legale' );
2017-08-04 16:28:16 +02:00
} else {
$rsp2 = $dbo -> fetchArray ( " SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id= " . prepare ( $r [ 'idsede' ]));
echo $rsp2 [ 0 ][ 'descrizione' ];
}
echo '
</ td > ' ;
// Pulsanti
echo '
< td > ' ;
if ( empty ( $r [ 'idintervento' ])) {
echo "
2017-09-22 15:19:59 +02:00
< a class = \ " btn btn-primary \" title= \" Pianifica ora! \" onclick= \" launch_modal( ' " . tr ( 'Pianifica intervento' ) . " ', ' " . $rootdir . '/add.php?id_module=' . Modules :: get ( 'Interventi' )[ 'id' ] . '&ref=dashboard&idcontratto=' . urlencode ( $r [ 'idcontratto' ]) . '&idcontratto_riga=' . $r [ 'id' ] . " ', 1 ); \" >
2017-08-04 16:28:16 +02:00
< i class = 'fa fa-calendar' ></ i >
</ a > " ;
}
echo '
</ td >
</ tr > ' ;
if ( ! isset ( $rsp [ $i + 1 ]) || $r [ 'mese' ] != $rsp [ $i + 1 ][ 'mese' ]) {
echo '
</ tbody >
</ table >
</ div > ' ;
}
}
} else {
echo '
2017-09-04 12:02:29 +02:00
< p > '.tr(' Non ci sono interventi da pianificare ').' .</ p > ' ;
2017-08-04 16:28:16 +02:00
}
2018-07-23 16:50:07 +02:00
?>
< script >
$ ( document ) . ready ( function () {
$ ( '.datatables' ) . DataTable ({
2018-08-11 15:49:46 +02:00
" oLanguage " : { " sUrl " : " <?php echo $rootdir ; ?>/assets/dist/js/i18n/datatables/<?php echo $lang ; ?>.min.json " },
2018-07-23 16:50:07 +02:00
" paging " : false ,
" info " : false
});
} );
</ script >