Aggiunto controllo gestionale per colonne duplicate in Viste

This commit is contained in:
Dasc3er 2021-09-17 11:51:10 +02:00
parent 87f98cfd94
commit a408a86593
3 changed files with 66 additions and 0 deletions

View File

@ -20,6 +20,7 @@
include_once __DIR__.'/../../core.php';
use Models\Cache;
use Modules\Aggiornamenti\Controlli\ColonneDuplicateViste;
use Modules\Aggiornamenti\Controlli\Controllo;
use Modules\Aggiornamenti\Controlli\DatiFattureElettroniche;
use Modules\Aggiornamenti\Controlli\PianoConti;
@ -51,6 +52,7 @@ switch (filter('op')) {
$controlli = [
PianoConti::class,
DatiFattureElettroniche::class,
ColonneDuplicateViste::class,
];
$results = [];

View File

@ -0,0 +1,60 @@
<?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/>.
*/
namespace Modules\Aggiornamenti\Controlli;
use Models\Module;
use Modules\Fatture\Fattura;
use Util\XML;
class ColonneDuplicateViste extends Controllo
{
public function getName()
{
return tr('Colonne duplicate per le Viste');
}
public function getType($record)
{
return 'warning';
}
public function check()
{
$duplicati = database()->fetchArray('SELECT `id_module`, `name` FROM `zz_views` GROUP BY `id_module`, `name` HAVING COUNT(`name`) > 1');
foreach ($duplicati as $colonna){
$modulo = Module::pool($colonna['id_module']);
$this->addResult([
'id' => $colonna['name'],
'nome' => $modulo->title.': '.$colonna['name'],
'descrizione' => tr('La colonna _NAME_ del modulo _MODULE_ esiste più volte', [
'_NAME_' => $modulo->title,
'_MODULE_' => $modulo->title,
]),
]);
}
}
public function execute($record, $params = [])
{
return false;
}
}

View File

@ -24,6 +24,7 @@ use Carbon\Carbon;
use Common\Components\Component;
use Common\Document;
use Illuminate\Database\Eloquent\Builder;
use InvalidArgumentException;
use Models\Upload;
use Modules\Anagrafiche\Anagrafica;
use Modules\Banche\Banca;
@ -462,6 +463,9 @@ class Fattura extends Document
}
$file = $this->uploads()->where('name', '=', 'Fattura Elettronica')->first();
if (empty($file)) {
throw new InvalidArgumentException("Fattura Elettronica non trovata");
}
return $file->getContent();
}