1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 06:55:05 +01:00
Rimozione dei controlli sui totali per le scadenze generiche.
This commit is contained in:
Thomas Zilio 2020-02-23 14:42:25 +01:00
parent 7d00a67d1a
commit d1b8ba9c2b

View File

@ -13,7 +13,7 @@ echo '
<input type="hidden" name="op" value="update"> <input type="hidden" name="op" value="update">
<input type="hidden" name="backto" value="record-edit"> <input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_record" value="'.$id_record.'"> <input type="hidden" name="id_record" value="'.$id_record.'">
<input type="hidden" name="tipo" value="'.$record['tipo'].'"> <input type="hidden" name="tipo" value="'.$record['tipo'].'">
<input type="hidden" name="descrizione" value="'.$record['descrizione'].'"> <input type="hidden" name="descrizione" value="'.$record['descrizione'].'">
<input type="hidden" name="iddocumento" value="'.$record['iddocumento'].'"> <input type="hidden" name="iddocumento" value="'.$record['iddocumento'].'">
@ -103,14 +103,13 @@ echo '
<tbody id="scadenze">'; <tbody id="scadenze">';
$totale_da_pagare = 0; // Scelgo la query in base alla scadenza
$totale_pagato = 0;
// Scelgo la query in base al segmento
if (!empty($documento)) { if (!empty($documento)) {
$rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC'); $rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC');
$totale_da_pagare = $documento->netto;
} else { } else {
$rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record).' ORDER BY scadenza ASC'); $rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record).' ORDER BY scadenza ASC');
$totale_da_pagare = sum(array_column($rs, 'da_pagare'));
} }
foreach ($rs as $i => $scadenza) { foreach ($rs as $i => $scadenza) {
@ -146,18 +145,6 @@ foreach ($rs as $i => $scadenza) {
</tr>'; </tr>';
} }
$totale_da_pagare = $documento->netto;
$totale_pagato = sum(array_column($rs, 'pagato'));
if ($totale_da_pagare == $totale_pagato) {
echo '
<script>
$(document).ready(function(){
$("#pulsanti").children().find("a:nth-child(2)").attr("disabled", true).addClass("disabled");
})
</script>';
}
echo ' echo '
</tbody> </tbody>
<tfoot> <tfoot>
@ -178,7 +165,7 @@ echo '
<div class="clearfix"></div> <div class="clearfix"></div>
<br> <br>
<div class="alert alert-error hide" id="totale"><?php echo tr('Il totale da pagare deve essere pari a _MONEY_', [ <div class="alert alert-error hide" id="totale"><?php echo tr('Il totale da pagare deve essere pari a _MONEY_', [
'_MONEY_' => '<b>'.moneyFormat($totale_da_pagare).'</b>', '_MONEY_' => '<b>'.moneyFormat($totale_da_pagare).'</b>',
]); ?>.<br><?php echo tr('Differenza di _TOT_ _CURRENCY_', [ ]); ?>.<br><?php echo tr('Differenza di _TOT_ _CURRENCY_', [
@ -197,32 +184,31 @@ echo '
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} {( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
<?php <?php
if ($records[0]['iddocumento'] == 0) { if (empty($documento)) {
?> echo '
<a class="btn btn-danger ask" data-backto="record-list"> <a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?> <i class="fa fa-trash"></i> '.tr('Elimina').'
</a> </a>';
<?php }
}
echo ' echo '
<table class="hide"> <table class="hide">
<tbody id="scadenza-template"> <tbody id="scadenza-template">
<tr class="danger"> <tr class="danger">
<input type="hidden" name="id_scadenza[-id-]" value=""> <input type="hidden" name="id_scadenza[-id-]" value="">
<td align="center"> <td align="center">
{[ "type": "date", "name": "scadenza[-id-]" ]} {[ "type": "date", "name": "scadenza[-id-]" ]}
</td> </td>
<td align="right"> <td align="right">
{[ "type": "number", "name": "da_pagare[-id-]", "decimals": 2, "onchange": "controlloTotale()" ]} {[ "type": "number", "name": "da_pagare[-id-]", "decimals": 2, "onchange": "controlloTotale()" ]}
</td> </td>
<td align="right"> <td align="right">
{[ "type": "number", "name": "pagato[-id-]", "decimals": 2 ]} {[ "type": "number", "name": "pagato[-id-]", "decimals": 2 ]}
</td> </td>
<td align="center"> <td align="center">
{[ "type": "date", "name": "data_concordata[-id-]" ]} {[ "type": "date", "name": "data_concordata[-id-]" ]}
</td> </td>
@ -234,36 +220,36 @@ echo '
var i = '.$i.'; var i = '.$i.';
$(document).on("click", "#add-scadenza", function(){ $(document).on("click", "#add-scadenza", function(){
cleanup_inputs(); cleanup_inputs();
i++; i++;
var text = replaceAll($("#scadenza-template").html(), "-id-", "" + i); var text = replaceAll($("#scadenza-template").html(), "-id-", "" + i);
$("#scadenze").append(text); $("#scadenze").append(text);
restart_inputs(); restart_inputs();
}); });
</script>'; </script>';
?> // Abilitazione dei controlli solo per Scadenze collegate a documenti
if (!empty($documento)) {
echo '
<script> <script>
globals.cifre_decimali = 2; globals.cifre_decimali = 2;
$(document).ready(function(){ $(document).ready(function(){
controlloTotale(); controlloTotale();';
<?php if ($dir == 'uscita') {
if ($dir == 'uscita') { echo '
echo '
$("#email-button").remove();'; $("#email-button").remove();';
} }
?> echo '
}); });
function controlloTotale() { function controlloTotale() {
totale_da_pagare = $('#totale_da_pagare').val().toEnglish(); totale_da_pagare = $("#totale_da_pagare").val().toEnglish();
totale_utente = 0; totale_utente = 0;
$('input[name*=da_pagare]').each(function() { $("input[name*=da_pagare]").each(function() {
totale_utente += $(this).val().toEnglish(); totale_utente += $(this).val().toEnglish();
@ -276,18 +262,18 @@ echo '
totale_utente = Math.round(totale_utente * 100) / 100; totale_utente = Math.round(totale_utente * 100) / 100;
totale_da_pagare = Math.round(totale_da_pagare * 100) / 100; totale_da_pagare = Math.round(totale_da_pagare * 100) / 100;
diff = Math.abs(totale_da_pagare) - Math.abs(totale_utente); diff = Math.abs(totale_da_pagare) - Math.abs(totale_utente);
if (diff == 0) { if (diff == 0) {
$('#btn-saves').removeClass('hide'); $("#save").removeClass("hide");
$('#totale').addClass('hide'); $("#totale").addClass("hide");
} else { } else {
$('#btn-saves').addClass('hide'); $("#save").addClass("hide");
$('#totale').removeClass('hide'); $("#totale").removeClass("hide");
} }
$('#diff').html(diff.toLocale()); $("#diff").html(diff.toLocale());
$('#totale_utente').html(totale_utente.toLocale()); $("#totale_utente").html(totale_utente.toLocale());
} }
</script> </script>';
}