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
|
|
|
|
|
|
|
use Plugins\PianificazioneInterventi\Promemoria;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$raggruppamenti = $elenco_promemoria->groupBy(function ($item) {
|
2021-03-17 18:51:25 +01:00
|
|
|
return $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();\">
|
2021-03-29 10:07:45 +02:00
|
|
|
<i class='fa ".$class."'></i> ".ucfirst($nome_mese->formatLocalized('%B %Y')).'
|
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') {
|
|
|
|
echo '- '.('Nessuna').' -';
|
|
|
|
} 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>
|
|
|
|
<td>'.$promemoria->tipo->descrizione.'</td>
|
|
|
|
<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>
|
2020-09-23 17:53:19 +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='.Modules::get('Interventi')['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>';
|
|
|
|
}
|