2019-05-02 13:17:06 +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 />.
*/
2019-05-02 13:17:06 +02:00
2020-03-14 12:21:14 +01:00
use Modules\Interventi\Intervento ;
2019-05-02 13:17:06 +02:00
include_once __DIR__ . '/../../../core.php' ;
2020-11-06 15:52:01 +01:00
// Interventi da pianificare NON completati
2020-03-14 12:21:14 +01:00
$interventi_da_pianificare = Intervento :: doesntHave ( 'sessioni' )
-> orderByRaw ( 'IF(data_scadenza IS NULL, data_richiesta, data_scadenza)' )
2024-04-09 12:18:08 +02:00
-> whereHas ( 'stato' , fn ( $query ) => $query -> where ( 'is_completato' , '=' , 0 ))
2020-03-14 12:21:14 +01:00
-> get ();
$raggruppamenti = $interventi_da_pianificare -> groupBy ( function ( $item , $key ) {
$data = $item -> data_scadenza ? : $item -> data_richiesta ;
2024-05-23 11:36:25 +02:00
return ucfirst (( string ) $data -> isoFormat ( 'MMMM YYYY' ));
2020-03-14 12:21:14 +01:00
});
$counter = 0 ;
foreach ( $raggruppamenti as $mese => $raggruppamento ) {
++ $counter ;
// Se cambia il mese ricreo l'intestazione della tabella
if ( $counter == 1 ) {
$attr = '' ;
$class = 'fa-minus-circle' ;
} else {
$attr = 'style="display:none;"' ;
$class = 'fa-plus-circle' ;
}
echo "
< h4 >
2020-04-20 11:23:01 +02:00
< a class = 'clickable' onclick = \ " if( $ ('#interventi_pianificare_ " . $counter . " ').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'); } $ ('#interventi_pianificare_ " . $counter . " ').slideToggle(); \" >
2020-03-14 12:21:14 +01:00
< i class = 'fa ".$class."' ></ i > " . $mese .'
</ a >
</ h4 > ' ;
2019-05-02 13:17:06 +02:00
echo '
2020-04-20 11:23:01 +02:00
< div id = " interventi_pianificare_'. $counter .' " '.$attr.' >
2020-03-14 12:21:14 +01:00
< table class = " table table-hover table-striped " >
< thead >
< tr >
2024-06-06 10:24:10 +02:00
< th width = " 50 " > '.tr(' Codice ').' </ th >
< th width = " 100 " > '.tr(' Cliente ').' </ th >
2020-03-14 12:21:14 +01:00
< th width = " 70 " >< small > '.tr(' Data richiesta ').' </ small ></ th >
2024-03-13 17:01:54 +01:00
< th width = " 20% " class = " text-center " > '.tr(' Tecnici assegnati ').' </ th >
2020-03-14 12:21:14 +01:00
< th width = " 200 " > '.tr(' Tipo intervento ').' </ th >
2024-06-06 10:24:10 +02:00
< th width = " 150 " > '.tr(' Stato intervento ').' </ th >
< th width = " 20 " ></ th >
2020-03-14 12:21:14 +01:00
</ tr >
</ thead >
2019-05-02 13:17:06 +02:00
2020-03-14 12:21:14 +01:00
< tbody > ' ;
// Elenco interventi da pianificare
foreach ( $raggruppamento as $r ) {
2021-04-12 15:51:27 +02:00
$rs_tecnici = $dbo -> fetchArray ( " SELECT GROUP_CONCAT(ragione_sociale SEPARATOR ',') AS tecnici FROM an_anagrafiche INNER JOIN in_interventi_tecnici_assegnati ON in_interventi_tecnici_assegnati.id_tecnico=an_anagrafiche.idanagrafica WHERE id_intervento= " . prepare ( $r [ 'id' ]) . ' GROUP BY id_intervento' );
2021-04-02 13:47:15 +02:00
2020-03-14 12:21:14 +01:00
echo '
< tr id = " int_'. $r['id'] .' " >
2024-03-13 17:01:54 +01:00
< td >< a target = " _blank " > '.Modules::link(' Interventi ', $r[' id '], $r[' codice ']).' </ a ></ td >
2024-03-08 11:54:00 +01:00
< td >< a target = " _blank " > '.Modules::link(' Anagrafiche ', $r[' idanagrafica '], $dbo->fetchOne(' SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = '.prepare($r[' idanagrafica ']))[' ragione_sociale ']).' < br >< small > Presso : ' ;
2020-11-09 20:03:47 +01:00
// Sede promemoria
if ( $r [ 'idsede' ] == '-1' ) {
2024-01-15 15:30:45 +01:00
echo '- Nessuna -' ;
2020-11-09 20:03:47 +01:00
} elseif ( empty ( $r [ 'idsede' ])) {
echo tr ( 'Sede legale' );
} else {
$rsp2 = $dbo -> fetchArray ( " SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id= " . prepare ( $r [ 'idsede' ]));
2020-11-06 15:52:01 +01:00
2020-11-09 20:03:47 +01:00
echo $rsp2 [ 0 ][ 'descrizione' ];
}
2020-11-06 15:52:01 +01:00
echo '
</ small >
</ td >
2020-11-09 20:03:47 +01:00
< td > '.Translator::dateToLocale($r[' data_richiesta ']).' '.((empty($r[' data_scadenza '])) ? ' ' : ' < br >< small > Entro il '.Translator::dateToLocale($r[' data_scadenza ']).' </ small > ').' </ td >
2021-04-02 13:47:15 +02:00
< td >
'.$rs_tecnici[0][' tecnici '].'
</ td >
2024-06-06 10:24:10 +02:00
< td > '.$dbo->fetchOne("SELECT CONCAT_WS(' - ', `codice`,`title`) AS descrizione FROM `in_tipiintervento` LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento_lang`.`id_record` = `in_tipiintervento`.`id` AND `in_tipiintervento_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).' ) WHERE `in_tipiintervento` . `id` = '.prepare($r[' idtipointervento ']))[' descrizione '].' </ td >
2024-04-18 17:44:05 +02:00
< td > '.$dbo->fetchOne("SELECT CONCAT_WS(' - ', `codice`,`title`) AS descrizione FROM `in_statiintervento` LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento_lang`.`id_record` = `in_statiintervento`.`id` AND `in_statiintervento_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).' ) WHERE `in_statiintervento` . `id` = '.prepare($r[' idstatointervento ']))[' descrizione '].' </ td >
2024-03-13 17:01:54 +01:00
< td class = " text-right " >
< button type = " button " class = " btn btn-xs btn-default " onclick = " toggleDettagli(this) " >
< i class = " fa fa-plus " ></ i >
</ button >
</ td >
</ tr >
< tr style = " display: none " >
< td colspan = " 7 " >
' . input ([
2024-03-22 15:52:24 +01:00
'type' => 'ckeditor' ,
'name' => 'descrizione_' . $r [ 'id' ],
'value' => $r [ 'richiesta' ],
'disabled' => true ,
]) . '
2024-03-13 17:01:54 +01:00
</ td >
2020-03-14 12:21:14 +01:00
</ tr > ' ;
2019-05-02 13:17:06 +02:00
}
2020-03-14 12:21:14 +01:00
2019-05-02 13:17:06 +02:00
echo '
2020-03-14 12:21:14 +01:00
</ tbody >
</ table >
</ div > ' ;
}
if ( $raggruppamenti -> isEmpty ()) {
2019-05-02 13:17:06 +02:00
echo '
2020-03-14 12:21:14 +01:00
< p > '.tr(' Non ci sono interventi da pianificare ').' .</ p > ' ;
2019-05-02 13:17:06 +02:00
}
2024-03-13 17:01:54 +01:00
echo '
< script >
$ ( document ) . ready ( function (){ init ();});
function toggleDettagli ( trigger ) {
const tr = $ ( trigger ) . closest ( " tr " );
const dettagli = tr . next ();
if ( dettagli . css ( " display " ) === " none " ){
dettagli . show ( 500 );
$ ( trigger ) . children () . removeClass ( " fa-plus " );
$ ( trigger ) . children () . addClass ( " fa-minus " );
} else {
dettagli . hide ( 500 );
$ ( trigger ) . children () . removeClass ( " fa-minus " );
$ ( trigger ) . children () . addClass ( " fa-plus " );
}
}
</ script > ' ;