2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
// Impostazione filtri di default a tutte le selezioni la prima volta
if ( ! isset ( $_SESSION [ 'dashboard' ][ 'idtecnici' ])) {
2018-07-17 08:05:19 +02:00
$rs = $dbo -> fetchArray ( " SELECT an_anagrafiche.idanagrafica AS id FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE deleted_at IS NULL AND descrizione='Tecnico' " );
2017-08-04 16:28:16 +02:00
$_SESSION [ 'dashboard' ][ 'idtecnici' ] = [ " '-1' " ];
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$_SESSION [ 'dashboard' ][ 'idtecnici' ][] = " ' " . $rs [ $i ][ 'id' ] . " ' " ;
}
}
if ( ! isset ( $_SESSION [ 'dashboard' ][ 'idstatiintervento' ])) {
2018-07-17 08:05:19 +02:00
$rs = $dbo -> fetchArray ( 'SELECT idstatointervento AS id, descrizione FROM in_statiintervento WHERE deleted_at IS NULL' );
2017-08-04 16:28:16 +02:00
$_SESSION [ 'dashboard' ][ 'idstatiintervento' ] = [ " '-1' " ];
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$_SESSION [ 'dashboard' ][ 'idstatiintervento' ][] = " ' " . $rs [ $i ][ 'id' ] . " ' " ;
}
}
if ( ! isset ( $_SESSION [ 'dashboard' ][ 'idtipiintervento' ])) {
$rs = $dbo -> fetchArray ( 'SELECT idtipointervento AS id, descrizione FROM in_tipiintervento' );
$_SESSION [ 'dashboard' ][ 'idtipiintervento' ] = [ " '-1' " ];
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$_SESSION [ 'dashboard' ][ 'idtipiintervento' ][] = " ' " . $rs [ $i ][ 'id' ] . " ' " ;
}
}
if ( ! isset ( $_SESSION [ 'dashboard' ][ 'idzone' ])) {
$rs = $dbo -> fetchArray ( 'SELECT id, descrizione FROM an_zone' );
$_SESSION [ 'dashboard' ][ 'idzone' ] = [ " '-1' " ];
2018-03-02 20:34:32 +01:00
2018-05-11 10:22:38 +02:00
// "Nessuna zona" di default
2018-02-20 14:50:09 +01:00
$_SESSION [ 'dashboard' ][ 'idzone' ][] = " '0' " ;
2017-08-04 16:28:16 +02:00
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$_SESSION [ 'dashboard' ][ 'idzone' ][] = " ' " . $rs [ $i ][ 'id' ] . " ' " ;
}
}
// Stati intervento
$checks = '' ;
$count = 0 ;
$total = 0 ;
2018-07-17 08:05:19 +02:00
$rs = $dbo -> fetchArray ( 'SELECT idstatointervento AS id, descrizione, colore FROM in_statiintervento WHERE deleted_at IS NULL ORDER BY descrizione ASC' );
2017-08-04 16:28:16 +02:00
$total = count ( $rs );
$allchecksstati = '' ;
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$attr = '' ;
foreach ( $_SESSION [ 'dashboard' ][ 'idstatiintervento' ] as $idx => $val ) {
if ( $val == " ' " . $rs [ $i ][ 'id' ] . " ' " ) {
$attr = 'checked="checked"' ;
++ $count ;
}
}
2018-02-18 19:53:23 +01:00
2018-06-23 15:41:32 +02:00
$checks .= " <li><input type='checkbox' id='idstato_ " . $rs [ $i ][ 'id' ] . " ' value= \" " . $rs [ $i ][ 'id' ] . '" ' . $attr . " onclick= \" $ .when ( session_set_array( 'dashboard,idstatiintervento', ' " . $rs [ $i ][ 'id' ] . " ' ) ).promise().then(function( ) { $ ('#calendar').fullCalendar('refetchEvents'); }); update_counter( 'idstati_count', $ ('#idstati_ul').find('input:checked').length ); \" > <label for='idstato_ " . $rs [ $i ][ 'id' ] . " '> <span class='badge' style= \" color: " . color_inverse ( $rs [ $i ][ 'colore' ]) . '; background:' . $rs [ $i ][ 'colore' ] . ';">' . $rs [ $i ][ 'descrizione' ] . " </span></label></li> \n " ;
2017-08-04 16:28:16 +02:00
$allchecksstati .= " session_set_array( 'dashboard,idstatiintervento', ' " . $rs [ $i ][ 'id' ] . " ', 0 ); " ;
}
if ( $count == $total ) {
$class = 'btn-success' ;
} elseif ( $count == 0 ) {
$class = 'btn-danger' ;
} else {
$class = 'btn-warning' ;
}
if ( $total == 0 ) {
$class = 'btn-primary disabled' ;
}
?>
<!-- Filtri -->
< div class = " row " >
<!-- STATI INTERVENTO -->
< div class = " dropdown col-md-3 " >
2019-12-05 19:38:00 +01:00
< a class = " btn <?php echo $class ; ?> btn-block " data - toggle = " dropdown " href = " javascript:; " id = " idstati_count " >< i class = " fa fa-filter " ></ i > < ? php echo tr ( 'Stati attività' ); ?> (<?php echo $count.'/'.$total; ?>) <i class="caret"></i></a>
2017-08-04 16:28:16 +02:00
< ul class = " dropdown-menu " role = " menu " id = " idstati_ul " >
2018-02-18 19:53:23 +01:00
< ? php echo $checks ; ?>
2017-08-04 16:28:16 +02:00
< div class = " btn-group pull-right " >
2017-09-04 12:02:29 +02:00
< button id = " selectallstati " onclick = " <?php echo $allchecksstati ; ?> " class = " btn btn-primary btn-xs " type = " button " >< ? php echo tr ( 'Tutti' ); ?> </button>
2017-08-04 16:28:16 +02:00
< button id = " deselectallstati " class = " btn btn-danger btn-xs " type = " button " >< i class = " fa fa-times " ></ i ></ button >
</ div >
</ ul >
</ div >
< ? php
// Tipi intervento
$checks = '' ;
$count = 0 ;
$total = 0 ;
$rs = $dbo -> fetchArray ( 'SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC' );
$total = count ( $rs );
$allcheckstipi = '' ;
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$attr = '' ;
foreach ( $_SESSION [ 'dashboard' ][ 'idtipiintervento' ] as $idx => $val ) {
if ( $val == " ' " . $rs [ $i ][ 'id' ] . " ' " ) {
$attr = 'checked="checked"' ;
++ $count ;
}
}
2018-02-18 19:53:23 +01:00
2018-02-16 18:27:15 +01:00
$checks .= " <li><input type='checkbox' id='idtipo_ " . $rs [ $i ][ 'id' ] . " ' value= \" " . $rs [ $i ][ 'id' ] . '" ' . $attr . " onclick= \" $ .when ( session_set_array( 'dashboard,idtipiintervento', ' " . $rs [ $i ][ 'id' ] . " ' ) ).promise().then(function( ) { $ ('#calendar').fullCalendar('refetchEvents'); }); update_counter( 'idtipi_count', $ ('#idtipi_ul').find('input:checked').length ); \" > <label for='idtipo_ " . $rs [ $i ][ 'id' ] . " '> " . $rs [ $i ][ 'descrizione' ] . " </label></li> \n " ;
2017-08-04 16:28:16 +02:00
$allcheckstipi .= " session_set_array( 'dashboard,idtipiintervento', ' " . $rs [ $i ][ 'id' ] . " ', 0 ); " ;
}
if ( $count == $total ) {
$class = 'btn-success' ;
} elseif ( $count == 0 ) {
$class = 'btn-danger' ;
} else {
$class = 'btn-warning' ;
}
if ( $total == 0 ) {
$class = 'btn-primary disabled' ;
}
?>
<!-- TIPI DI INTERVENTO -->
< div class = " dropdown col-md-3 " >
2019-12-05 19:38:00 +01:00
< a class = " btn <?php echo $class ; ?> btn-block " data - toggle = " dropdown " href = " javascript:; " id = " idtipi_count " >< i class = " fa fa-filter " ></ i > < ? php echo tr ( 'Tipi attività' ); ?> (<?php echo $count.'/'.$total; ?>) <i class="caret"></i></a>
2017-08-04 16:28:16 +02:00
< ul class = " dropdown-menu " role = " menu " id = " idtipi_ul " >
2018-02-18 19:53:23 +01:00
< ? php echo $checks ; ?>
2017-08-04 16:28:16 +02:00
< div class = " btn-group pull-right " >
2017-09-04 12:02:29 +02:00
< button id = " selectalltipi " onclick = " <?php echo $allcheckstipi ; ?> " class = " btn btn-primary btn-xs " type = " button " >< ? php echo tr ( 'Tutti' ); ?> </button>
2017-08-04 16:28:16 +02:00
< button id = " deselectalltipi " class = " btn btn-danger btn-xs " type = " button " >< i class = " fa fa-times " ></ i ></ button >
</ div >
</ ul >
</ div >
< ? php
// Tecnici
$checks = '' ;
$count = 0 ;
$total = 0 ;
$totale_tecnici = 0 ; // conteggia tecnici eliminati e non
2018-06-07 19:15:17 +02:00
$rs = $dbo -> fetchArray ( " SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale, colore FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica
2018-02-20 16:46:23 +01:00
LEFT OUTER JOIN in_interventi_tecnici ON in_interventi_tecnici . idtecnico = an_anagrafiche . idanagrafica INNER JOIN in_interventi ON in_interventi_tecnici . idintervento = in_interventi . id
2018-07-17 08:05:19 +02:00
WHERE an_anagrafiche . deleted_at IS NULL AND an_tipianagrafiche . descrizione = 'Tecnico' " .Modules::getAdditionalsQuery('Interventi').' GROUP BY an_anagrafiche.idanagrafica ORDER BY ragione_sociale ASC');
2017-08-04 16:28:16 +02:00
$total = count ( $rs );
$totale_tecnici += $total ;
$allchecktecnici = '' ;
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$attr = '' ;
foreach ( $_SESSION [ 'dashboard' ][ 'idtecnici' ] as $idx => $val ) {
if ( $val == " ' " . $rs [ $i ][ 'id' ] . " ' " ) {
$attr = 'checked="checked"' ;
++ $count ;
}
}
2018-06-23 15:41:32 +02:00
$checks .= " <li><input type='checkbox' id='tech_ " . $rs [ $i ][ 'id' ] . " ' value= \" " . $rs [ $i ][ 'id' ] . '" ' . $attr . " onclick= \" $ .when ( session_set_array( 'dashboard,idtecnici', ' " . $rs [ $i ][ 'id' ] . " ' ) ).promise().then(function( ) { $ ('#calendar').fullCalendar('refetchEvents'); }); update_counter( 'idtecnici_count', $ ('#idtecnici_ul').find('input:checked').length ); \" > <label for='tech_ " . $rs [ $i ][ 'id' ] . " '><span class='badge' style= \" color:#000; background:transparent; border: 1px solid " . $rs [ $i ][ 'colore' ] . ';">' . $rs [ $i ][ 'ragione_sociale' ] . " </span></label></li> \n " ;
2017-08-04 16:28:16 +02:00
$allchecktecnici .= " session_set_array( 'dashboard,idtecnici', ' " . $rs [ $i ][ 'id' ] . " ', 0 ); " ;
}
2018-06-06 00:00:22 +02:00
// TECNICI ELIMINATI CON ALMENO 1 INTERVENTO
2018-07-17 08:05:19 +02:00
$rs = $dbo -> fetchArray ( " SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica INNER JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE deleted_at IS NOT NULL AND descrizione='Tecnico' GROUP BY an_anagrafiche.idanagrafica ORDER BY ragione_sociale ASC " );
2017-08-04 16:28:16 +02:00
$total = count ( $rs );
$totale_tecnici += $total ;
if ( $total > 0 ) {
$checks .= " <li><hr>Tecnici eliminati:</li> \n " ;
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$attr = '' ;
foreach ( $_SESSION [ 'dashboard' ][ 'idtecnici' ] as $idx => $val ) {
if ( $val == " ' " . $rs [ $i ][ 'id' ] . " ' " ) {
$attr = 'checked="checked"' ;
++ $count ;
}
}
2018-02-18 19:53:23 +01:00
2018-02-16 18:27:15 +01:00
$checks .= " <li><input type='checkbox' id='tech_ " . $rs [ $i ][ 'id' ] . " ' value= \" " . $rs [ $i ][ 'id' ] . '" ' . $attr . " onclick= \" $ .when ( session_set_array( 'dashboard,idtecnici', ' " . $rs [ $i ][ 'id' ] . " ' ) ).promise().then(function( ) { $ ('#calendar').fullCalendar('refetchEvents'); }); update_counter( 'idtecnici_count', $ ('#idtecnici_ul').find('input:checked').length ); \" > <label for='tech_ " . $rs [ $i ][ 'id' ] . " '> " . $rs [ $i ][ 'ragione_sociale' ] . " </label></li> \n " ;
2017-08-04 16:28:16 +02:00
$allchecktecnici .= " session_set_array( 'dashboard,idtecnici', ' " . $rs [ $i ][ 'id' ] . " ', 0 ); " ;
} // end for
} // end if
if ( $count == $totale_tecnici ) {
$class = 'btn-success' ;
} elseif ( $count == 0 ) {
$class = 'btn-danger' ;
} else {
$class = 'btn-warning' ;
}
if ( $totale_tecnici == 0 ) {
$class = 'btn-primary disabled' ;
}
?>
<!-- TECNICI -->
< div class = " dropdown col-md-3 " >
2018-02-18 19:53:23 +01:00
< a class = " btn <?php echo $class ; ?> btn-block " data - toggle = " dropdown " href = " javascript:; " id = " idtecnici_count " >< i class = " fa fa-filter " ></ i > < ? php echo tr ( 'Tecnici' ); ?> (<?php echo $count.'/'.$totale_tecnici; ?>) <i class="caret"></i></a>
2017-08-04 16:28:16 +02:00
< ul class = " dropdown-menu " role = " menu " id = " idtecnici_ul " >
2018-02-18 19:53:23 +01:00
< ? php echo $checks ; ?>
2017-08-04 16:28:16 +02:00
< div class = " btn-group pull-right " >
2017-09-04 12:02:29 +02:00
< button id = " selectalltecnici " onclick = " <?php echo $allchecktecnici ; ?> " class = " btn btn-primary btn-xs " type = " button " >< ? php echo tr ( 'Tutti' ); ?> </button>
2017-08-04 16:28:16 +02:00
< button id = " deselectalltecnici " class = " btn btn-danger btn-xs " type = " button " >< i class = " fa fa-times " ></ i ></ button >
</ div >
</ ul >
</ div >
< ? php
// Zone
2018-06-23 15:41:32 +02:00
$allcheckzone = null ;
2017-08-04 16:28:16 +02:00
$checks = '' ;
$count = 0 ;
$total = 0 ;
2018-02-20 14:57:24 +01:00
$rs = $dbo -> fetchArray ( '(SELECT 0 AS ordine, \'0\' AS id, \'Nessuna zona\' AS descrizione) UNION (SELECT 1 AS ordine, id, descrizione FROM an_zone) ORDER BY ordine, descrizione ASC' );
2017-08-04 16:28:16 +02:00
$total = count ( $rs );
for ( $i = 0 ; $i < count ( $rs ); ++ $i ) {
$attr = '' ;
foreach ( $_SESSION [ 'dashboard' ][ 'idzone' ] as $idx => $val ) {
if ( $val == " ' " . $rs [ $i ][ 'id' ] . " ' " ) {
$attr = 'checked="checked"' ;
++ $count ;
}
}
2018-02-16 18:15:36 +01:00
$checks .= " <li><input type='checkbox' id='idzone_ " . $rs [ $i ][ 'id' ] . " ' value= \" " . $rs [ $i ][ 'id' ] . '" ' . $attr . " onclick= \" $ .when ( session_set_array( 'dashboard,idzone', ' " . $rs [ $i ][ 'id' ] . " ' ) ).promise().then(function( ) { $ ('#calendar').fullCalendar('refetchEvents'); update_counter( 'idzone_count', $ ('#idzone_ul').find('input:checked').length ); }); \" > <label for='idzone_ " . $rs [ $i ][ 'id' ] . " '> " . $rs [ $i ][ 'descrizione' ] . " </label></li> \n " ;
2017-08-04 16:28:16 +02:00
2018-06-23 15:41:32 +02:00
$allcheckzone = " session_set_array( 'dashboard,idzone', ' " . $rs [ $i ][ 'id' ] . " ', 0 ); " ;
2017-08-04 16:28:16 +02:00
}
if ( $count == $total ) {
$class = 'btn-success' ;
} elseif ( $count == 0 ) {
$class = 'btn-danger' ;
} else {
$class = 'btn-warning' ;
}
if ( $total == 0 ) {
$class = 'btn-primary disabled' ;
}
?>
<!-- ZONE -->
< div class = " dropdown col-md-3 " >
2018-02-18 19:53:23 +01:00
< a class = " btn <?php echo $class ; ?> btn-block " data - toggle = " dropdown " href = " javascript:; " id = " idzone_count " >< i class = " fa fa-filter " ></ i > < ? php echo tr ( 'Zone' ); ?> (<?php echo $count.'/'.$total; ?>) <i class="caret"></i></a>
2017-08-04 16:28:16 +02:00
< ul class = " dropdown-menu " role = " menu " id = " idzone_ul " >
2018-02-18 19:53:23 +01:00
< ? php echo $checks ; ?>
2017-08-04 16:28:16 +02:00
< div class = " btn-group pull-right " >
2017-09-04 12:02:29 +02:00
< button id = " selectallzone " onclick = " <?php echo $allcheckzone ; ?> " class = " btn btn-primary btn-xs " type = " button " >< ? php echo tr ( 'Tutti' ); ?> </button>
2017-08-04 16:28:16 +02:00
< button id = " deselectallzone " class = " btn btn-danger btn-xs " type = " button " >< i class = " fa fa-times " ></ i ></ button >
</ div >
</ ul >
</ div >
</ div >
< br >
< ? php
2020-03-14 14:59:27 +01:00
$query_da_programmare = ' SELECT data_richiesta AS data FROM co_promemoria
INNER JOIN co_contratti ON co_promemoria . idcontratto = co_contratti . id
INNER JOIN an_anagrafiche ON co_contratti . idanagrafica = an_anagrafiche . idanagrafica
WHERE
idcontratto IN ( SELECT id FROM co_contratti WHERE idstato IN ( SELECT id FROM co_staticontratti WHERE is_pianificabile = 1 ))
AND idintervento IS NULL
UNION SELECT IF ( data_scadenza IS NULL , data_richiesta , data_scadenza ) AS data FROM in_interventi
INNER JOIN an_anagrafiche ON in_interventi . idanagrafica = an_anagrafiche . idanagrafica
WHERE ( SELECT COUNT ( * ) FROM in_interventi_tecnici WHERE in_interventi_tecnici . idintervento = in_interventi . id ) = 0 ' ;
$risultati_da_programmare = $dbo -> fetchArray ( $query_da_programmare );
if ( ! empty ( $risultati_da_programmare )) {
2017-08-04 16:28:16 +02:00
echo '
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-10 " > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
< div id = " calendar " ></ div > ' ;
2020-03-14 14:59:27 +01:00
if ( ! empty ( $risultati_da_programmare )) {
2017-08-04 16:28:16 +02:00
echo '
</ div >
< div id = " external-events " class = " hidden-xs hidden-sm col-md-2 " >
2018-10-23 12:50:02 +02:00
< h4 > '.tr(' Promemoria da pianificare ').' </ h4 > ' ;
2018-05-11 10:22:38 +02:00
2018-06-06 00:00:22 +02:00
// Controllo pianificazioni mesi precedenti
2020-03-14 14:59:27 +01:00
$query_mesi_precenti = ' SELECT co_promemoria . id FROM co_promemoria INNER JOIN co_contratti ON co_promemoria . idcontratto = co_contratti . id WHERE idstato IN ( SELECT id FROM co_staticontratti WHERE is_pianificabile = 1 ) AND idintervento IS NULL AND DATE_ADD ( co_promemoria . data_richiesta , INTERVAL 1 DAY ) <= NOW ()
2018-09-20 09:21:34 +02:00
2019-12-09 16:44:07 +01:00
UNION SELECT in_interventi . id FROM in_interventi INNER JOIN an_anagrafiche ON in_interventi . idanagrafica = an_anagrafiche . idanagrafica WHERE ( SELECT COUNT ( * ) FROM in_interventi_tecnici WHERE in_interventi_tecnici . idintervento = in_interventi . id ) = 0 AND DATE_ADD ( IF ( in_interventi . data_scadenza IS NULL , in_interventi . data_richiesta , in_interventi . data_scadenza ), INTERVAL 1 DAY ) <= NOW () ' ;
2020-03-14 14:59:27 +01:00
$numero_mesi_precenti = $dbo -> fetchNum ( $query_mesi_precenti );
2018-05-11 10:22:38 +02:00
2020-03-14 14:59:27 +01:00
if ( $numero_mesi_precenti > 0 ) {
echo '<div class="alert alert-warning alert-dismissible text-sm" role="alert"><i class="fa fa-exclamation-triangle"></i><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> ' . tr ( 'Ci sono _NUM_ attività scadute' , [
'_NUM_' => $numero_mesi_precenti ,
]) . '.</div>' ;
2018-03-22 18:34:33 +01:00
}
2019-12-13 10:08:17 +01:00
2020-03-14 14:59:27 +01:00
// Aggiunta della data corrente per visualizzare il mese corrente
$risultati_da_programmare [] = [
'data' => date ( 'Y-m-d H:i:s' ),
];
2018-05-11 10:22:38 +02:00
2020-03-14 14:59:27 +01:00
$mesi = collect ( $risultati_da_programmare )
-> unique ( function ( $item ) {
$data = new Carbon\Carbon ( $item [ 'data' ]);
2018-05-11 10:22:38 +02:00
2020-03-14 14:59:27 +01:00
return $data -> format ( 'm-Y' );
})
-> sortBy ( 'data' );
2018-05-11 10:22:38 +02:00
2020-03-14 14:59:27 +01:00
echo '
< select class = " superselect " id = " select-intreventi-pianificare " > ' ;
2018-05-11 10:22:38 +02:00
2020-03-14 14:59:27 +01:00
foreach ( $mesi as $mese ) {
$data = new Carbon\Carbon ( $mese [ 'data' ]);
$chiave = $data -> format ( 'mY' );
$testo = $data -> formatLocalized ( '%B %Y' );
2018-03-22 18:34:33 +01:00
2020-03-14 14:59:27 +01:00
echo '
< option value = " '. $chiave .' " > '.ucfirst($testo).' </ option > ' ;
2017-08-31 10:09:06 +02:00
}
2018-05-11 10:22:38 +02:00
2017-08-04 16:28:16 +02:00
echo '
2020-03-14 14:59:27 +01:00
</ select >
< div id = " interventi-pianificare " ></ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
}
2018-07-08 18:11:17 +02:00
$vista = setting ( 'Vista dashboard' );
2017-08-04 16:28:16 +02:00
if ( $vista == 'mese' ) {
$def = 'month' ;
} elseif ( $vista == 'giorno' ) {
$def = 'agendaDay' ;
} else {
$def = 'agendaWeek' ;
}
?>
< script type = " text/javascript " >
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
function load_interventi_da_pianificare ( mese ){
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
if ( mese == undefined ){
// Seleziono il mese corrente per gli interventi da pianificare
var date = new Date ();
var mese ;
date . setDate ( date . getDate ());
//Note: January is 0, February is 1, and so on.
mese = ( '0' + ( date . getMonth () + 1 )) . slice ( - 2 ) + date . getFullYear ();
$ ( '#select-intreventi-pianificare option[value=' + mese + ']' ) . attr ( 'selected' , 'selected' ) . trigger ( 'change' );
}
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
$ ( '#interventi-pianificare' ) . html ( '<center><br><br><i class=\'fa fa-refresh fa-spin fa-2x fa-fw\'></i></center>' );
$ . get ( '<?php echo $rootdir; ?>/modules/dashboard/actions.php' , { op : 'load_intreventi' , mese : mese }, function ( data ){
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
})
. done ( function ( data ) {
$ ( '#interventi-pianificare' ) . html ( data );
$ ( '#external-events .fc-event' ) . each ( function () {
2018-03-22 18:34:33 +01:00
$ ( this ) . draggable ({
zIndex : 999 ,
revert : true ,
revertDuration : 0
});
});
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
});
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
}
$ ( '#select-intreventi-pianificare' ) . change ( function (){
var mese = $ ( this ) . val ();
load_interventi_da_pianificare ( mese );
2018-03-22 18:34:33 +01:00
});
2017-08-04 16:28:16 +02:00
$ ( document ) . ready ( function () {
2019-07-29 13:16:55 +02:00
2019-05-13 19:21:46 +02:00
load_interventi_da_pianificare ();
2018-05-11 10:22:38 +02:00
2017-08-04 16:28:16 +02:00
// Comandi seleziona tutti
$ ( '#selectallstati' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function ( i ) { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = true ;
2018-02-16 18:27:15 +01:00
$ . when ( session_set_array ( 'dashboard,idstatiintervento' , this . value , 0 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
2018-02-20 16:46:23 +01:00
2018-02-16 18:15:36 +01:00
i ++ ;
update_counter ( 'idstati_count' , i );
2017-08-04 16:28:16 +02:00
});
});
$ ( '#selectalltipi' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function ( i ) { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = true ;
2018-02-16 18:27:15 +01:00
$ . when ( session_set_array ( 'dashboard,idtipiintervento' , this . value , 0 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
i ++ ;
update_counter ( 'idtipi_count' , i );
2018-02-20 16:46:23 +01:00
});
2017-08-04 16:28:16 +02:00
});
$ ( '#selectalltecnici' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function ( i ) { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = true ;
2018-02-20 16:46:23 +01:00
$ . when ( session_set_array ( 'dashboard,idtecnici' , this . value , 0 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
i ++ ;
update_counter ( 'idtecnici_count' , i );
2017-08-04 16:28:16 +02:00
});
2018-02-20 16:46:23 +01:00
2017-08-04 16:28:16 +02:00
});
$ ( '#selectallzone' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function ( i ) { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = true ;
2019-05-24 16:31:00 +02:00
$ . when ( session_set_array ( 'dashboard,idzone' , this . value , 0 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
2018-02-20 16:46:23 +01:00
2020-03-14 14:59:27 +01:00
i ++ ;
2018-02-16 18:15:36 +01:00
update_counter ( 'idzone_count' , i );
2017-08-04 16:28:16 +02:00
2018-02-16 18:15:36 +01:00
});
2018-02-20 16:46:23 +01:00
2017-08-04 16:28:16 +02:00
});
// Comandi deseleziona tutti
$ ( '#deselectallstati' ) . click ( function ( event ) {
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function () { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = false ;
2019-05-24 16:31:00 +02:00
$ . when ( session_set_array ( 'dashboard,idstatiintervento' , this . value , 1 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
2018-02-20 16:46:23 +01:00
2018-02-16 18:15:36 +01:00
update_counter ( 'idstati_count' , 0 );
});
2018-02-20 16:46:23 +01:00
2017-08-04 16:28:16 +02:00
});
$ ( '#deselectalltipi' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function () { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = false ;
2019-05-24 16:31:00 +02:00
$ . when ( session_set_array ( 'dashboard,idtipiintervento' , this . value , 1 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
2018-02-20 16:46:23 +01:00
2018-02-16 18:15:36 +01:00
update_counter ( 'idtipi_count' , 0 );
2017-08-04 16:28:16 +02:00
2018-02-16 18:15:36 +01:00
});
2018-02-20 16:46:23 +01:00
2017-08-04 16:28:16 +02:00
});
$ ( '#deselectalltecnici' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function () { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = false ;
2019-05-24 16:31:00 +02:00
$ . when ( session_set_array ( 'dashboard,idtecnici' , this . value , 1 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
2018-02-20 16:46:23 +01:00
2018-02-16 18:15:36 +01:00
update_counter ( 'idtecnici_count' , 0 );
2017-08-04 16:28:16 +02:00
});
});
$ ( '#deselectallzone' ) . click ( function ( event ) {
2018-02-20 16:46:23 +01:00
2018-05-11 10:22:38 +02:00
$ ( this ) . parent () . parent () . find ( 'li input[type=checkbox]' ) . each ( function () { // loop through each checkbox
2018-02-16 18:15:36 +01:00
this . checked = false ;
2018-02-20 16:46:23 +01:00
$ . when ( session_set_array ( 'dashboard,idzone' , this . value , 1 )) . promise () . then ( function () {
2018-02-16 18:15:36 +01:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
update_counter ( 'idzone_count' , 0 );
2017-08-04 16:28:16 +02:00
});
});
// Creazione del calendario
create_calendar ();
2018-05-11 10:22:38 +02:00
// Data di default
2018-04-16 17:49:09 +02:00
$ ( '.fc-prev-button, .fc-next-button, .fc-today-button' ) . click ( function (){
var date_start = $ ( '#calendar' ) . fullCalendar ( 'getView' ) . start . format ( 'YYYY-MM-DD' );
date_start = moment ( date_start );
2018-05-11 10:22:38 +02:00
2018-04-16 17:49:09 +02:00
if ( '<?php echo $def; ?>' == 'month' ){
if ( date_start . date () > 1 ){
date_start = moment ( date_start ) . add ( 1 , 'M' ) . startOf ( 'month' );
}
}
2018-05-11 10:22:38 +02:00
2018-04-16 17:49:09 +02:00
date_start = date_start . format ( 'YYYY-MM-DD' );
setCookie ( 'calendar_date_start' , date_start , 365 );
});
2018-05-11 10:22:38 +02:00
2018-04-16 17:49:09 +02:00
calendar_date_start = getCookie ( 'calendar_date_start' );
2018-05-14 19:17:14 +02:00
if ( calendar_date_start != '' )
$ ( '#calendar' ) . fullCalendar ( 'gotoDate' , calendar_date_start );
2018-05-11 10:22:38 +02:00
2017-08-04 16:28:16 +02:00
});
function create_calendar (){
$ ( '#external-events .fc-event' ) . each ( function () {
// store data so the calendar knows to render an event upon drop
$ ( this ) . data ( 'event' , {
title : $ . trim ( $ ( this ) . text ()), // use the element's text as the event title
stick : false // maintain when user navigates (see docs on the renderEvent method)
});
// make the event draggable using jQuery UI
$ ( this ) . draggable ({
zIndex : 999 ,
2018-08-11 15:49:46 +02:00
revert : true , // will cause the event to go back to its
2017-08-04 16:28:16 +02:00
revertDuration : 0 // original position after the drag
});
});
var calendar = $ ( '#calendar' ) . fullCalendar ({
locale : globals . locale ,
2020-02-03 09:58:38 +01:00
height : " auto " ,
2017-08-04 16:28:16 +02:00
< ? php
2018-07-08 18:11:17 +02:00
$domenica = setting ( 'Visualizzare la domenica sul calendario' );
2017-12-31 16:00:23 +01:00
if ( empty ( $domenica )) {
2017-08-04 16:28:16 +02:00
echo '
hiddenDays : [ 0 ], ' ;
}
?>
header : {
left : 'prev,next today' ,
center : 'title' ,
right : 'month,agendaWeek,agendaDay'
},
timeFormat : 'H:mm' ,
slotLabelFormat : " H:mm " ,
slotDuration : '00:15:00' ,
defaultView : '<?php echo $def; ?>' ,
< ? php
2018-09-18 17:58:15 +02:00
echo "
2020-01-30 11:20:22 +01:00
minTime : '".setting(' Ora inizio sul calendario ')."' ,
maxTime : '".((setting(' Ora fine sul calendario ') != ' 00 : 00 : 00 ' and !empty(setting(' Ora fine sul calendario '))) ? setting(' Ora fine sul calendario ') : ' 23 : 59 : 59 ')."' ,
2018-09-18 17:58:15 +02:00
" ;
2017-08-04 16:28:16 +02:00
?>
2017-08-30 11:50:46 +02:00
lazyFetching : true ,
2019-12-12 13:03:37 +01:00
slotEventOverlap : false ,
2020-04-28 14:22:10 +02:00
selectHelper : false ,
2017-08-04 16:28:16 +02:00
eventLimit : false , // allow "more" link when too many events
allDaySlot : false ,
2017-08-30 11:50:46 +02:00
loading : function ( isLoading , view ) {
if ( isLoading ) {
2017-09-01 12:55:48 +02:00
$ ( '#tiny-loader' ) . fadeIn ();
2017-08-30 11:50:46 +02:00
} else {
2017-09-01 12:55:48 +02:00
$ ( '#tiny-loader' ) . hide ();
2017-08-30 11:50:46 +02:00
}
},
2017-09-07 18:58:41 +02:00
< ? php
2017-09-12 14:40:26 +02:00
if ( Modules :: getPermission ( 'Interventi' ) == 'rw' ) {
2017-08-31 10:09:06 +02:00
?>
2017-09-01 12:55:48 +02:00
droppable : true ,
2017-08-04 16:28:16 +02:00
drop : function ( date , jsEvent , ui , resourceId ) {
data = moment ( date ) . format ( " YYYY-MM-DD " );
ora_dal = moment ( date ) . format ( " HH:mm " );
ora_al = moment ( date ) . add ( 1 , 'hours' ) . format ( " HH:mm " );
2018-09-20 09:21:34 +02:00
ref = $ ( this ) . data ( 'ref' );
2020-04-20 13:09:55 +02:00
if ( ref == 'promemoria' ) {
2020-02-14 11:46:44 +01:00
nome = 'idcontratto_riga' ;
2018-09-20 09:21:34 +02:00
} else {
2020-02-14 11:46:44 +01:00
nome = 'id_intervento' ;
2018-09-20 09:21:34 +02:00
}
2017-08-04 16:28:16 +02:00
2020-02-14 11:46:44 +01:00
launch_modal ( '<?php echo tr(' Pianifica intervento '); ?>' , globals . rootdir + '/add.php?id_module=<?php echo Modules::get(' Interventi ')[' id ']; ?>&data=' + data + '&orario_inizio=' + ora_dal + '&orario_fine=' + ora_al + '&ref=dashboard&idcontratto=' + $ ( this ) . data ( 'idcontratto' ) + '&' + nome + '=' + $ ( this ) . data ( 'id' ));
2017-08-04 16:28:16 +02:00
$ ( this ) . remove ();
2017-08-31 10:09:06 +02:00
2020-02-05 12:40:44 +01:00
$ ( '#modals > div' ) . on ( 'hidden.bs.modal' , function () {
2017-08-31 10:09:06 +02:00
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
});
},
2017-09-01 12:55:48 +02:00
selectable : true ,
2020-02-14 11:46:44 +01:00
select : function ( start , end , allDay ) {
data = moment ( start ) . format ( " YYYY-MM-DD " );
data_fine = moment ( end ) . format ( " YYYY-MM-DD " );
2017-08-04 16:28:16 +02:00
ora_dal = moment ( start ) . format ( " HH:mm " );
ora_al = moment ( end ) . format ( " HH:mm " );
2020-05-13 13:42:14 +02:00
launch_modal ( '<?php echo tr(' Aggiungi attività '); ?>' , globals . rootdir + '/add.php?id_module=<?php echo Modules::get(' Interventi ')[' id ']; ?>&ref=dashboard&data=' + data + '&data_fine=' + data_fine + '&orario_inizio=' + ora_dal + '&orario_fine=' + ora_al , 1 );
2017-08-04 16:28:16 +02:00
$ ( '#calendar' ) . fullCalendar ( 'unselect' );
},
2017-09-01 12:55:48 +02:00
editable : true ,
eventDrop : function ( event , dayDelta , minuteDelta , revertFunc ) {
2018-07-19 12:47:28 +02:00
$ . get ( globals . rootdir + " /modules/dashboard/actions.php?op=update_intervento&id= " + event . id + " &idintervento= " + event . idintervento + " &timeStart= " + moment ( event . start ) . format ( " YYYY-MM-DD HH:mm " ) + " &timeEnd= " + moment ( event . end ) . format ( " YYYY-MM-DD HH:mm " ), function ( data , response ){
2017-08-04 16:28:16 +02:00
if ( response == " success " ){
data = $ . trim ( data );
2017-09-01 12:55:48 +02:00
if ( data != " ok " ){
2017-08-04 16:28:16 +02:00
alert ( data );
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
revertFunc ();
}
else {
return false ;
}
}
});
},
2017-09-01 12:55:48 +02:00
eventResize : function ( event , dayDelta , minuteDelta , revertFunc ) {
2018-07-19 12:47:28 +02:00
$ . get ( globals . rootdir + " /modules/dashboard/actions.php?op=update_intervento&id= " + event . id + " &idintervento= " + event . idintervento + " &timeStart= " + moment ( event . start ) . format ( " YYYY-MM-DD HH:mm " ) + " &timeEnd= " + moment ( event . end ) . format ( " YYYY-MM-DD HH:mm " ), function ( data , response ){
2017-08-04 16:28:16 +02:00
if ( response == " success " ){
data = $ . trim ( data );
2017-09-01 12:55:48 +02:00
if ( data != " ok " ){
2017-08-04 16:28:16 +02:00
alert ( data );
$ ( '#calendar' ) . fullCalendar ( 'refetchEvents' );
revertFunc ();
}
else {
return false ;
}
}
});
},
2017-09-07 18:58:41 +02:00
< ? php
2017-09-01 12:55:48 +02:00
}
2017-09-07 18:58:41 +02:00
?>
2017-08-30 11:50:46 +02:00
eventAfterRender : function ( event , element ) {
2017-08-04 16:28:16 +02:00
element . find ( '.fc-title' ) . html ( event . title );
2017-09-07 18:58:41 +02:00
< ? php
2017-09-01 12:55:48 +02:00
2018-07-08 18:11:17 +02:00
if ( setting ( 'Utilizzare i tooltip sul calendario' ) == '1' ) {
2017-09-07 18:58:41 +02:00
?>
2020-01-09 19:09:49 +01:00
element . tooltipster ({
content : '<?php echo tr(' Caricamento ... '); ?>' ,
animation : 'grow' ,
2020-01-09 19:12:04 +01:00
updateAnimation : 'grow' ,
2020-01-09 19:09:49 +01:00
contentAsHTML : true ,
hideOnClick : true ,
speed : 200 ,
delay : 300 ,
maxWidth : 400 ,
theme : 'tooltipster-shadow' ,
touchDevices : true ,
trigger : 'hover' ,
position : 'left' ,
functionBefore : function ( instance , helper ) {
var $origin = $ ( helper . origin );
2020-02-14 11:46:44 +01:00
2020-01-09 19:09:49 +01:00
// we set a variable so the data is only loaded once via Ajax, not every time the tooltip opens
if ( $origin . data ( 'loaded' ) !== true ) {
$ . get ( globals . rootdir + " /modules/dashboard/actions.php?op=get_more_info&id= " + event . idintervento , function ( data ) {
// call the 'content' method to update the content of our tooltip with the returned data.
// note: this content update will trigger an update animation (see the updateAnimation option)
instance . content ( data );
// to remember that the data has been loaded
$origin . data ( 'loaded' , true );
});
}
}
});
2017-09-07 18:58:41 +02:00
< ? php
2017-09-01 12:55:48 +02:00
}
2017-09-07 18:58:41 +02:00
?>
},
2017-09-01 12:55:48 +02:00
events : {
2018-07-19 12:47:28 +02:00
url : globals . rootdir + " /modules/dashboard/actions.php?op=get_current_month " ,
2017-09-01 12:55:48 +02:00
type : 'GET' ,
error : function () {
2017-09-04 12:02:29 +02:00
alert ( '<?php echo tr(' Errore durante la creazione degli eventi '); ?>' );
2017-09-01 12:55:48 +02:00
}
2017-08-04 16:28:16 +02:00
}
});
}
</ script >