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.0 KiB
84 righe
2.0 KiB
<?php |
|
|
|
namespace App\Console\Commands\Preservation; |
|
|
|
use App\Models\Main\Tenant; |
|
use InvalidArgumentException; |
|
use Illuminate\Console\Command; |
|
use App\Models\Tenant\Gare\Gara; |
|
use Illuminate\Support\Facades\DB; |
|
use Facade\Ignition\Exceptions\InvalidConfig; |
|
|
|
$path = dirname(base_path()); |
|
include_once "{$path}/config.php"; |
|
|
|
class CheckTendersForPreservationCommand 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-tenders |
|
{--T|tenant= : Tenant Identifier}'; |
|
|
|
/** |
|
* The console command description. |
|
* |
|
* @var string |
|
*/ |
|
protected $description = 'Check completed tenders 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') && Gara::count() > 0) { |
|
|
|
foreach(Gara::select("codice", "stato", "codice_ente")->cursor() as $gara) { |
|
|
|
$this->line("Processing tender #{$gara["codice"]}"); |
|
$ente->checkConservazione("gare", $gara["codice"], $gara["stato"], $gara["codice_ente"]); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
}
|
|
|