gestione gare pubbliche
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

84 righe
2.1 KiB

<?php
namespace App\Console\Commands\Preservation;
use App\Models\Main\Tenant;
use App\Models\Tenant\Contratti\Contratti;
use App\Models\Tenant\Contratti\ContrattiSottoscritti;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use InvalidArgumentException;
$path = dirname(base_path());
include_once "{$path}/config.php";
class CheckContractsForPreservationCommand extends Command
{
/**
* Tenant
*
* @var App\Models\Main\Tenant
*/
private $tenant;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'preservation:check-completed-contracts
{--T|tenant= : Tenant Identifier}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check completed contracts and prepare them for preservation';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
do {
$tenant = $this->option('tenant') ?? $this->ask('What is Tenant id?');
$this->tenant = Tenant::find($tenant);
if (! $this->tenant) {
$this->error('Invalid Tenant ID. Please try again.');
}
} while (! $this->tenant);
setup_db_connection($this->tenant->codice);
$ente = new \ente();
$ente->excludeConnector = true;
$ente->init($this->tenant->dominio);
if(empty($ente->codice)) {
throw new InvalidArgumentException("Failed to initialize EnteClass with: {$this->tenant->dominio}");
}
global $pdo;
$pdo->setConnessioneEnte($this->tenant->codice);
if($ente->hasModulo('conservazione') && Contratti::count() > 0) {
foreach(Contratti::select("codice", "stato")->cursor() as $contratto) {
$this->line("Processing contract #{$contratto["codice"]}");
$ente->checkConservazione("stipula", $contratto["codice"], $contratto["stato"], $ente->codice);
}
}
return 0;
}
}