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.
 
 
 

624 righe
36 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>';
$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" 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">
<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()" novalidate>
<input type="hidden" id="action" name="action" value="saveFile" />
<div class="modal-body">
<div class="form-group">
<label for="LOTTO">Lotto</label>
<input type="text" readonly="readonly" class="form-control" id="edit_LOTTO" name="LOTTO"/>
</div>
<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 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 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 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="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
<button class="btn btn-success" type="submit" name="save">Genera 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'; ?>
<script type="text/javascript">
$(document).ready(function () {
});
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 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() {
var form = document.getElementById('form-edit-mandato');
var formData = new FormData(form);
$("#loader").show();
$.ajax({
url: WS_CALL + '?module=generaMandato',
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;
$("#loader").hide();
$('#editMandato').modal('toggle');
if (nomeFile != '' && risposta) {
Swal.fire({
type: 'success',
title: 'OK',
text: "Decreto di liquidazione generato con successo",
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'Scarica il PDF',
allowOutsideClick: false
}).then((result) => {
var object = {
module: 'streamerFile',
action: 'download_mandati_pdf', //download_mandati_xml
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>