diff --git a/modules/articoli/edit.php b/modules/articoli/edit.php index fdafefd10..07894418e 100644 --- a/modules/articoli/edit.php +++ b/modules/articoli/edit.php @@ -94,7 +94,7 @@ $_SESSION['superselect']['id_categoria'] = $record['id_categoria'];
- {[ "type": "checkbox", "label": "", "name": "attivo", "help": "", "value": "$attivo$", "placeholder": "" ]} + {[ "type": "checkbox", "label": "", "name": "attivo", "help": "", "value": "$attivo$", "placeholder": "" ]}
diff --git a/modules/dashboard/widgets/stampa_calendario.dashboard.php b/modules/dashboard/widgets/stampa_calendario.dashboard.php index ac96f8678..1ce0ec0ab 100644 --- a/modules/dashboard/widgets/stampa_calendario.dashboard.php +++ b/modules/dashboard/widgets/stampa_calendario.dashboard.php @@ -9,77 +9,58 @@ echo '
-
- {[ "type": "text", "label": "'.tr('Anno Mese').'", "name": "anno-mese", "required": "1", "extra":"readonly", "value": "'.$_SESSION['period']['month'].'" ]} + {[ "type": "text", "label": "'.tr('Mese e anno').'", "name": "date", "required": "1", "value": "'.$_SESSION['dashboard']['date'].'" ]}
- +
- {[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['settings']['format'].'" ]} + {[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['dashboard']['format'].'" ]}
- {[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['settings']['orientation'].'" ]} + {[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['dashboard']['orientation'].'" ]}

 

- + +
-
'; + -echo ''; -echo ''; +'; ?> - - diff --git a/modules/interventi/add_righe.php b/modules/interventi/add_righe.php index a2793c3c3..0d406c175 100644 --- a/modules/interventi/add_righe.php +++ b/modules/interventi/add_righe.php @@ -116,10 +116,10 @@ echo ' $('#bs-popup').modal('hide'); // Ricarico le righe - $('#righe').load('fileurl('ajax_righe.php');?>?id_module=&id_record='); + $('#righe').load('fileurl('ajax_righe.php'); ?>?id_module=&id_record='); // Ricarico la tabella dei costi - $('#costi').load('fileurl('ajax_costi.php');?>?id_module=&id_record='); + $('#costi').load('fileurl('ajax_costi.php'); ?>?id_module=&id_record='); } }); }); diff --git a/modules/interventi/ajax_righe.php b/modules/interventi/ajax_righe.php index a15a887f6..d3c2e4704 100644 --- a/modules/interventi/ajax_righe.php +++ b/modules/interventi/ajax_righe.php @@ -161,10 +161,10 @@ if (!$righe->isEmpty()) { }, function(data, result){ if(result == 'success'){ // Ricarico le righe - $('#righe').load('fileurl('ajax_righe.php');?>?id_module=&id_record='); + $('#righe').load('fileurl('ajax_righe.php'); ?>?id_module=&id_record='); // Ricarico la tabella dei costi - $('#costi').load('fileurl('ajax_costi.php');?>?id_module=&id_record='); + $('#costi').load('fileurl('ajax_costi.php'); ?>?id_module=&id_record='); // Toast diff --git a/modules/my_impianti/plugins/my_impianti.componenti.php b/modules/my_impianti/plugins/my_impianti.componenti.php index dbc46063a..12ae06693 100644 --- a/modules/my_impianti/plugins/my_impianti.componenti.php +++ b/modules/my_impianti/plugins/my_impianti.componenti.php @@ -155,7 +155,7 @@ if (!empty($rs2)) { // Per più "versioni" dello stesso componente mostro un riga meno evidente // per non confonderlo come componente in uso in questo momento $same = ($prev_componente == $nome_componente); - + if (get('id') == $rs2[$j]['id']) { $collapsed = ''; $icon = 'minus'; diff --git a/modules/preventivi/add.php b/modules/preventivi/add.php index 0d6427c31..17ac7273b 100644 --- a/modules/preventivi/add.php +++ b/modules/preventivi/add.php @@ -13,7 +13,7 @@ $id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : $user['idan
- {[ "type": "date", "label": "", "name": "data_bozza", "value": "", "required": 1 ]} + {[ "type": "date", "label": "", "name": "data_bozza", "value": "", "required": 1 ]}
{[ "type": "text", "label": "", "name": "nome", "required": 1 ]} diff --git a/modules/preventivi/src/Preventivo.php b/modules/preventivi/src/Preventivo.php index 2ad65716f..1cd91f36c 100644 --- a/modules/preventivi/src/Preventivo.php +++ b/modules/preventivi/src/Preventivo.php @@ -53,12 +53,13 @@ class Preventivo extends Document // Salvataggio delle informazioni $model->nome = $nome; - if (empty($data_bozza)) + if (empty($data_bozza)) { $model->data_bozza = Carbon::now(); - else + } else { $model->data_bozza = $data_bozza; + } $model->data_conclusione = Carbon::now()->addMonth(); - + if (!empty($id_sede)) { $model->idsede = $id_sede; } diff --git a/modules/zone/ajax/select.php b/modules/zone/ajax/select.php index c10055dfc..d6851143b 100644 --- a/modules/zone/ajax/select.php +++ b/modules/zone/ajax/select.php @@ -4,7 +4,7 @@ include_once __DIR__.'/../../../core.php'; switch ($resource) { case 'zone': - + $query = 'SELECT `id`, CONCAT(`nome`, \' - \', `descrizione`) AS `descrizione` FROM an_zone |where| ORDER BY descrizione ASC'; foreach ($elements as $element) { diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php index 782a0d47d..95d8b7b7e 100644 --- a/plugins/sedi/edit.php +++ b/plugins/sedi/edit.php @@ -4,7 +4,6 @@ include_once __DIR__.'/../../core.php'; $google = setting('Google Maps API key'); - /* if (!empty($google)) { echo ' @@ -131,8 +130,6 @@ if (!empty($google)) {
'; } - - // Permetto eliminazione tipo sede solo se non è utilizzata da nessun'altra parte nel gestionale $elementi = $dbo->fetchArray('SELECT `zz_user_sedi`.`id_user` AS `id` FROM `zz_user_sedi` WHERE `zz_user_sedi`.`idsede` = '.prepare($id_record).' UNION @@ -146,8 +143,8 @@ if (!empty($elementi)) { '_NUM_' => count($elementi), ]).'.
'; - - $disabled = 'disabled'; + + $disabled = 'disabled'; } echo ' @@ -176,4 +173,4 @@ $(document).ready( function(){ $("#form_sedi #lng_").val(result.geometry.location.lng()); }); }); -'; \ No newline at end of file +'; diff --git a/plugins/sedi/init.php b/plugins/sedi/init.php index 1aed21821..16ed17b1e 100644 --- a/plugins/sedi/init.php +++ b/plugins/sedi/init.php @@ -13,4 +13,4 @@ if (isset($id_record)) { if (isset($id_parent)) { $record['tipo_anagrafica'] = $dbo->fetchOne('SELECT tipo FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica ='.prepare($id_parent))['tipo']; $record['iso2'] = $dbo->fetchOne('SELECT iso2 FROM an_nazioni INNER JOIN an_anagrafiche ON an_nazioni.id = an_anagrafiche.id_nazione WHERE an_anagrafiche.idanagrafica ='.prepare($id_parent))['iso2']; -} \ No newline at end of file +} diff --git a/src/Translator.php b/src/Translator.php index 5f06d02a3..01a7af4bc 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -81,10 +81,17 @@ class Translator extends Util\Singleton $this->translator->setLocale($locale); $this->locale = $locale; - $reduced = explode('_', $locale)[0]; + Carbon::setUtf8(true); - setlocale(LC_TIME, $reduced); - Carbon::setLocale($reduced); + $result = setlocale(LC_TIME, $locale); + Carbon::setLocale($locale); + + if (empty($result)) { + $reduced = explode('_', $locale)[0]; + + $result = setlocale(LC_TIME, $reduced); + Carbon::setLocale($reduced); + } self::setFormatter($locale, $formatter); } diff --git a/templates/dashboard/body.php b/templates/dashboard/body.php index 38415b246..951961ed8 100644 --- a/templates/dashboard/body.php +++ b/templates/dashboard/body.php @@ -2,29 +2,15 @@ include_once __DIR__.'/../../core.php'; -$height = '80'; +use Carbon\Carbon; -if (isset($_SESSION['period']['month'])) { - $period = explode(' ', $_SESSION['period']['month']); - $month = $period[0]; - $year = $period[1]; +$calendar = $_SESSION['dashboard']; - $months = ['Gennaio' => '01', 'Febbraio' => '02', 'Marzo' => '03', 'Aprile' => '04', 'Maggio' => '05', 'Giugno' => '06', 'Luglio' => '07', 'Agosto' => '08', 'Settembre' => '09', 'Ottobre' => '10', 'Novembre' => '11', 'Dicembre' => '12']; - $month = $months[$month]; +$date = $calendar['date']; +$date = new Carbon($date); - $title = $_SESSION['period']['month']; - - //numero di giorni nel mese - $maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1; - - $mindate = $year.'-'.$month.'-'.'01'; - $maxdate = $year.'-'.$month.'-'.$maxday; - - $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND '; -} - -if (isset($_SESSION['period']['week'])) { - $period = explode(' ', $_SESSION['period']['week']); +if ($calendar['format'] == 'week') { + $period = explode(' ', $_SESSION['dashboard']['week']); $day = $period[0]; @@ -48,179 +34,133 @@ if (isset($_SESSION['period']['week'])) { $month = $months[$month]; $maxmonth = $months[$maxmonth]; - $title = $_SESSION['period']['week']; + $title = $_SESSION['dashboard']['week']; //numero di giorni nel mese $maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1; - $mindate = $year.'-'.$month.'-'.$day; - $maxdate = $year.'-'.$maxmonth.'-'.$maxday_; + $min_date = $year.'-'.$month.'-'.$day; + $max_date = $year.'-'.$maxmonth.'-'.$maxday_; //aggiungo un giorno - $maxdate = date('Y-m-d', date(strtotime('+1 day', strtotime($maxdate)))); + $max_date = date('Y-m-d', date(strtotime('+1 day', strtotime($max_date)))); - $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND '; + $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($max_date).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($min_date).' AND '; +} else { + $title = $date->formatLocalized('%B %Y'); + + $min_date = $date->copy()->startOfMonth(); + $max_date = $date->copy()->endOfMonth(); + + $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($max_date).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($min_date).' AND '; } -$custom = [ - 'periodo' => $month.'-'.$year, -]; +$height = '80'; -//$date_start = $_SESSION['period_start']; -//$date_end = $_SESSION['period_end']; -$stati = (array) $_SESSION['dashboard']['idstatiintervento']; -$tipi = (array) $_SESSION['dashboard']['idtipiintervento']; -$tecnici = (array) $_SESSION['dashboard']['idtecnici']; - -//in_interventi_tecnici.idintervento, colore, in_interventi_tecnici.id, idtecnico, orario_inizio, orario_fine,(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS nome_tecnico, (SELECT colore FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS colore_tecnico, -$query = 'SELECT DAY(in_interventi_tecnici.orario_inizio) AS giorno, orario_inizio AS data, GROUP_CONCAT(CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica), \'
\', (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi_tecnici.idtecnico), \'\' ) SEPARATOR \'
\') AS attivita FROM in_interventi_tecnici INNER JOIN (in_interventi LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento) ON in_interventi_tecnici.idintervento=in_interventi.id WHERE '.$where.' idtecnico IN('.implode(',', $tecnici).') AND in_interventi.idstatointervento IN('.implode(',', $stati).') AND in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') '.Modules::getAdditionalsQuery('Interventi').' GROUP BY giorno ORDER BY CAST(giorno AS UNSIGNED)'; - -//echo $query; +$stati = (array) $calendar['idstatiintervento']; +$tipi = (array) $calendar['idtipiintervento']; +$tecnici = (array) $calendar['idtecnici']; +$query = 'SELECT + DATE(orario_inizio) AS data, + (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS anagrafica, + (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi_tecnici.idtecnico) AS tecnico +FROM in_interventi_tecnici + INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id + LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento +WHERE '.$where.' + idtecnico IN('.implode(',', $tecnici).') AND + in_interventi.idstatointervento IN('.implode(',', $stati).') AND + in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') '.Modules::getAdditionalsQuery('Interventi'); $sessioni = $dbo->fetchArray($query); -//echo $query; -$rs = []; -for ($i = 0; $i < 33; ++$i) { - $rs[$sessioni[$i]['giorno']]['cliente'] = $sessioni[$i]['attivita']; - $rs[$sessioni[$i]['giorno']]['data'] = $sessioni[$i]['data']; -} +$sessioni = collect($sessioni)->groupBy('data'); -function showMonth($month, $year, &$rs, &$height) -{ - $date = mktime(12, 0, 0, $month, 1, $year); - $daysInMonth = date('t', $date); - // calculate the position of the first day in the calendar (sunday = 1st column, etc) - $offset = (date('w', $date) - 1) % 7; - - if ($offset < 0) { - $offset = 7 + $offset; - } - - //echo $date."
"; - //echo date("w", $date)."
"; - //echo $offset; - - $rows = 1; - - //echo "

Displaying calendar for " . date("F Y", $date) . "

\n"; - $header = []; - $row = []; - - //$table .= "\n"; - //echo "\t"; - // $table .= "\t"; - - //$header[$rows] = "\n\t"; - //$row[$rows] = "\n\t"; - - //giorni prima - for ($i = 1; $i <= $offset; ++$i) { - $current_month = $month; - if ($current_month == 1) { - $current_month = 12; - $current_year = $year - 1; - } else { - $current_month = $month - 1; - $current_year = $year; - } - - $lastdateofmonth = date('t', $current_month); - - //$lastdate = $lastdateofmonth."/".$current_month."/".$current_year; - - $day = (($lastdateofmonth - $offset) + ($i)); - $weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf('%02d', $day)))); - $weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica']; - $weekday = $weekdays[$weekday]; - - $header[$rows] .= '\n"; - $row[$rows] .= "\n"; - } - - //giorni del mese - for ($day = 1; $day <= $daysInMonth; ++$day) { - if (($day + $offset - 1) % 7 == 0 && $day != 1) { - // $table .= "\t"; - - // $header[$rows] .= "\n\t"; - //$row[$rows] .= "\n\t"; - - ++$rows; - } - - $weekday = date('l', strtotime($year.'-'.$month.'-'.(sprintf('%02d', $day)))); - $weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica']; - $weekday = $weekdays[$weekday]; - - $header[$rows] .= '\n"; - if (empty($rs[$day]['cliente'])) { - $rs[$day]['cliente'] = ' '; - } - - $row[$rows] .= "\n"; - } - - //$i = 1; - //giorni dopo - //while( ($day + $offset) <= $rows * 7){ - - for ($i = 1; ($day + $offset) <= ($rows * 7); ++$i) { - $current_month = $month; - if ($current_month == 12) { - $current_month = 1; - $current_year = $year + 1; - } else { - $current_month = $month + 1; - $current_year = $year; - } - - //$lastdateofmonth = date('t',$current_month); - - //$lastdate = $lastdateofmonth."/".$current_month."/".$current_year; - - $weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf('%02d', $i)))); - $weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica']; - $weekday = $weekdays[$weekday]; - - $header[$rows] .= '\n"; - //$row[$rows] .= "\n"; - $row[$rows] .= "\n"; - - ++$day; - } - - //$header[$rows] .= ""; - //$row[$rows] .= ""; - - //print_r($header); - //echo "
"; - //print_r($row); - - echo '
SuMTuWThFSa
LunMarMerGioVenSabDom
'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])."
Lun ".$day."Mar ".($day+1)."Mer ".($day+2)."Gio ".($day+3)."Ven ".($day+4)."Sab ".($day+5)."Dom ".($day+6)."
'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.$month, [], ['upper' => true])."".''.$rs[$day]['cliente']." '.tr($weekday.' '.(sprintf('%02d', $i)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])." ".($offset+$day)."
".($rows * 7)."
\n'; - - //creo righe - for ($i = 1; $i <= count($row); ++$i) { - echo "\n"; - echo $header[$i]; - echo "\n"; - - echo "\n"; - echo $row[$i]; - echo "\n"; - } - - echo '
'; - - //$table .= "\n"; - - //echo $table; -} - -// Intestazione tabella per righe -echo " -

".tr('Calendario _PERIOD_', [ +// Intestazione tabella +echo ' +

'.tr('Calendario _PERIOD_', [ '_PERIOD_' => $title, ], ['upper' => true]).'

'; -showMonth($month, $year, $rs, $height); +// Elenco per la gestione +$list = []; + +// Filler per i giorni non inclusi della settimana iniziale +$week_start = $min_date->startOfWeek(); +$current_day = $week_start; +while ($current_day->lessThan($min_date)) { + $list[] = [ + 'date' => $current_day->copy(), + 'contents' => [], + ]; + + $current_day->addDay(); +} + +// Elenco del periodo indicato +while ($current_day->lessThan($max_date)) { + $list[] = [ + 'date' => $current_day->copy(), + 'contents' => $sessioni[$current_day->toDateString()] ?: [], + ]; + + $current_day->addDay(); +} + +// Filler per i giorni non inclusi della settimana finale +$week_end = $max_date->endOfWeek(); +while ($current_day->lessThan($week_end)) { + $list[] = [ + 'date' => $current_day->copy(), + 'contents' => [], + ]; + + $current_day->addDay(); +} + +// Stampa della tabella +echo ' +'; + +$count = count($list); +for ($i = 0; $i < $count; $i = $i + 7) { + echo ' + '; + + for ($c = 0; $c < 7; ++$c ) { + $element = $list[$i + $c]; + + echo ' + '; + } + + echo ' + '; + + echo ' + '; + + for ($c = 0; $c < 7; ++$c ) { + $element = $list[$i + $c]; + + $clienti = ''; + foreach ($element['contents'] as $sessione) { + $clienti .= $sessione['anagrafica'].'
+ '.$sessione['tecnico'].'
'; + } + + $background = '#ffffff'; + if (empty($clienti)) { + $background = 'lightgray'; + } + + echo ' + '; + } + + echo ' + '; +} + +echo ' +
'.$element['date']->formatLocalized('%A %d/%m').'
'.$clienti.'
'; diff --git a/templates/dashboard/settings.php b/templates/dashboard/settings.php index 754a1e442..b8f40e4f5 100644 --- a/templates/dashboard/settings.php +++ b/templates/dashboard/settings.php @@ -1,7 +1,8 @@ $format, diff --git a/update/v2_4_10/Fattura.php b/update/v2_4_10/Fattura.php index 010b4e66d..fe45424ca 100644 --- a/update/v2_4_10/Fattura.php +++ b/update/v2_4_10/Fattura.php @@ -23,10 +23,10 @@ class Fattura extends Document /** * Crea una nuova fattura. * - * @param Anagrafica $anagrafica - * @param TipoFattura $tipo_documento - * @param string $data - * @param int $id_segment + * @param Anagrafica $anagrafica + * @param TipoFattura $tipo_documento + * @param string $data + * @param int $id_segment * * @return self */