Aggiunto widget per stampa settimanale calendario

This commit is contained in:
Matteo 2023-05-19 12:22:48 +02:00
parent d001d3f11c
commit d268ba555f
5 changed files with 311 additions and 1 deletions

View File

@ -0,0 +1,114 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../../core.php';
use Carbon\Carbon;
// Trovo id_print della stampa
$id_print = Prints::getPrints()['Stampa calendario settimanale'];
echo '
<form action="" method="post" onsubmit="if($(this).parsley().validate()) { return stampa_calendario(); }" >
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Settimana').'", "name": "date", "required": "1" ]}
</div>
<div class="col-md-2">
{[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['dashboard']['format'].'" ]}
</div>
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['dashboard']['orientation'].'" ]}
</div>
<div class="col-md-2">
<p style="line-height:14px;">&nbsp;</p>
<button type="submit" class="btn btn-primary btn-block">
<i class="fa fa-print"></i> '.tr('Stampa').'
</button>
</div>
</div>
</form>
<script>$(document).ready(init)</script>';
echo '
<script>
function stampa_calendario (){
window.open(globals.rootdir + "/pdfgen.php?id_print='.$id_print.'");
return false;
}
$("#format").change(function() {
session_set("dashboard,format", $(this).val(), 0, 0);
});
$("#orientation").change(function() {
session_set("dashboard,orientation", $(this).val(), 0, 0);
});
</script>';
?>
<style>
.bootstrap-datetimepicker-widget tr:hover {
background-color: #eeeeee;
}
</style>
<script>
$(function() {
moment.updateLocale('en', {
week: { dow: 1 } // Monday is the first day of the week
});
moment.updateLocale('it', {
week: { dow: 1 } // Monday is the first day of the week
});
$("#date").datetimepicker({
format: 'DD/MM/YYYY',
});
//Get the value of Start and End of Week
$('#date').on('dp.change', function (e) {
value = $("#date").val();
firstDate = moment(value, "DD/MM/YYYY").day(1).format("DD/MM/YYYY");
lastDate = moment(value, "DD/MM/YYYY").day(7).format("DD/MM/YYYY");
$("#date").val(firstDate + " - " + lastDate);
session_set("dashboard,date_week_start", moment(firstDate, "DD/MM/YYYY").format("YYYY-MM-DD"), 0, 0);
session_set("dashboard,date_week_end", moment(lastDate, "DD/MM/YYYY").format("YYYY-MM-DD"), 0, 0);
});
});
</script>

View File

@ -0,0 +1,129 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../core.php';
use Carbon\Carbon;
$calendar = $_SESSION['dashboard'];
$date_start = $calendar['date_week_start'];
$date_end = date('Y-m-d', strtotime('+1 day', strtotime($calendar['date_week_end'])));
$title = date('d/m/Y', strtotime($date_start))." - ".date('d/m/Y', strtotime($date_end));
$min_date = new Carbon($date_start);
$max_date = new Carbon($date_end);
$height = '480';
$stati = (array) $calendar['idstatiintervento'];
$tipi = (array) $calendar['idtipiintervento'];
$tecnici = (array) $calendar['idtecnici'];
$query = "SELECT
DATE(orario_inizio) AS data,
in_interventi.richiesta AS richiesta,
DATE_FORMAT(orario_inizio, '%H:%i') AS ora_inizio,
DATE_FORMAT(orario_fine, '%H:%i') AS ora_fine,
(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS anagrafica,
GROUP_CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi_tecnici.idtecnico) SEPARATOR ', ') AS tecnico,
in_statiintervento.colore AS color
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').'
GROUP BY in_interventi.id, data
ORDER BY ora_inizio ASC';
$sessioni = $dbo->fetchArray($query);
$sessioni = collect($sessioni)->groupBy('data');
// Intestazione tabella
echo '
<h3 class="text-bold">'.tr('Calendario _PERIOD_', [
'_PERIOD_' => $title,
], ['upper' => true]).'</h3>';
// Elenco per la gestione
$list = [];
// Filler per i giorni non inclusi della settimana iniziale
$current_day = $min_date;
// Elenco del periodo indicato
while ($current_day->lessThan($max_date)) {
$list[] = [
'date' => $current_day->copy(),
'contents' => $sessioni[$current_day->toDateString()] ?: [],
];
$current_day->addDay();
}
// Stampa della tabella
echo '
<table class="table table-bordered">';
$count = count($list);
for ($i = 0; $i < $count; $i = $i + 7) {
echo '
<tr>';
for ($c = 0; $c < 7; ++$c) {
$element = $list[$i + $c];
echo '
<th>'.ucfirst($element['date']->formatLocalized('%A %d/%m')).'</th>';
}
echo '
</tr>';
echo '
<tr>';
for ($c = 0; $c < 7; ++$c) {
$element = $list[$i + $c];
$clienti = '';
foreach ($element['contents'] as $sessione) {
$clienti .= '<table><tr><td style="background-color:'.$sessione['color'].';font-size:8pt;">'.$sessione['ora_inizio'].' - '.$sessione['ora_fine'].'</small><br><b>'.$sessione['anagrafica'].'</b><br>
<i>'.$sessione['richiesta'].'</i><small>'.$sessione['tecnico'].'</td></tr></table>';
}
$background = '#ffffff';
if (empty($clienti)) {
$background = 'lightgray';
}
echo '
<td style="height:'.$height.'px;background:'.$background.'">'.$clienti.'</td>';
}
echo '
</tr>';
}
echo '
</table>';

View File

@ -0,0 +1,34 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
echo '
<!-- Intestazione fornitore -->
<div class="row">
<div class="col-xs-6">
<p><b>$f_ragionesociale$</b></p>
<p>$f_indirizzo$ $f_citta_full$</p>
<p>'.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$</p>
<p>'.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$</p>
<p>'.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$</p>
<p>'.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$</p>
</div>
<div class="col-xs-6 text-right">
<img src="$logo$" alt="Logo" border="0"/>
</div>
</div>';

View File

@ -0,0 +1,26 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
$format = (isset($_SESSION['dashboard']['format'])) ? $_SESSION['dashboard']['format'] : 'A4';
$orientation = (isset($_SESSION['dashboard']['orientation'])) ? $_SESSION['dashboard']['orientation'] : 'L';
return [
'format' => $format,
'orientation' => $orientation,
];

View File

@ -26,3 +26,10 @@ DELETE FROM `zz_prints` WHERE `name` = 'Spesometro';
-- Aggiunta stampa ddt in entrata
INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto'), '1', 'Ddt di acquisto', 'Ddt in entrata', 'DDT num. {numero} del {data}', 'ddt', 'idddt', '{\"pricing\":true}', 'fa fa-print', '', '', '0', '1', '1', '1');
-- Aggiuntq widget per la stampa settimanale del calendario
INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES
(NULL, 'Stampa calendario settimanale', 'print', (SELECT id FROM zz_modules WHERE name = 'Dashboard'), 'controller_top', NULL, NULL, '#4ccc4c', 'fa fa-print', '', './modules/dashboard/widgets/stampa_calendario_settimanale.dashboard.php', 'popup', '', 'Stampa calendario settimanale', 1, 7, NULL);
INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`, `available_options`) VALUES
(NULL, (SELECT id FROM zz_modules WHERE name = 'Dashboard'), 1, 'Stampa calendario settimanale', 'Stampa calendario settimanale', 'Calendario settimanale', 'dashboard_settimanale', '', '', 'fa fa-print', '', '', 0, 1, 1, 1, NULL);