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.
 
 
 

848 righe
49 KiB

<!doctype html>
<?php
include '../../lib/api.php';
define('THIS_PERMISSION', GRUPPO_STATISTICHE);
define('THIS_PERMISSION2', GRUPPO_REGIONE);
include_once (ROOT . "layout/include_permission.php");
$toDay = new DateTime();
$toDay->sub(new DateInterval('P1D'));
$oggi = $toDay->format('Y-m-d');
$dPost = (isset($_POST['dataElaborazione']) ? $_POST['dataElaborazione'] : $toDay->format('d-m-Y'));
$data_elaborazione = new DateTime($dPost); //07-12-2023
$dataElaborazione = $data_elaborazione->format('d/m/Y');
$stats = DomandaSconti::GetTotalePerStato($dataElaborazione);
$rs = array();
foreach ($stats as $k => $stat) {
$stat['SCONTO_CAL'] = $stat['SCONTO'];
$stat['COSTO_CAL'] = $stat['COSTO'];
$stat['SCONTO'] = number_format(str_replace(",", ".", round($stat['SCONTO'], 2)), 2, ',', '.');
$stat['COSTO'] = number_format(str_replace(",", ".", round($stat['COSTO'], 2)), 2, ',', '.');
$rs[$stat['STATO']][$stat['LOTTO']][] = $stat;
}
?>
<html lang="en">
<? include_once ROOT . 'layout/head.php'; ?>
<body>
<? include_once ROOT . 'layout/header.php'; ?>
<? include_once ROOT . 'layout/menu.php'; ?>
<main role="main" class="<?= $cssColumNavBar ?>" >
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Estrazioni</li>
</ol>
</nav>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card-title">
<form class="form-inline" method="post" action="estrazioni.php">
<label class="my-1 mr-2" >Estrazioni al</label>
<input type="date" class="form-control " required autocomplete="new-password" min="<?= MIN_DATA_ACQUISTO_BIGLIETTO_JS ?>" max="<?= $dataElaborazione ?>" name="dataElaborazione" id="dataElaborazione" value="<?= (trim($dataElaborazione) != "" ? $data_elaborazione->format('Y-m-d') : '') ?>">
<button type="submit" class="btn btn-primary m-3">Applica la data</button>
<button type="button" onclick="exportVISTA()" class="btn btn-sm btn-danger float-right">EXPORT VIEW</button>
</form>
</div>
<?
//Utils::print_array($STATI_RICHIESTE_SCONTI);
//Utils::print_array($rs);
?>
<div class="row">
<?
foreach ($STATI_RICHIESTE_SCONTI as $key => $value) {
$btn = "";
$bg_card = "";
$badge = "";
$tfooter = false;
$th_data = '-';
$th_periodo = 'Periodo elaborato';
$btnChangeLotto = '';
switch ($key) {
case RS_IN_ELABORAZIONE:
$col = "col-lg-12";
$bg_card = "bg-secondary";
$badge = "badge-success";
//$btn='<button type="button" onclick="presaInCarico()" class="btn btn-sm btn-light">'.$ICONE_STATI_RICHIESTE_SCONTI[RS_PRESA_IN_CARICO].'&nbsp;Prendi in carico</button>';
$th_data = "-";
//$tfooter = true;
break;
case RS_PRESA_IN_CARICO:
$col = "col-lg-12";
$bg_card = "bg-info";
$badge = "badge-success";
$th_data = "Data estrazione";
if ($LoggedAccount->SUPER_USER) {
$btnChangeLotto = '<button type="button" title="Cambia lotto di destinazione " data-toggle="modal" data-target="#modaleCambiaLotto" class="float-right mr-5 btn btn-sm btn-warning"><i class="fas fa-exchange-alt"></i></button>';
}
break;
case RS_APPROVATA:
$col = "col-lg-12";
$bg_card = "bg-success";
$badge = "badge-success";
$th_data = "Data esito";
break;
case RS_EROGATA:
$col = "col-lg-12";
$bg_card = "bg-primary";
$badge = "badge-success";
$th_data = "Data erogazione";
$tfooter = true;
break;
case RS_NON_APPROVATA:
$col = "col-lg-12";
$bg_card = "bg-dark";
$badge = "badge-success";
$th_data = "Data esito";
break;
case RS_ANNULLATE_UFFICIO:
$bg_card = "bg-danger";
$badge = "badge-success";
break;
}
?>
<div class="<?= $col ?> mb-3">
<div class="card <?= $bg_card ?> h-100 text-white shadow-sm">
<div class="card-header">
<h6 class="card-title"><?= $value ?><span class="badge badge-light float-right"><?= $ICONE_STATI_RICHIESTE_SCONTI[$key] ?></span><?= $btnChangeLotto ?></h6>
</div>
<div class="card-body bg-light">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">Tipo</th>
<th scope="col">Lotto</th>
<th scope="col"><?= $th_data ?></th>
<th scope="col"><?= $th_periodo ?></th>
<th scope="col">Q.tà</th>
<th scope="col">Costo €.</th>
<th class="table-success" scope="col">Sconto €.</th>
<th scope="col">#</th>
</tr>
</thead>
<tbody>
<?
$totale_costo = 0;
$totale_sconto = 0;
$totale_costo_erogato = 0;
$totale_sconto_erogato = 0;
foreach ($rs[$key] as $k => $val) {
foreach ($val as $ke => $v) {
$btnChange = '';
$btnExport = '';
switch ($v['STATO']) {
case RS_IN_ELABORAZIONE:
$btnChange = '<button type="button" title="Prendi in carico" onclick="presaInCarico(' . $v['PRIORITA'] . ')" class="btn btn-sm btn-warning">' . $ICONE_STATI_RICHIESTE_SCONTI[RS_PRESA_IN_CARICO] . '</button>';
//$badge="badge-warning";
$totale_costo += $v['COSTO_CAL'];
$totale_sconto += $v['SCONTO_CAL'];
$column_elaborato = 'dal 04/12/2023 al ' . $dataElaborazione;
break;
case RS_PRESA_IN_CARICO:
$bg_card = "bg-info";
$badge = "badge-success";
if ($LoggedAccount->SUPER_USER) {
$btnChange = '<button type="button" title="Approva le pratiche verificate" onclick="approva(\'' . $k . '\', \'approvaVerificati\')" class="btn btn-sm btn-info"><i class="fas fa-user-check"></i></button>';
}
$btnChange .= '<button type="button" title="Approva tutte le pratiche" onclick="approva(\'' . $k . '\', \'approva\')" class="btn btn-sm btn-warning">' . $ICONE_STATI_RICHIESTE_SCONTI[RS_APPROVATA] . '</button>';
$btnExport = '<button type="button" title="Export" onclick="exportXls(\'' . $k . '\', \'' . $v['STATO'] . '\')" class="btn btn-sm btn-success"><i class="fas fa-download"></i></button>';
$column_data = $v['DATA_ESPORTAZIONE'];
$column_elaborato = 'dal 04/12/2023 al ' . $v['DATA_FILTRO'];
break;
case RS_APPROVATA:
$bg_card = "bg-success";
$badge = "badge-success";
$btnChange = '<button type="button" title="Eroga" onclick="eroga(\'' . $k . '\')" class="btn btn-sm btn-warning">' . $ICONE_STATI_RICHIESTE_SCONTI[RS_EROGATA] . '</button>';
$btnChange .= '<button type="button" title="Disapprova" onclick="approva(\'' . $k . '\', \'disapprova\')" class="btn btn-sm btn-danger">' . $ICONE_STATI_RICHIESTE_SCONTI[RS_PRESA_IN_CARICO] . '</button>';
$btnExport .= '<button type="button" title="Anagrafiche" onclick="exportAnagrafiche(\'' . $k . '\', \'' . $v['STATO'] . '\', \'' . $v['PRIORITA'] . '\')" class="btn btn-sm btn-primary"><i class="fas fa-user"></i></button>';
$btnExport .= '<button type="button" title="Anagrafiche a Blocchi" onclick="exportAnagraficheBlocchi(\'' . $k . '\', \'' . $v['STATO'] . '\', \'' . $v['PRIORITA'] . '\')" class="btn btn-sm btn-primary"><i class="fas fa-users"></i></button>';
$btnExport .= '<button type="button" title="Decreti" onclick="exportDecreti(\'' . $k . '\', \'' . $v['STATO'] . '\', 0, \'' . $v['PRIORITA'] . '\')" class="btn btn-sm btn-primary"><i class="fas fa-file-excel"></i></button>';
$btnExport .= '<button type="button" title="Decreti Omissis" onclick="exportDecreti(\'' . $k . '\', \'' . $v['STATO'] . '\', 1,\'' . $v['PRIORITA'] . '\')" class="btn btn-sm btn-primary"><i class="fas fa-file-export"></i></button>';
// $btnExport='<button type="button" title="Export" onclick="exportXlsMandati(\''.$k.'\', \''.$v['STATO'].'\')" class="btn btn-sm btn-success"><i class="fas fa-file-excel"></i></i></button>';
$btnExport .= '<button type="button" title="Mandati di pagamento" onclick="exportXmlMandati(\'' . $k . '\', \'' . $v['STATO'] . '\')" class="btn btn-sm btn-success"><i class="fas fa-file-invoice-dollar"></i></button>';
if ($LoggedAccount->SUPER_USER) {
$onclickLotto = 'loadMandato(\'' . $v['LOTTO'] . '\', \'' . $v['STATO'] . '\')';
$btnExport .= '<button type="button" title="Decreto Generale" onclick="'.$onclickLotto.'" data-toggle="modal" data-target="#editMandato" class="btn btn-sm btn-info"><i class="fas fa-file-pdf"></i></button>';
}
//$btnExport .= '<button type="button" title="Decreto Generale" onclick="exportDecretoGenerale(\'' . $k . '\', \'' . $v['STATO'] . '\')" class="btn btn-sm btn-info"><i class="fas fa-file-pdf"></i></button>';
$column_data = $v['DATA_ESITO'];
$column_elaborato = 'dal 04/12/2023 al ' . $v['DATA_FILTRO'];
$drsData = DomandaSconti::getDrsFromLotto($k);
$drs = $drsData['NUMERO_DRS'];
$dataDrs = Date::convertData($drsData['DATA_DRS']);
break;
case RS_EROGATA:
$bg_card = "bg-primary";
$badge = "badge-success";
$column_data = $v['DATA_EROGAZIONE'];
$totale_costo_erogato += $v['COSTO_CAL'];
$totale_sconto_erogato += $v['SCONTO_CAL'];
$btnExport = '<button type="button" title="Export" onclick="exportXls(\'' . $k . '\', \'' . $v['STATO'] . '\')" class="btn btn-sm btn-success"><i class="fas fa-download"></i></button>';
$column_elaborato = 'dal 04/12/2023 al ' . $v['DATA_FILTRO'];
$drsData = DomandaSconti::getDrsFromLotto($k);
$drs = $drsData['NUMERO_DRS'];
$dataDrs = Date::convertData($drsData['DATA_DRS']);
break;
case RS_NON_APPROVATA:
$bg_card = "bg-dark";
$badge = "badge-success";
$column_data = $v['DATA_ESITO'];
$btnExport = '<button type="button" title="Export" onclick="exportXls(\'' . $k . '\', \'' . $v['STATO'] . '\')" class="btn btn-sm btn-success"><i class="fas fa-download"></i></button>';
$column_elaborato = 'dal 04/12/2023 al ' . $v['DATA_FILTRO'];
break;
}
?>
<tr>
<th scope="row"><?= $TIPO_RICHIESTA[$v['PRIORITA']] ?></th>
<th scope="row">
<?= $k ?>
<small><?= $drs > 0 && $v['STATO'] == RS_EROGATA ? "<br>DRS NR. " . $drs . " del " . $dataDrs : "" ?></small>
</th>
<td><?= $column_data ?></td>
<td><?= $column_elaborato ?></td>
<td><?= $v['NUM'] ?></td>
<td><?= $v['COSTO'] ?></td>
<td class="table-success" ><?= $v['SCONTO'] ?></td>
<td><div class="btn-group float-right" role="group"><?= $btnExport . $btnChange ?></div></td>
</tr>
<?
}
}
?>
</tbody>
<?
if ($tfooter && $key == RS_IN_ELABORAZIONE) {
$perc = 100 / $totale_costo * $totale_sconto;
$perc = number_format(str_replace(",", ".", round($perc, 2)), 2, ',', '.');
?>
<tfoot>
<tr>
<td colspan="8" class="table-success"><small>(<b>100</b>/<b>Costo</b>)*<b>Sconto</b> = <?= $perc ?>%</small></td>
</tr>
</tfoot>
<?
}
if ($tfooter && $key == RS_EROGATA) {
$totale_costo_erogato = number_format(str_replace(",", ".", round($totale_costo_erogato, 2)), 2, ',', '.');
$totale_sconto_erogato = number_format(str_replace(",", ".", round($totale_sconto_erogato, 2)), 2, ',', '.');
?>
<tfoot>
<tr>
<th colspan="5"></th>
<th><?= $totale_costo_erogato ?></th>
<th class="table-success"><?= $totale_sconto_erogato ?></th>
<th>&nbsp;</th>
</tr>
</tfoot>
<?
}
?>
</table>
</div>
<div class="card-footer">
<div class="btn-group" role="group">
<?= (count($rs[$key]) > 0 ? $btn : '') ?>
</div>
</div>
</div>
</div>
<? } ?>
</div>
</div>
</div>
<div id="editMandato" class="modal fade" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">PRODUZIONE DEL DECRETO DI LIQUIDAZIONE</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="col s12 needs-validation" id="form-edit-mandato" action="javascript:generaMandato()" enctype="multipart/form-data" novalidate>
<input type="hidden" id="actionFile" name="actionFile" value="saveFile" />
<input type="hidden" id="edit_STATO" name="STATO" />
<input type="hidden" id="edit_FILEPATH_DRS" name="FILEPATH_DRS" />
<input type="hidden" id="edit_FILEPATH" name="FILEPATH" />
<div class="modal-body">
<div class="row">
<div class="col">
<div class="form-group">
<label for="LOTTO">Lotto</label>
<input type="text" readonly="readonly" class="form-control" id="edit_LOTTO" name="LOTTO"/>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="TIPO">Tipo</label>
<input type="hidden" readonly="readonly" class="form-control" id="edit_TIPO" name="TIPO"/>
<input type="text" readonly="readonly" class="form-control" id="edit_TIPO_TXT" name="TIPO_TXT"/>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="IMPORTO_MANDATO">Importo da liquidare</label>
<input type="text" readonly="readonly" class="form-control" id="edit_IMPORTO_MANDATO" name="IMPORTO_MANDATO"/>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="NUMERO_DRS">Numero D.R.S.<span class="text-danger">*</span></label>
<input type="text" required class="form-control" id="edit_NUMERO_DRS" name="NUMERO_DRS"/>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="oggetto">Data D.R.S.<span class="text-danger">*</span></label>
<input type="date" required class="form-control" id="edit_DATA_DRS" name="DATA_DRS"/>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="MESE_RIFERIMENTO">Mese/Anno riferimento<span class="text-danger">*</span></label>
<input type="text" required readonly autocomplete="off" class="form-control bg-white" id="edit_MESE_RIFERIMENTO" name="MESE_RIFERIMENTO" placeholder="Seleziona mese e anno"/>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="CAPITOLO_BILANCIO">Capitolo di spesa<span class="text-danger">*</span></label>
<input type="text" required class="form-control" id="edit_CAPITOLO_BILANCIO" name="CAPITOLO_BILANCIO"/>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="CODICE_FINANZIARIO">Codice finanziario<span class="text-danger">*</span></label>
<input type="text" required class="form-control" id="edit_CODICE_FINANZIARIO" name="CODICE_FINANZIARIO"/>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="ANNO_FINANZIARIO">Anno finanziario<span class="text-danger">*</span></label>
<input type="text" required class="form-control" id="edit_ANNO_FINANZIARIO" name="ANNO_FINANZIARIO"/>
</div>
</div>
</div>
<div class="row d-none" id="upload_decreto_liquidazione">
<div class="col">
<div class="form-group">
<label for="edit_FILEPATH_UPLOAD">Upload decreto di liquidazione<span class="text-danger">*</span></label>
<input type="file" disabled class="form-control-file" id="edit_FILEPATH_UPLOAD" name="FILEPATH_UPLOAD" accept=".pdf,.p7m,.pdf.p7m,application/pdf"/>
<small class="form-text text-muted" id="edit_FILEPATH_LABEL"></small>
<button type="button" class="btn btn-sm btn-success mt-2 d-none" id="btn-download-filepath" onclick="downloadFilepath()">
<i class="fas fa-download"></i>&nbsp;Scarica file caricato
</button>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
<button class="btn btn-success" type="submit" name="save" id="btn-submit-mandato">Genera il decreto di liquidazione</button>
<button class="btn btn-primary d-none" type="button" id="btn-upload-mandato" onclick="generaMandato('upload')">Carica il decreto di liquidazione</button>
</div>
</form>
</div>
</div>
</div>
<div id="modaleCambiaLotto" class="modal fade" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">SPOSTA LE RICHIESTE DI UN LOTTO AD UN ALTRO LOTTO</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="col s12" id="form-cambia-lotto" action="javascript:siparsFramework.ModModal('form-cambia-lotto', 'elenco_sconti')">
<input type="hidden" id="action" name="action" value="cambiaLotto" />
<div class="modal-body">
<div class="form-group">
<label for="oggetto">LOTTO DI ORIGINE</label>
<input type="number" class="form-control" name="LOTTO_FROM"/>
</div>
<div class="form-group">
<label for="oggetto">LOTTO DI DESTINAZIONE</label>
<input type="number" class="form-control" name="LOTTO_TO"/>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
<button class="btn btn-danger" type="submit" name="save">Procedi</button>
</div>
</form>
</div>
</div>
</div>
</main>
<? include_once ROOT . 'layout/footer.php'; ?>
<style>
.month-year-datepicker .ui-datepicker-calendar {
display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
initMeseRiferimentoPicker();
});
function initMeseRiferimentoPicker() {
var mesi = [
'gennaio',
'febbraio',
'marzo',
'aprile',
'maggio',
'giugno',
'luglio',
'agosto',
'settembre',
'ottobre',
'novembre',
'dicembre'
];
$('#edit_MESE_RIFERIMENTO').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
monthNames: mesi,
monthNamesShort: mesi,
closeText: 'Seleziona',
currentText: 'Mese corrente',
beforeShow: function (input, inst) {
if ($(input).data('datepickerLocked')) {
return false;
}
var valueParts = $.trim(input.value).toLowerCase().split(' ');
var monthIndex = mesi.indexOf(valueParts[0]);
var year = parseInt(valueParts[1], 10);
if (monthIndex >= 0 && !isNaN(year)) {
$(this).datepicker('option', 'defaultDate', new Date(year, monthIndex, 1));
$(this).datepicker('setDate', new Date(year, monthIndex, 1));
}
setTimeout(function () {
inst.dpDiv.addClass('month-year-datepicker');
}, 0);
},
onClose: function () {
var month = $('#ui-datepicker-div .ui-datepicker-month :selected').val();
var year = $('#ui-datepicker-div .ui-datepicker-year :selected').val();
if (month !== undefined && year !== undefined) {
$(this).val(mesi[parseInt(month, 10)] + ' ' + year);
}
$('#ui-datepicker-div').removeClass('month-year-datepicker');
}
});
}
function loadMandato(lotto, stato) {
var form = $('#form-edit-mandato');
form[0].reset();
$('#edit_STATO').val(stato);
configureMandatoForm(false);
$.post(WS_CALL + '?module=elenco_sconti&action=loadMandato', {id: lotto}, function (data) {
var record = JSON.parse(data);
$.each(record, function (i, item) {
var field = $('[name="' + i + '"]');
if (field.length > 0) {
field.val(item);
}
});
$('#edit_STATO').val(stato);
configureMandatoForm($.trim(record.FILEPATH_DRS || '') !== '', $.trim(record.FILEPATH || '') !== '', record.FILEPATH || '');
});
}
function configureMandatoForm(hasDrsFile, hasUploadedFile, filePath) {
var editableFields = [
'#edit_NUMERO_DRS',
'#edit_DATA_DRS',
'#edit_MESE_RIFERIMENTO',
'#edit_CAPITOLO_BILANCIO',
'#edit_CODICE_FINANZIARIO',
'#edit_ANNO_FINANZIARIO'
];
$(editableFields.join(',')).prop('readonly', hasUploadedFile);
$('#edit_MESE_RIFERIMENTO').data('datepickerLocked', hasUploadedFile);
$('#upload_decreto_liquidazione').toggleClass('d-none', !hasDrsFile);
$('#edit_FILEPATH_UPLOAD').prop('disabled', !hasDrsFile || hasUploadedFile).prop('required', hasDrsFile && !hasUploadedFile);
$('#btn-submit-mandato').prop('disabled', hasUploadedFile).toggleClass('d-none', hasUploadedFile).text('Genera il decreto di liquidazione');
$('#btn-upload-mandato').toggleClass('d-none', !hasDrsFile || hasUploadedFile).prop('disabled', !hasDrsFile || hasUploadedFile);
$('#btn-download-filepath').toggleClass('d-none', !hasUploadedFile).prop('disabled', !hasUploadedFile);
if (hasUploadedFile && $.trim(filePath || '') !== '') {
$('#edit_FILEPATH_LABEL').html('File caricato: <strong>' + filePath + '</strong>');
} else if (hasDrsFile) {
$('#edit_FILEPATH_LABEL').text('Carica il decreto firmato o definitivo da salvare a sistema.');
} else {
$('#edit_FILEPATH_LABEL').text('');
$('#edit_FILEPATH_UPLOAD').val('');
}
}
function downloadFilepath() {
var nomeFile = $.trim($('#edit_FILEPATH').val());
if (nomeFile === '') {
functionSwall('error', 'Nessun file caricato da scaricare.', '');
return;
}
var object = {
module: 'streamerFile',
action: 'download_mandati_pdf',
nomeFile: nomeFile
};
$.redirect(WS_CALL, object, "POST");
}
function presaInCarico(type) {
Swal.fire({
title: "Attenzione",
text: "Sicuro di volere procedere con la presa in carico delle richieste?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
if (result.value) {
var object = {
module: 'elenco_sconti',
action: 'presaincarico',
tipo: type,
data_estrazione: '<?= $dataElaborazione ?>'
};
$('#loader').show();
postdataClassic(WS_CALL, object, function (response) {
$('#loader').hide();
var risp = jQuery.parseJSON(response);
if (risp.esito === 1) {
Swal.fire({
type: 'success',
title: 'OK',
text: "Operazione completata con successo",
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK',
allowOutsideClick: false
}).then((result) => {
reloadPage();
});
} else {
functionSwall('error', risp.erroreDescrizione, '');
}
});
} else {
functionSwall('error', risp.erroreDescrizione, '');
}
});
}
function approva(lotto, action = 'approva') {
Swal.fire({
title: "Attenzione",
text: "Sicuro di volere procedere con l\'operazione richiesta?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
if (result.value) {
var object = {
module: 'elenco_sconti',
action: action,
lotto: lotto
};
$('#loader').show();
postdataClassic(WS_CALL, object, function (response) {
$('#loader').hide();
var risp = jQuery.parseJSON(response);
if (risp.esito === 1) {
Swal.fire({
type: 'success',
title: 'OK',
text: "Operazione completata con successo",
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK',
allowOutsideClick: false
}).then((result) => {
reloadPage();
});
}
});
} else {
functionSwall('error', risp.erroreDescrizione, '');
}
});
}
function eroga(lotto) {
Swal.fire({
title: "Attenzione",
text: "Sicuro di volere procedere con l\'erogazione delle richieste?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
if (result.value) {
var object = {
module: 'elenco_sconti',
action: 'eroga',
lotto: lotto
};
$('#loader').show();
postdataClassic(WS_CALL, object, function (response) {
$('#loader').hide();
var risp = jQuery.parseJSON(response);
if (risp.esito === 1) {
Swal.fire({
type: 'success',
title: 'OK',
text: "Operazione completata con successo",
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK',
allowOutsideClick: false
}).then((result) => {
reloadPage();
});
}
});
} else {
functionSwall('error', risp.erroreDescrizione, '');
}
});
}
function reloadPage() {
var object = {
dataElaborazione: '<?= $data_elaborazione->format('Y-m-d') ?>'
};
$.redirect(HTTP_PRIVATE_SECTION + "estrazioni.php", object, "POST");
}
function exportXls(lotto, stato) {
var object = {
module: 'streamerFile',
action: 'download_estrazioni',
lotto: lotto,
stato: stato
};
$.redirect(WS_CALL, object, "POST");
}
function exportXlsMandati(lotto, stato) {
var object = {
module: 'streamerFile',
action: 'download_mandati_xls',
lotto: lotto,
stato: stato
};
$.redirect(WS_CALL, object, "POST");
}
function exportAnagraficheBlocchi(lotto, stato) {
var object = {
module: 'streamerFile',
action: 'download_anagrafiche_xls', //download_mandati_xml
lotto: lotto,
stato: stato
};
$.redirect(WS_CALL, object, "POST");
}
function exportXmlMandati(lotto, stato) {
var object = {
module: 'streamerFile',
action: 'download_pagamenti_xls', //download_mandati_xml
lotto: lotto,
stato: stato
};
$.redirect(WS_CALL, object, "POST");
}
function exportDecretoGenerale(lotto, stato) {
var form = $('<form>', {
action: WS_CALL,
method: 'POST',
target: '_blank'
});
form.append($('<input>', {type: 'hidden', name: 'module', value: 'streamerFile'}));
form.append($('<input>', {type: 'hidden', name: 'action', value: 'download_decreto_generale'}));
form.append($('<input>', {type: 'hidden', name: 'lotto', value: lotto}));
form.append($('<input>', {type: 'hidden', name: 'stato', value: stato}));
$('body').append(form);
form.submit();
form.remove();
}
function exportDecreti(lotto, stato, omissis, priorita) {
var object = {
module: 'streamerFile',
action: 'exportDecreti', //download_mandati_xml
lotto: lotto,
stato: stato,
omissis: omissis,
priorita: priorita,
};
$.redirect(WS_CALL, object, "POST");
}
function exportAnagrafiche(lotto, stato, priorita) {
var object = {
module: 'streamerFile',
action: 'exportAnagrafiche', //download_mandati_xml
lotto: lotto,
stato: stato,
priorita: priorita,
};
$.redirect(WS_CALL, object, "POST");
}
function exportVISTA() {
var object = {
module: 'streamerFile',
action: 'downloadEstrazioneVistaXls', //download_mandati_xml
};
$.redirect(WS_CALL, object, "POST");
}
function generaMandato(modalita = 'generate') {
var form = document.getElementById('form-edit-mandato');
var isUploadDecreto = modalita === 'upload';
if (isUploadDecreto && $('#edit_FILEPATH_UPLOAD').get(0).files.length === 0) {
functionSwall('error', 'Selezionare il file del decreto di liquidazione da caricare.', '');
return;
}
var formData = new FormData(form);
formData.append('module', 'streamerFile');
formData.append('action', isUploadDecreto ? 'upload_decreto_liquidazione' : 'download_decreto_generale');
$("#loader").show();
$.ajax({
url: WS_CALL,
type: 'POST',
data: formData,
processData: false,
contentType: false,
beforeSend: function (data) {
},
success: function (response) {
//console.log(response);
var res = jQuery.parseJSON(response);
var risposta = res.esito;
var nomeFile = res.nomeFile;
var descrizione_errore = res.descrizioneErrore || res.erroreDescrizione;
$("#loader").hide();
$('#editMandato').modal('toggle');
if (nomeFile != '' && risposta) {
var successText = isUploadDecreto ? 'Decreto di liquidazione caricato con successo' : 'Decreto di liquidazione generato con successo';
var confirmButtonText = isUploadDecreto ? 'OK' : 'Scarica il PDF';
Swal.fire({
type: 'success',
title: 'OK',
text: successText,
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: confirmButtonText,
allowOutsideClick: false
}).then((result) => {
if (isUploadDecreto) {
reloadPage();
} else {
var object = {
module: 'streamerFile',
action: 'download_drs_pdf',
nomeFile: nomeFile
};
$.redirect(WS_CALL, object, "POST");
setTimeout(reloadPage, 1000);
}
});
} else {
$('#loader').hide();
functionSwall('error', descrizione_errore, "");
}
},
error: function (xhr, status, error) {
$('#loader').hide();
alert("An AJAX error occured: " + status + "\nError: " + error);
console.log(xhr);
}
});
}
</script>
</body>
</html>