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.
118 righe
3.9 KiB
118 righe
3.9 KiB
<?php |
|
|
|
$mode = $_REQUEST['action']; |
|
switch ($mode) { |
|
case 'preSaveContratto': |
|
preSaveContratto(); |
|
break; |
|
case 'saveContratto': |
|
saveContratto(); |
|
break; |
|
case 'delContratto': |
|
deleteContratto(); |
|
break; |
|
} |
|
|
|
function preSaveContratto() { |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
$canoneAnnuo = Utils::get_filter_string_POST('CANONE_ANNUO'); |
|
$canone_explod = explode(',', $canoneAnnuo); |
|
$canone_decimal = ($canone_explod[1] ? $canone_explod[1] : '00'); |
|
$canone_intero = $canone_explod[0]; |
|
$canone_text = Utils::spell_my_int($canone_intero); |
|
$risultato = "" . $canoneAnnuo . " (" . $canone_text . "/" . $canone_decimal . ")"; |
|
// echo $risultato; |
|
$response['esito'] = 1; |
|
$response['testo'] = $risultato; |
|
echo json_encode($response); |
|
} |
|
|
|
function saveContratto() { |
|
global $con, $LoggedAccount; |
|
$transaction = false; |
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_contratti', $_POST['csrf_contratti']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
|
|
$con->db_transactionStart(); |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
// VERIFICO SE SONO NEL PERIODO DELLA PRESENTAZIONE DELLA DOMANDA |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
//Utils::print_array($_POST); |
|
DomandaContratti::checkVerificaDatiPreSalvataggio(); |
|
$contratto = new DomandaContratti($_POST); |
|
//Utils::print_array($contratto); |
|
$controlliContratto = $contratto->checkDatiPreSave(); |
|
if ($controlliContratto['checkDati']) { |
|
|
|
$verificaslot = $contratto->VerificaSlotTemporale(); |
|
if ($verificaslot['esito'] == 1) { |
|
$response = $contratto->Save(); |
|
if ($response['esito'] == 1) { |
|
$num = DomandaContratti::Count('ID_DOMANDA = ' . $contratto->ID_DOMANDA); |
|
$response['nuovoContratto'] = ($num == 1 ? true : false); |
|
$transaction = true; |
|
} |
|
} else { |
|
$response['esito'] = -999; |
|
$response['erroreDescrizione'] = $verificaslot['erroreDescrizione']; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = ("Verificare i seguenti campi: " . $controlliContratto['txt_dati_mancanti']); |
|
} |
|
|
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function deleteContratto() { |
|
global $con, $LoggedAccount; |
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_contratti', $_POST['csrf_contratti']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
$transaction = false; |
|
$con->db_transactionStart(); |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
// VERIFICO SE SONO NEL PERIODO DELLA PRESENTAZIONE DELLA DOMANDA |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
$id_contratto = Utils::get_filter_int_POST('id_contratto'); |
|
|
|
$contratto = new DomandaContratti($id_contratto); |
|
if ($contratto->isErasable()) { |
|
$response = $contratto->Delete(); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = 'Contratto non cancellabile'; |
|
} |
|
|
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
}
|
|
|