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.
 
 
 
 
 

140 righe
8.7 KiB

<?
if (!empty($elabora_coda) && (!empty($_SESSION["ente"]))) {
alertManager::printCliInfo("Scadenze in Form");
if (empty(getQueueLog($_SESSION["ente"]->codice,"scadenzeForm"))) {
$current_time = (int) date('H');
if($current_time >= 8) {
$elenchi = [];
$elenchi["b_bandi_albo"] = ["partecipanti"=>"r_partecipanti_albo","folder"=>"albo_fornitori","modulo"=>"albo_fornitori","relazione"=>"r_albo_fornitori_form"];
$limiti = array();
$limiti["30"] = date('Y-m-d',strtotime("+30 days"));
$limiti["7"] = date('Y-m-d',strtotime("+7 day"));
$limiti["1"] = date('Y-m-d',strtotime("+1 day"));
$limiti["0"] = date('Y-m-d');
$limite_ultimo = date('Y-m-d');
$inputInfo = $pdo->prepare("SELECT * FROM b_form_input WHERE codice = :codice_input");
$groupQS = $pdo->prepare("SELECT * FROM b_form_data WHERE codice_gruppo = :gruppo AND gruppo_compilazione = :gc AND type = :type AND id = :id AND soft_delete = 'N'");
$deadlineIds = $pdo->prepare("SELECT b_form_input.codice FROM b_form_input JOIN b_form_group ON b_form_input.codice_gruppo = b_form_group.codice WHERE b_form_group.codice_form = :form AND b_form_input.tipo = 'deadline'");
$deadlineValues = $pdo->prepare("SELECT * FROM b_form_data WHERE type = :type AND codice_input = :input AND id = :id");
foreach ($elenchi AS $tabella => $infoElenco) {
$scadenze = [];
$folder = $infoElenco["folder"];
$modulo = $infoElenco["modulo"];
$sql_bandi = "SELECT * FROM {$tabella} WHERE (scadenza > now() OR scadenza IS NULL) AND pubblica > 0 AND stato NOT IN (80)";
$ris_bandi = $pdo->query($sql_bandi);
$checkForm = $pdo->prepare("SELECT codice_form FROM {$infoElenco["relazione"]} WHERE codice_elenco = :elenco");
$groupQS->bindValue(":type","{$modulo}-{$_SESSION["ente"]->codice}");
$deadlineValues->bindValue(":type","{$modulo}-{$_SESSION["ente"]->codice}");
$risPartecipanti = $pdo->prepare("SELECT ".$infoElenco["partecipanti"].".* FROM " . $infoElenco["partecipanti"] . " WHERE ammesso = 'S' AND codice_elenco = :elenco");
if ($ris_bandi->rowCount() > 0) {
while($bando = $ris_bandi->fetch(PDO::FETCH_ASSOC)) {
$logID = "scadenzeRevisioni-{$tabella}-{$bando["codice"]}";
if (empty(getQueueLog($_SESSION["ente"]->codice,$logID))) {
$risPartecipanti->bindValue(":elenco",$bando["codice"]);
$risPartecipanti->execute();
if ($risPartecipanti->rowCount() > 0) {
$partecipanti = $risPartecipanti->fetchAll(PDO::FETCH_ASSOC);
$checkForm->bindValue(":elenco",$bando["codice"]);
$checkForm->execute();
if ($checkForm->rowCount() > 0) {
while($idForm = $checkForm->fetch(PDO::FETCH_COLUMN)) {
$deadlineIds->bindValue(":form",$idForm);
$deadlineIds->execute();
if (!empty($deadlineIds->rowCount())) {
while($deadlineID = $deadlineIds->fetch(PDO::FETCH_COLUMN)) {
$deadlineValues->bindValue(":input",$deadlineID);
foreach($partecipanti AS $partecipante) {
if ($partecipante["valutato"]=="S") {
$deadlineValues->bindValue(":id",$partecipante["codice"]);
$deadlineValues->execute();
if ($deadlineValues->rowCount() > 0) {
while($formData = $deadlineValues->fetch(PDO::FETCH_ASSOC)) {
$scadenza = date2mysql($formData["valore"]);
if (!empty($scadenza)) {
foreach($limiti AS $gg => $limite) {
if ($limite == $scadenza) {
if (!isset($scadenze[$partecipante["codice_operatore"]][$bando["codice"]])) {
$scadenze[$partecipante["codice_operatore"]][$bando["codice"]] = ["bando" => $bando, "msg" => "", "scaduta" => null];
}
$scadenza_string = $gg . " giorni";
if ($gg=="30") { $scadenza_string = "1 mese"; }
if ($gg=="1") { $scadenza_string = "1 giorno"; }
if (empty($gg)) {
$scadenza_string = "SCADUTA";
$scadenze[$partecipante["codice_operatore"]][$bando["codice"]]["scaduta"] = $partecipante["codice"];
}
$groupQS->bindValue(":gruppo",$formData["codice_gruppo"]);
$groupQS->bindValue(":gc",$formData["gruppo_compilazione"]);
$groupQS->bindValue(":id",$formData["id"]);
$groupQS->execute();
if ($groupQS->rowCount() > 0) {
$corpo = "";
while($groupData = $groupQS->fetch(PDO::FETCH_ASSOC)) {
$inputInfo->bindValue(":codice_input",$groupData["codice_input"]);
$inputInfo->execute();
if ($inputInfo->rowCount() > 0) {
$info = $inputInfo->fetch(PDO::FETCH_ASSOC);
if ($info["tipo"] != "file") {
$titolo = json_decode($info["titolo"],true)["IT"];
$corpo .= $titolo . ": " . $groupData["valore"];
if ($info["codice"] == $formData["codice_input"]) {
$corpo .= " - {$scadenza_string}";
}
$corpo .= "<br>";
}
}
}
$corpo .= "<hr><br>";
$scadenze[$partecipante["codice_operatore"]][$bando["codice"]]["msg"] .= $corpo;
}
}
}
}
}
}
}
}
}
}
}
}
}
writeQueueLog($_SESSION["ente"]->codice,$logID);
}
}
}
if (!empty($scadenze)) {
foreach($scadenze AS $codice_operatore => $bandi) {
$oggetto = __("Documenti in scadenza");
$corpo = "Si informa la S.V. sono presenti documenti in scadenza relativi ai seguenti bandi:";
foreach($bandi AS $codice_bando => $info) {
$bando = $info["bando"];
$href = "https://".$_SESSION["ente"]->getInfo()["dominio"]."/".$folder."/id".$bando["codice"]."-dettaglio";
$corpo.= "<br><br><strong><a href='".$href."' title='Sito esterno'>" . $bando["oggetto"] . "</a></strong><br>";
$corpo.= $info["msg"];
if (!empty($info["scaduta"]) && settingsManager::getValue("scadenzaDocumentiForm") == "E") {
$pdo->go("UPDATE {$infoElenco["partecipanti"]} SET valutato = 'S', ammesso = 'N', motivazione = 'Documentazione scaduta' WHERE codice = :codice ",[":codice"=>$info["scaduta"]]);
}
}
$corpo.= "La invitiamo ad aggiornare quanto prima i suoi dati<br>";
$corpo.= "Distinti Saluti<br><br>";
$mailer = new Communicator();
$mailer->oggetto = $oggetto;
$mailer->corpo = $corpo;
$mailer->codice_pec = $bando["codice_pec"];
$mailer->comunicazione = true;
$mailer->coda = false;
$mailer->destinatari = $codice_operatore;
$esito = $mailer->send();
unset($mailer);
}
}
}
writeQueueLog($_SESSION["ente"]->codice,"scadenzeForm");
}
} else {
alertManager::printCliWarning("Già eseguito");
}
}
?>