Nuova stampa scadenzario in stampe contabili con filtri
This commit is contained in:
parent
6dc29b3392
commit
d85de431ee
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||
* Copyright (C) DevCode s.r.l.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (empty($dbo->fetchArray('SELECT * FROM co_scadenziario'))) {
|
||||
$class = 'muted';
|
||||
$disabled = 'disabled';
|
||||
} else {
|
||||
$class = 'primary';
|
||||
$disabled = '';
|
||||
}
|
||||
|
||||
?><br>
|
||||
|
||||
<!-- STAMPA TOTALE -->
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
|
||||
<button type="button" onclick="window.open('<?php echo Prints::getHref('Scadenzario', null, null); ?>');" <?php echo $disabled; ?> class="btn btn-<?php echo $class; ?> btn-block btn-lg text-center"><i class="fa fa-print"></i> <?php echo tr('Stampa scadenzario'); ?></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
|
@ -104,4 +104,33 @@ echo '
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.tr('Scadenzario').'</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">';
|
||||
|
||||
if (empty($dbo->fetchArray('SELECT * FROM co_scadenziario'))) {
|
||||
$class = 'muted';
|
||||
$disabled = 'disabled';
|
||||
} else {
|
||||
$class = 'primary';
|
||||
$disabled = '';
|
||||
}
|
||||
|
||||
echo ' <button type="button" '.$disabled.' class="btn btn-'.$class.' col-md-5" data-toggle="modal" data-title="'.tr('Stampa scadenzario').'" data-href="'.base_path().'/modules/stampe_contabili/stampa_scadenzario.php" >
|
||||
<i class="fa fa-print fa-2x"></i><br>'.tr('Stampa<br>scadenzario').'
|
||||
</button>';
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/*
|
||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||
* Copyright (C) DevCode s.r.l.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
// Trovo id_print della stampa
|
||||
$link = Prints::getHref('Scadenzario', null);
|
||||
|
||||
echo '
|
||||
<form action="" method="post" onsubmit="if($(this).parsley().validate()) { return avvia_stampa(); }" >
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "'.tr('Data inizio').'", "name": "data_inizio", "value": "" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "'.tr('Data fine').'", "name": "data_fine", "value": "" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "checkbox", "label": "'.tr('Includi scadenze pagate').'", "name": "is_pagata" ]}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "checkbox", "label": "'.tr('Includi solo Ri.Ba').'", "name": "is_riba" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "checkbox", "label": "'.tr('Includi solo scadenze Clienti').'", "name": "is_cliente" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "checkbox", "label": "'.tr('Includi solo scadenze Fornitori').'", "name": "is_fornitore" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fa fa-print"></i> '.tr('Stampa scadenzario').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
function avvia_stampa (){
|
||||
var data_inizio = $("#data_inizio").val();
|
||||
var data_fine = $("#data_fine").val();
|
||||
var is_pagata = $("#is_pagata").is(":checked");
|
||||
var is_riba = $("#is_riba").is(":checked");
|
||||
var is_cliente = $("#is_cliente").is(":checked");
|
||||
var is_fornitore = $("#is_fornitore").is(":checked");
|
||||
|
||||
window.open("'.$link.'&data_inizio="+data_inizio+"&data_fine="+data_fine+"&is_pagata="+is_pagata+"&is_riba="+is_riba+"&is_cliente="+is_cliente+"&is_fornitore="+is_fornitore, "_blank");
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#is_cliente").change(function() {
|
||||
if($(this).is(":checked")) {
|
||||
$("#is_fornitore").prop("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
$("#is_fornitore").change(function() {
|
||||
if($(this).is(":checked")) {
|
||||
$("#is_cliente").prop("checked", false);
|
||||
}
|
||||
});
|
||||
</script>';
|
|
@ -21,9 +21,6 @@ include_once __DIR__.'/../../core.php';
|
|||
|
||||
use Modules\Fatture\Fattura;
|
||||
|
||||
$date_start = $_SESSION['period_start'];
|
||||
$date_end = $_SESSION['period_end'];
|
||||
|
||||
$module = Modules::get('Scadenzario');
|
||||
$id_module = $module['id'];
|
||||
|
||||
|
@ -32,24 +29,28 @@ $total = Util\Query::readQuery($module);
|
|||
// Lettura parametri modulo
|
||||
$module_query = $total['query'];
|
||||
|
||||
$search_filters = [];
|
||||
if(!empty(get('data_inizio')) AND !empty(get('data_fine'))){
|
||||
$module_query = str_replace('1=1', '1=1 AND `data` BETWEEN "'.get('data_inizio').'" AND "'.get('data_fine').'"', $module_query);
|
||||
|
||||
if (is_array($_SESSION['module_'.$id_module])) {
|
||||
foreach ($_SESSION['module_'.$id_module] as $field => $value) {
|
||||
if (!empty($value) && string_starts_with($field, 'search_')) {
|
||||
$field_name = str_replace('search_', '', $field);
|
||||
$field_name = str_replace('__', ' ', $field_name);
|
||||
$field_name = str_replace('-', ' ', $field_name);
|
||||
array_push($search_filters, '`'.$field_name.'` LIKE "%'.$value.'%"');
|
||||
}
|
||||
}
|
||||
$date_start = get('data_inizio');
|
||||
$date_end = get('data_fine');
|
||||
}
|
||||
|
||||
if (!empty($search_filters)) {
|
||||
$module_query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $module_query);
|
||||
if(get('is_pagata')=='true'){
|
||||
$module_query = str_replace('AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`) ', '', $module_query);
|
||||
}
|
||||
|
||||
$module_query = str_replace('1=1', '1=1 AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`) ', $module_query);
|
||||
if(get('is_riba')=='true'){
|
||||
$module_query = str_replace('1=1', '1=1 AND co_pagamenti.codice_modalita_pagamento_fe="MP12"', $module_query);
|
||||
}
|
||||
|
||||
if(get('is_cliente')=='true'){
|
||||
$module_query = str_replace('1=1', '1=1 AND co_tipidocumento.dir="entrata"', $module_query);
|
||||
}
|
||||
|
||||
if(get('is_fornitore')=='true'){
|
||||
$module_query = str_replace('1=1', '1=1 AND co_tipidocumento.dir="uscita"', $module_query);
|
||||
}
|
||||
|
||||
// Scelgo la query in base alla scadenza
|
||||
if (isset($id_record)) {
|
||||
|
@ -62,8 +63,5 @@ if (isset($id_record)) {
|
|||
}
|
||||
}
|
||||
|
||||
// Filtri derivanti dai permessi (eventuali)
|
||||
$module_query = Modules::replaceAdditionals($id_module, $module_query);
|
||||
|
||||
// Scadenze
|
||||
$records = $dbo->fetchArray($module_query);
|
||||
|
|
|
@ -24,13 +24,17 @@ if (isset($id_record)) {
|
|||
<h4><b>'.tr('Scadenza _ANAG_', [
|
||||
'_ANAG_' => $records[0]['Anagrafica'],
|
||||
], ['upper' => true]).'</b></h4>';
|
||||
} else {
|
||||
} else if(!empty($date_start) AND !empty($date_end)) {
|
||||
echo '
|
||||
<h4><b>'.tr('Scadenze dal _START_ al _END_', [
|
||||
'_START_' => Translator::dateToLocale($date_start),
|
||||
'_END_' => Translator::dateToLocale($date_end),
|
||||
], ['upper' => true]).'</b>
|
||||
</h4>';
|
||||
}else{
|
||||
echo '
|
||||
<h4><b>'.tr('Scadenze').'</b>
|
||||
</h4>';
|
||||
}
|
||||
|
||||
echo '
|
||||
|
|
Loading…
Reference in New Issue