2021-06-14 15:48:46 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2020-04-20 13:31:41 +02:00
|
|
|
|
2021-11-08 12:09:49 +01:00
|
|
|
use Carbon\Carbon;
|
2024-03-06 10:56:09 +01:00
|
|
|
use Models\Module;
|
2024-03-22 15:52:24 +01:00
|
|
|
use Plugins\PianificazioneInterventi\Promemoria;
|
2020-04-20 13:31:41 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../../core.php';
|
|
|
|
|
2021-03-29 10:07:45 +02:00
|
|
|
$elenco_promemoria = Promemoria::doesntHave('intervento')->orderByraw('data_richiesta ASC')->get();
|
2021-03-17 18:51:25 +01:00
|
|
|
|
|
|
|
$array_promemoria = [];
|
2021-03-29 10:07:45 +02:00
|
|
|
foreach ($elenco_promemoria as $promemoria) {
|
2021-03-17 18:51:25 +01:00
|
|
|
$data_pro = new Carbon($promemoria->data_richiesta);
|
2021-03-29 10:07:45 +02:00
|
|
|
$array_promemoria[$data_pro->format('Y-m')][] = $promemoria;
|
2021-03-17 18:51:25 +01:00
|
|
|
}
|
|
|
|
|
2020-04-20 13:31:41 +02:00
|
|
|
if ($elenco_promemoria->isEmpty()) {
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Non ci sono promemoria da pianificare').'.</p>';
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-04-09 12:18:08 +02:00
|
|
|
$raggruppamenti = $elenco_promemoria->groupBy(fn ($item) => $item->data_richiesta->format('Y-m'));
|
2020-04-20 13:31:41 +02:00
|
|
|
|
|
|
|
$counter = 0;
|
|
|
|
foreach ($raggruppamenti as $mese => $raggruppamento) {
|
|
|
|
++$counter;
|
|
|
|
|
|
|
|
// Se cambia il mese ricreo l'intestazione della tabella
|
|
|
|
if ($counter == 1) {
|
|
|
|
$attr = '';
|
|
|
|
$class = 'fa-minus-circle';
|
|
|
|
} else {
|
|
|
|
$attr = 'style="display:none;"';
|
|
|
|
$class = 'fa-plus-circle';
|
|
|
|
}
|
|
|
|
|
2021-03-29 10:07:45 +02:00
|
|
|
$nome_mese = new Carbon($mese.'-01');
|
2021-03-17 18:51:25 +01:00
|
|
|
|
2020-04-20 13:31:41 +02:00
|
|
|
echo "
|
|
|
|
<h4>
|
|
|
|
<a class='clickable' onclick=\"if( $('#promemoria_pianificare_".$counter."').css('display') == 'none' ){ $(this).children('i').removeClass('fa-plus-circle'); $(this).children('i').addClass('fa-minus-circle'); }else{ $(this).children('i').addClass('fa-plus-circle'); $(this).children('i').removeClass('fa-minus-circle'); } $('#promemoria_pianificare_".$counter."').slideToggle();\">
|
2024-04-10 14:53:26 +02:00
|
|
|
<i class='fa ".$class."'></i> ".ucfirst($nome_mese->isoFormat('MMMM YYYY')).'
|
2020-04-20 13:31:41 +02:00
|
|
|
</a>
|
|
|
|
</h4>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div id="promemoria_pianificare_'.$counter.'" '.$attr.'>
|
|
|
|
<table class="table table-hover table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-11-06 15:52:01 +01:00
|
|
|
<th width="200">'.tr('Cliente').'</th>
|
|
|
|
<th width="300">'.tr('Contratto').'</th>
|
|
|
|
<th width="70">'.tr('Entro').'</th>
|
|
|
|
<th width="200">'.tr('Tipo attività').'</th>
|
|
|
|
<th>'.tr('Descrizione').'</th>
|
|
|
|
<th width="20"></th>
|
2020-04-20 13:31:41 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
// Elenco promemoria da pianificare
|
2021-03-17 18:51:25 +01:00
|
|
|
foreach ($array_promemoria[$mese] as $promemoria) {
|
2020-04-20 13:31:41 +02:00
|
|
|
$contratto = $promemoria->contratto;
|
|
|
|
$anagrafica = $contratto->anagrafica;
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td>
|
2020-11-06 15:52:01 +01:00
|
|
|
'.Modules::link('Anagrafiche', $anagrafica->id, nl2br($anagrafica->ragione_sociale)).'<br><small>Presso: ';
|
|
|
|
|
2020-11-09 20:03:47 +01:00
|
|
|
// Sede promemoria
|
|
|
|
if ($promemoria->idsede == '-1') {
|
2024-01-15 15:30:45 +01:00
|
|
|
echo '- Nessuna -';
|
2020-11-09 20:03:47 +01:00
|
|
|
} elseif (empty($promemoria->idsede)) {
|
|
|
|
echo tr('Sede legale');
|
|
|
|
} else {
|
|
|
|
$rsp2 = $dbo->fetchArray("SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id=".prepare($promemoria->idsede));
|
|
|
|
|
|
|
|
echo $rsp2[0]['descrizione'];
|
|
|
|
}
|
2020-11-06 15:52:01 +01:00
|
|
|
|
|
|
|
echo ' </small>
|
2020-04-20 13:31:41 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
'.reference($contratto).'
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>'.dateFormat($promemoria->data_richiesta).'</td>
|
2024-04-18 17:44:05 +02:00
|
|
|
<td>'.$promemoria->tipo->getTranslation('title').'</td>
|
2020-04-20 13:31:41 +02:00
|
|
|
<td>'.nl2br($promemoria->richiesta).'</td>
|
|
|
|
|
2020-11-06 15:52:01 +01:00
|
|
|
<td>
|
2020-04-20 13:31:41 +02:00
|
|
|
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Pulsanti
|
|
|
|
echo '
|
|
|
|
<td>
|
2024-04-18 17:44:05 +02:00
|
|
|
<button type="button" class="btn btn-primary btn-sm" title="Pianifica intervento ora..." data-toggle="tooltip" onclick="launch_modal(\'Pianifica intervento\', \''.base_path().'/add.php?id_module='.(new Module())->getByField('title', 'Interventi', Models\Locale::getPredefined()->id).'&ref=interventi_contratti&idcontratto='.$contratto->id.'&idcontratto_riga='.$promemoria->id.'\');">
|
2020-04-20 13:31:41 +02:00
|
|
|
<i class="fa fa-calendar"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>';
|
|
|
|
}
|