This commit is contained in:
Luca 2018-05-22 18:10:49 +02:00
commit 27abdbf89d
4 changed files with 185 additions and 266 deletions

View File

@ -39,13 +39,12 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
else {
// UPLOAD
if (filter('op') == 'link_file' && !empty($_FILES) && !empty($_FILES['blob']['name'])) {
$nome = filter('nome_allegato');
$nome = !empty($nome) ? $nome : $_FILES['blob']['name'];
$src = $_FILES['blob']['tmp_name'];
$f = pathinfo($_FILES['blob']['name']);
/*
$allowed = [
// Image formats
@ -166,25 +165,18 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
do {
$filename = random_string().'.'.$f['extension'];
} while (file_exists($upload_dir.'/'.$filename));
// Creazione file fisico
if (move_uploaded_file($src, $upload_dir.'/'.$filename)) {
$dbo->insert('zz_files', [
$dbo->insert('zz_files', [
'nome' => $nome,
'filename' => $filename,
'original' => $_FILES['blob']['name'],
'id_module' => $id_module,
'id_record' => $id_record,
'id_plugin' => $id_plugin,
'id_plugin' => !empty($id_plugin) ? $id_plugin : null,
]);
/*$dbo->query('INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')');
echo 'INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')';
exit;*/
$_SESSION['infos'][] = tr('File caricato correttamente!');
} else {
$_SESSION['errors'][] = tr('Errore durante il caricamento del file!');

View File

@ -4,80 +4,64 @@ include_once __DIR__.'/../../core.php';
$height = '80';
if (isset($_SESSION['period']['month'])) {
$period = explode(' ', $_SESSION['period']['month']);
$month = $period[0];
$year = $period[1];
if (isset( $_SESSION['period']['month'] )){
$period = explode(" ", $_SESSION['period']['month']);
$month = $period[0];
$year = $period[1];
$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];
$months = array( '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];
$title = $_SESSION['period']['month'];
//numero di giorni nel mese
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year)+1;
$title = $_SESSION['period']['month'];
$mindate = $year.'-'.$month.'-'.'01';
$maxdate = $year.'-'.$month.'-'.$maxday;
//numero di giorni nel mese
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1;
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
$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']);
$day = $period[0];
if (count($period) == 5){
$maxmonth = $period[3];
$maxday_ = $period[2];
$month = $period[3];
$year = $period[4];
}
if (count($period) == 6){
$maxmonth = $period[1];
$maxday_ = $period[3];
$month = $period[4];
$year = $period[5];
}
if (isset($_SESSION['period']['week'])) {
$period = explode(' ', $_SESSION['period']['week']);
$months = array( 'gen' => '01', 'feb' => '02', 'mar' => '03','apr' => '04','mag' => '05','giu' => '06','lug' => '07','ago' => '08','set' => '09','ott' => '10','nov' => '11','dic' => '12');
$month = $months[$month];
$maxmonth = $months[$maxmonth];
$title = $_SESSION['period']['week'];
//numero di giorni nel mese
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year)+1;
$day = $period[0];
$mindate = $year.'-'.$month.'-'.$day;
$maxdate = $year.'-'.$maxmonth.'-'.$maxday_;
//aggiungo un giorno
$maxdate = date('Y-m-d',date(strtotime("+1 day", strtotime($maxdate))));
if (count($period) == 5) {
$maxmonth = $period[3];
$maxday_ = $period[2];
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
$month = $period[3];
$year = $period[4];
}
if (count($period) == 6) {
$maxmonth = $period[1];
$maxday_ = $period[3];
$month = $period[4];
$year = $period[5];
}
$months = ['gen' => '01', 'feb' => '02', 'mar' => '03', 'apr' => '04', 'mag' => '05', 'giu' => '06', 'lug' => '07', 'ago' => '08', 'set' => '09', 'ott' => '10', 'nov' => '11', 'dic' => '12'];
$month = $months[$month];
$maxmonth = $months[$maxmonth];
$title = $_SESSION['period']['week'];
//numero di giorni nel mese
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1;
$mindate = $year.'-'.$month.'-'.$day;
$maxdate = $year.'-'.$maxmonth.'-'.$maxday_;
//aggiungo un giorno
$maxdate = date('Y-m-d', date(strtotime('+1 day', strtotime($maxdate))));
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
}
$report_name = sanitizeFilename('dashboard_'.$year.'_'.$month.'.pdf');
//$date_start = $_SESSION['period_start'];
@ -86,216 +70,155 @@ $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((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) SEPARATOR \'<br>\') AS cliente 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)";
$query = 'SELECT DAY(in_interventi_tecnici.orario_inizio) AS giorno, orario_inizio AS data, GROUP_CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) SEPARATOR \'<br>\') AS cliente 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;
$sessioni = $dbo->fetchArray($query);
//echo $query;
$rs = array();
for ($i=0; $i<33;$i++){
$rs[$sessioni[$i]['giorno']]['cliente'] = $sessioni[$i]['cliente'];
$rs[$sessioni[$i]['giorno']]['data'] = $sessioni[$i]['data'];
$rs = [];
for ($i = 0; $i < 33; ++$i) {
$rs[$sessioni[$i]['giorno']]['cliente'] = $sessioni[$i]['cliente'];
$rs[$sessioni[$i]['giorno']]['data'] = $sessioni[$i]['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;
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."<br>";
//echo date("w", $date)."<br>";
//echo $offset;
$rows = 1;
//echo "<h1>Displaying calendar for " . date("F Y", $date) . "</h1>\n";
$header = array();
$row = array();
//$table .= "<table border=\"1\">\n";
//echo "\t<tr><th>Su</th><th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th></tr>";
// $table .= "\t<tr><th>Lun</th><th>Mar</th><th>Mer</th><th>Gio</th><th>Ven</th><th>Sab</th><th>Dom</th></tr>";
//$header[$rows] = "\n\t<tr>";
//$row[$rows] = "\n\t<tr>";
//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;
if ($offset < 0) {
$offset = 7 + $offset;
}
$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 = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
$weekday = $weekdays[$weekday];
$header[$rows] .= "<th>".tr($weekday.' '.(sprintf("%02d", $day)).'/'.(sprintf("%02d", $current_month)), [], ['upper' => true])."</th>\n";
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b></td>\n";
}
//giorni del mese
for($day = 1; $day <= $daysInMonth; $day++){
if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
// $table .= "\t<tr><th>Lun ".$day."</th><th>Mar ".($day+1)."</th><th>Mer ".($day+2)."</th><th>Gio ".($day+3)."</th><th>Ven ".($day+4)."</th><th>Sab ".($day+5)."</th><th>Dom ".($day+6)."</th></tr>";
//echo $date."<br>";
//echo date("w", $date)."<br>";
//echo $offset;
// $header[$rows] .= "</tr>\n\t<tr>";
//$row[$rows] .= "</tr>\n\t<tr>";
$rows++;
$rows = 1;
//echo "<h1>Displaying calendar for " . date("F Y", $date) . "</h1>\n";
$header = [];
$row = [];
//$table .= "<table border=\"1\">\n";
//echo "\t<tr><th>Su</th><th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th></tr>";
// $table .= "\t<tr><th>Lun</th><th>Mar</th><th>Mer</th><th>Gio</th><th>Ven</th><th>Sab</th><th>Dom</th></tr>";
//$header[$rows] = "\n\t<tr>";
//$row[$rows] = "\n\t<tr>";
//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] .= '<th>'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])."</th>\n";
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b></td>\n";
}
$weekday = date('l', strtotime($year.'-'.$month.'-'.(sprintf("%02d", $day))));
$weekdays = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
$weekday = $weekdays[$weekday];
$header[$rows] .= "<th>" . tr($weekday.' '.(sprintf("%02d", $day)).'/'.$month, [], ['upper' => true]) ."</th>\n";
if (empty($rs[$day]['cliente'])){
$rs[$day]['cliente'] = ' ';
}
$row[$rows] .= "<td style='height:".$height."px' >". "<b>".$rs[$day]['cliente']."</b></td>\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){
//giorni del mese
for ($day = 1; $day <= $daysInMonth; ++$day) {
if (($day + $offset - 1) % 7 == 0 && $day != 1) {
// $table .= "\t<tr><th>Lun ".$day."</th><th>Mar ".($day+1)."</th><th>Mer ".($day+2)."</th><th>Gio ".($day+3)."</th><th>Ven ".($day+4)."</th><th>Sab ".($day+5)."</th><th>Dom ".($day+6)."</th></tr>";
$current_month = 1;
$current_year = $year+1;
}else{
// $header[$rows] .= "</tr>\n\t<tr>";
//$row[$rows] .= "</tr>\n\t<tr>";
$current_month = $month+1;
$current_year = $year;
++$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] .= '<th>'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.$month, [], ['upper' => true])."</th>\n";
if (empty($rs[$day]['cliente'])) {
$rs[$day]['cliente'] = ' ';
}
$row[$rows] .= "<td style='height:".$height."px' >".'<b>'.$rs[$day]['cliente']."</b></td>\n";
}
//$lastdateofmonth = date('t',$current_month);
//$lastdate = $lastdateofmonth."/".$current_month."/".$current_year;
$weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf("%02d", $i))));
$weekdays = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
$weekday = $weekdays[$weekday];
//$i = 1;
//giorni dopo
//while( ($day + $offset) <= $rows * 7){
$header[$rows] .= "<th> ".tr($weekday.' '.(sprintf("%02d", $i)).'/'.(sprintf("%02d", $current_month)), [], ['upper' => true])." </th>\n";
//$row[$rows] .= "<td> ".($offset+$day)."<br>".($rows * 7)." </td>\n";
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b> </td>\n";
$day++;
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;
}
}
//$header[$rows] .= "</tr>";
//$row[$rows] .= "</tr>";
//print_r($header);
//echo "<br>";
//print_r($row);
echo '<table class="table table-bordered">\n';
//creo righe
for ($i=1; $i<=count($row);$i++){
echo "<tr>\n";
echo $header[$i];
echo "</tr>\n";
echo "<tr>\n";
echo $row[$i];
echo "</tr>\n";
}
//$lastdateofmonth = date('t',$current_month);
echo '</table>';
//$table .= "</table>\n";
//$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] .= '<th> '.tr($weekday.' '.(sprintf('%02d', $i)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])." </th>\n";
//$row[$rows] .= "<td> ".($offset+$day)."<br>".($rows * 7)." </td>\n";
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b> </td>\n";
++$day;
}
//$header[$rows] .= "</tr>";
//$row[$rows] .= "</tr>";
//print_r($header);
//echo "<br>";
//print_r($row);
echo '<table class="table table-bordered">\n';
//creo righe
for ($i = 1; $i <= count($row); ++$i) {
echo "<tr>\n";
echo $header[$i];
echo "</tr>\n";
echo "<tr>\n";
echo $row[$i];
echo "</tr>\n";
}
echo '</table>';
//$table .= "</table>\n";
//echo $table;
}
}
// Intestazione tabella per righe
echo "
<h3 class='text-bold'>".tr('Calendario _PERIOD_', [
'_PERIOD_' => $title
], ['upper' => true])."</h3>";
'_PERIOD_' => $title,
], ['upper' => true]).'</h3>';
showMonth($month,$year,$rs, $height);
showMonth($month, $year, $rs, $height);

View File

@ -1,9 +1,10 @@
<?php
$format = (isset( $_SESSION['settings']['format'] )) ? $_SESSION['settings']['format'] : 'A4';
$orientation = (isset( $_SESSION['settings']['orientation'] )) ? $_SESSION['settings']['orientation'] : 'L';
$format = (isset($_SESSION['settings']['format'])) ? $_SESSION['settings']['format'] : 'A4';
$orientation = (isset($_SESSION['settings']['orientation'])) ? $_SESSION['settings']['orientation'] : 'L';
return [
'format' => $format,
'orientation' => $orientation,
// 'header-height' => 0,
'format' => $format,
'orientation' => $orientation,
// 'header-height' => 0,
];

View File

@ -212,3 +212,6 @@ UPDATE `or_statiordine` SET `completato` = '1' WHERE `or_statiordine`.`id` IN( 2
-- Campi per note aggiuntive in ddt e ordini
ALTER TABLE `or_ordini` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`;
ALTER TABLE `dt_ddt` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`;
-- Fix id_plugin (zz_files)
UPDATE `zz_files` SET `id_plugin` = NULL WHERE `id_plugin` = 0;