1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-29 09:11:11 +01:00
openstamanager/plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php

132 lines
4.5 KiB
PHP
Raw Normal View History

2021-03-17 18:51:25 +01: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/>.
*/
use Plugins\PianificazioneInterventi\Promemoria;
include_once __DIR__.'/../../../core.php';
2021-03-17 18:51:25 +01:00
$elenco_promemoria = Promemoria::doesntHave('intervento')->orderByraw("data_richiesta ASC")->get();
$array_promemoria = [];
foreach($elenco_promemoria as $promemoria){
$data_pro = new Carbon($promemoria->data_richiesta);
$array_promemoria[$data_pro->format("Y-m")][] = $promemoria;
}
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');
});
$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-17 18:51:25 +01:00
$nome_mese = new Carbon($mese."-01");
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-17 18:51:25 +01:00
<i class='fa ".$class."'></i> ".ucfirst($nome_mese->formatLocalized("%B %Y")).'
</a>
</h4>';
echo '
<div id="promemoria_pianificare_'.$counter.'" '.$attr.'>
<table class="table table-hover table-striped">
<thead>
<tr>
<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>
</tr>
</thead>
<tbody>';
// Elenco promemoria da pianificare
2021-03-17 18:51:25 +01:00
foreach ($array_promemoria[$mese] as $promemoria) {
$contratto = $promemoria->contratto;
$anagrafica = $contratto->anagrafica;
echo '
<tr>
<td>
'.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'];
}
echo ' </small>
</td>
<td>
'.reference($contratto).'
</td>
<td>'.dateFormat($promemoria->data_richiesta).'</td>
<td>'.$promemoria->tipo->descrizione.'</td>
<td>'.nl2br($promemoria->richiesta).'</td>
<td>
</td>';
// Pulsanti
echo '
<td>
<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.'\');">
<i class="fa fa-calendar"></i>
</button>
</td>
</tr>';
}
echo '
</tbody>
</table>
</div>';
}