From 0029d93817c19e2f397f6baed3b10c141837deb8 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 16 Feb 2018 18:15:36 +0100 Subject: [PATCH] Fix filtri dashboard --- modules/dashboard/edit.php | 139 ++++++--- modules/dashboard/edit__.php | 571 +++++++++++++++++++++++++++++++++++ 2 files changed, 661 insertions(+), 49 deletions(-) create mode 100644 modules/dashboard/edit__.php diff --git a/modules/dashboard/edit.php b/modules/dashboard/edit.php index 65e36d6d2..5b1dda892 100644 --- a/modules/dashboard/edit.php +++ b/modules/dashboard/edit.php @@ -61,8 +61,8 @@ for ($i = 0; $i < count($rs); ++$i) { ++$count; } } - - $checks .= "
  • \n"; + + $checks .= "
  • \n"; $allchecksstati .= "session_set_array( 'dashboard,idstatiintervento', '".$rs[$i]['id']."', 0 ); "; } @@ -115,8 +115,9 @@ for ($i = 0; $i < count($rs); ++$i) { ++$count; } } - - $checks .= "
  • \n"; + + + $checks .= "
  • \n"; $allcheckstipi .= "session_set_array( 'dashboard,idtipiintervento', '".$rs[$i]['id']."', 0 ); "; } @@ -173,7 +174,9 @@ for ($i = 0; $i < count($rs); ++$i) { } } - $checks .= "
  • \n"; + + + $checks .= "
  • \n"; $allchecktecnici .= "session_set_array( 'dashboard,idtecnici', '".$rs[$i]['id']."', 0 ); "; } @@ -195,8 +198,8 @@ if ($total > 0) { ++$count; } } - - $checks .= "
  • \n"; + + $checks .= "
  • \n"; $allchecktecnici .= "session_set_array( 'dashboard,idtecnici', '".$rs[$i]['id']."', 0 ); "; } // end for @@ -248,7 +251,7 @@ for ($i = 0; $i < count($rs); ++$i) { } } - $checks .= "
  • \n"; + $checks .= "
  • \n"; $allcheckzone .= "session_set_array( 'dashboard,idzone', '".$rs[$i]['id']."', 0 ); "; } @@ -324,80 +327,118 @@ if ($vista == 'mese') { $(document).ready(function() { // Comandi seleziona tutti $('#selectallstati').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - this.checked = true; + + $(this).parent().parent().find('li input[type=checkbox]').each(function(i) { //loop through each checkbox + this.checked = true; + $.when (session_set_array( 'dashboard,idstatiintervento', this.value, 0 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + i++; + update_counter( 'idstati_count',i); + }); - update_counter( 'idstati_count', $('#idstati_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); }); $('#selectalltipi').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - this.checked = true; - }); + + $(this).parent().parent().find('li input[type=checkbox]').each(function(i) { //loop through each checkbox + this.checked = true; + $.when (session_set_array( 'dashboard,idtipiintervento', this.value, 0 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + i++; + update_counter( 'idtipi_count', i); - update_counter( 'idtipi_count', $('#idtipi_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); + }); + }); $('#selectalltecnici').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - this.checked = true; + + $(this).parent().parent().find('li input[type=checkbox]').each(function(i) { //loop through each checkbox + this.checked = true; + $.when (session_set_array( 'dashboard,idtecnici', this.value, 0 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + i++; + update_counter( 'idtecnici_count', i); }); - - update_counter( 'idtecnici_count', $('#idtecnici_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); + }); $('#selectallzone').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - this.checked = true; - }); + + $(this).parent().parent().find('li input[type=checkbox]').each(function(i) { //loop through each checkbox + this.checked = true; + $.when (session_set_array( 'dashboard,idzone', this.value, 0 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + i++ + update_counter( 'idzone_count', i); - update_counter( 'idzone_count', $('#idzone_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); + }); + }); // Comandi deseleziona tutti $('#deselectallstati').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - if( this.checked == true ) session_set_array( 'dashboard,idstatiintervento', this.value, 1 ); - this.checked = false; - }); - update_counter( 'idstati_count', $('#idstati_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); + $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox + this.checked = false; + $.when (session_set_array( 'dashboard,idstatiintervento', this.value, 1 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + update_counter( 'idstati_count', 0); + + }); + }); $('#deselectalltipi').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - if( this.checked == true ) session_set_array( 'dashboard,idtipiintervento', this.value, 1 ); - this.checked = false; - }); + + $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox + this.checked = false; + $.when (session_set_array( 'dashboard,idtipiintervento', this.value, 1 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + + update_counter( 'idtipi_count', 0); - update_counter( 'idtipi_count', $('#idtipi_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); + }); + }); $('#deselectalltecnici').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - if( this.checked == true ) session_set_array( 'dashboard,idtecnici', this.value, 1 ); - this.checked = false; + + $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox + this.checked = false; + $.when (session_set_array( 'dashboard,idtecnici', this.value, 1 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + update_counter( 'idtecnici_count', 0); + }); - update_counter( 'idtecnici_count', $('#idtecnici_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); }); $('#deselectallzone').click(function(event) { - $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox - if( this.checked == true ) session_set_array( 'dashboard,idzone', this.value, 1 ); - this.checked = false; + + $(this).parent().parent().find('li input[type=checkbox]').each(function() { //loop through each checkbox + this.checked = false; + $.when (session_set_array( 'dashboard,idzone', this.value, 1 )).promise().done(function() { + $('#calendar').fullCalendar('refetchEvents'); + }); + + update_counter( 'idzone_count', 0); + }); - update_counter( 'idzone_count', $('#idzone_ul').find('input:checked').length ); - $('#calendar').fullCalendar('refetchEvents'); }); // Creazione del calendario diff --git a/modules/dashboard/edit__.php b/modules/dashboard/edit__.php new file mode 100644 index 000000000..65e36d6d2 --- /dev/null +++ b/modules/dashboard/edit__.php @@ -0,0 +1,571 @@ +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=0 AND descrizione='Tecnico'"); + + $_SESSION['dashboard']['idtecnici'] = ["'-1'"]; + + for ($i = 0; $i < count($rs); ++$i) { + $_SESSION['dashboard']['idtecnici'][] = "'".$rs[$i]['id']."'"; + } +} + +if (!isset($_SESSION['dashboard']['idstatiintervento'])) { + $rs = $dbo->fetchArray('SELECT idstatointervento AS id, descrizione FROM in_statiintervento'); + + $_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'"]; + + for ($i = 0; $i < count($rs); ++$i) { + $_SESSION['dashboard']['idzone'][] = "'".$rs[$i]['id']."'"; + } +} + +// Stati intervento +$checks = ''; +$count = 0; +$total = 0; + +$rs = $dbo->fetchArray('SELECT idstatointervento AS id, descrizione, colore FROM in_statiintervento ORDER BY descrizione ASC'); +$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; + } + } + + $checks .= "
  • \n"; + + $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'; +} +?> + + +
    + + + +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; + } + } + + $checks .= "
  • \n"; + + $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'; +} +?> + + + +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 +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 +WHERE an_anagrafiche.deleted=0 AND an_tipianagrafiche.descrizione='Tecnico' ".Modules::getAdditionalsQuery('Interventi')." GROUP BY an_anagrafiche.idanagrafica ORDER BY ragione_sociale ASC"); +$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; + } + } + + $checks .= "
  • \n"; + + $allchecktecnici .= "session_set_array( 'dashboard,idtecnici', '".$rs[$i]['id']."', 0 ); "; +} + +// TECNICI ELIMINATI +$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 WHERE deleted=1 AND descrizione='Tecnico' ORDER BY ragione_sociale ASC"); +$total = count($rs); + +$totale_tecnici += $total; + +if ($total > 0) { + $checks .= "

  • Tecnici eliminati:
  • \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; + } + } + + $checks .= "
  • \n"; + + $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'; +} + +?> + + + + +fetchArray('SELECT id, descrizione FROM an_zone ORDER BY descrizione ASC'); +$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; + } + } + + $checks .= "
  • \n"; + + $allcheckzone .= "session_set_array( 'dashboard,idzone', '".$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'; +} +?> + + +
    +
    +fetchArray($qp); + +if (!empty($rsp)) { + echo ' +
    +
    '; +} + +echo ' +
    '; + +if (!empty($rsp)) { + echo ' +
    + + +
    '; +} + +$vista = get_var('Vista dashboard'); +if ($vista == 'mese') { + $def = 'month'; +} elseif ($vista == 'giorno') { + $def = 'agendaDay'; +} else { + $def = 'agendaWeek'; +} +?> + +