2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2019-09-28 11:12:11 +02:00
|
|
|
use Modules\Fatture\Fattura;
|
|
|
|
|
|
|
|
$documento = Fattura::find($record['iddocumento']);
|
|
|
|
$dir = $documento->direzione;
|
|
|
|
$numero = $documento->numero_esterno ?: $documento->numero;
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
|
|
|
<form action="" method="post" id="edit-form">
|
|
|
|
<input type="hidden" name="op" value="update">
|
|
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
|
|
<input type="hidden" name="id_record" value="'.$id_record.'">
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<input type="hidden" name="tipo" value="'.$record['tipo'].'">
|
|
|
|
<input type="hidden" name="descrizione" value="'.$record['descrizione'].'">
|
|
|
|
<input type="hidden" name="iddocumento" value="'.$record['iddocumento'].'">
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
|
|
<div class="panel-heading">
|
2019-07-25 18:05:47 +02:00
|
|
|
<h3 class="panel-title">
|
|
|
|
'.tr('Dettagli scadenza').'
|
2019-09-28 11:12:11 +02:00
|
|
|
<button type="button" class="btn btn-xs btn-info pull-right '.(empty($documento) ? 'disabled' : '').'" id="add-scadenza" '.(empty($documento) ? 'disabled' : '').'>
|
2019-07-25 18:05:47 +02:00
|
|
|
<i class="fa fa-plus"></i> '.tr('Aggiungi scadenza').'
|
|
|
|
</button>
|
|
|
|
</h3>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="row">
|
|
|
|
|
|
|
|
<!-- Info scadenza -->
|
2020-01-14 22:18:52 +01:00
|
|
|
<div class="col-md-6">';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-09-28 11:12:11 +02:00
|
|
|
if (!empty($documento)) {
|
|
|
|
echo '
|
|
|
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
2017-08-04 16:28:16 +02:00
|
|
|
<tr>
|
2019-09-28 11:12:11 +02:00
|
|
|
<th width="120">'.($dir == 'entrata' ? tr('Cliente') : tr('Fornitore')).':</th>
|
2017-08-04 16:28:16 +02:00
|
|
|
<td>
|
2019-09-28 11:12:11 +02:00
|
|
|
'.Modules::link('Anagrafiche', $documento->anagrafica->id, $documento->anagrafica->ragione_sociale).'
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>
|
2020-01-14 22:18:52 +01:00
|
|
|
</tr>
|
|
|
|
|
2019-04-19 17:29:54 +02:00
|
|
|
<tr>
|
|
|
|
<th>'.tr('Documento').':</th>
|
2019-09-28 11:12:11 +02:00
|
|
|
<td>'.$documento->tipo->descrizione.'</td>
|
2020-01-14 22:18:52 +01:00
|
|
|
</tr>
|
|
|
|
|
2019-04-19 17:29:54 +02:00
|
|
|
<tr>
|
|
|
|
<th>'.tr('Numero').':</th>
|
|
|
|
<td>'.$numero.'</td>
|
2020-01-14 22:18:52 +01:00
|
|
|
</tr>
|
|
|
|
|
2019-04-19 17:29:54 +02:00
|
|
|
<tr>
|
|
|
|
<th>'.tr('Data').':</th>
|
2019-09-28 11:12:11 +02:00
|
|
|
<td>'.Translator::dateToLocale($documento->data).'</td>
|
|
|
|
</tr>
|
2020-01-14 22:18:52 +01:00
|
|
|
|
|
|
|
<tr>
|
2020-02-05 12:45:15 +01:00
|
|
|
<th>'.tr('Netto a pagare').':</th>
|
|
|
|
<td>'.moneyFormat($documento->netto).'</td>
|
2020-01-14 22:18:52 +01:00
|
|
|
</tr>
|
|
|
|
|
2020-01-28 14:20:14 +01:00
|
|
|
<tr>
|
|
|
|
<th>'.tr('Note').':</th>
|
|
|
|
<td>
|
|
|
|
{[ "type": "textarea", "name": "note", "value": "'.$record['note'].'" ]}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
2019-09-28 11:12:11 +02:00
|
|
|
</table>
|
|
|
|
|
|
|
|
'.Modules::link($documento->module, $record['iddocumento'], '<i class="fa fa-folder-open"></i> '.tr('Apri documento'), null, 'class="btn btn-primary"');
|
2019-05-04 00:32:28 +02:00
|
|
|
} else {
|
2019-09-28 11:12:11 +02:00
|
|
|
$scadenza = $dbo->fetchOne('SELECT * FROM co_scadenziario WHERE id='.prepare($id_record));
|
|
|
|
|
|
|
|
echo input([
|
|
|
|
'type' => 'textarea',
|
|
|
|
'label' => tr('Descrizione'),
|
|
|
|
'name' => 'descrizione',
|
|
|
|
'required' => 1,
|
|
|
|
'value' => $scadenza['descrizione'],
|
|
|
|
]);
|
2019-04-19 17:29:54 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Elenco scadenze -->
|
2020-01-14 22:18:52 +01:00
|
|
|
<div class="col-md-6">
|
2017-08-04 16:28:16 +02:00
|
|
|
<table class="table table-hover table-condensed table-bordered">
|
2019-07-25 18:05:47 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="150">'.tr('Data').'</th>
|
|
|
|
<th width="150">'.tr('Importo').'</th>
|
|
|
|
<th width="150">'.tr('Pagato').'</th>
|
|
|
|
<th width="150">'.tr('Data concordata').'</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2019-09-28 11:12:11 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<tbody id="scadenze">';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-02-23 14:42:25 +01:00
|
|
|
// Scelgo la query in base alla scadenza
|
2019-09-28 11:12:11 +02:00
|
|
|
if (!empty($documento)) {
|
|
|
|
$rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC');
|
2020-02-23 14:42:25 +01:00
|
|
|
$totale_da_pagare = $documento->netto;
|
2019-05-04 00:32:28 +02:00
|
|
|
} else {
|
2019-09-28 11:12:11 +02:00
|
|
|
$rs = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record).' ORDER BY scadenza ASC');
|
2020-02-23 14:42:25 +01:00
|
|
|
$totale_da_pagare = sum(array_column($rs, 'da_pagare'));
|
2019-04-19 17:29:54 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-09-28 11:12:11 +02:00
|
|
|
foreach ($rs as $i => $scadenza) {
|
|
|
|
if ($scadenza['da_pagare'] == $scadenza['pagato']) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$class = 'success';
|
2019-09-28 11:12:11 +02:00
|
|
|
} elseif (abs($scadenza['pagato']) == 0) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$class = 'danger';
|
2019-09-28 11:12:11 +02:00
|
|
|
} elseif (abs($scadenza['pagato']) <= abs($scadenza['da_pagare'])) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$class = 'warning';
|
|
|
|
} else {
|
|
|
|
$class = 'danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr class="'.$class.'">
|
2019-09-28 11:12:11 +02:00
|
|
|
<input type="hidden" name="id_scadenza['.$i.']" value="'.$scadenza['id'].'">
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
<td align="center">
|
2019-09-28 11:12:11 +02:00
|
|
|
{[ "type": "date", "name": "scadenza['.$i.']", "value": "'.$scadenza['scadenza'].'" ]}
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td align="right">
|
2019-09-28 11:12:11 +02:00
|
|
|
{[ "type": "number", "name": "da_pagare['.$i.']", "decimals": 2, "value": "'.Translator::numberToLocale($scadenza['da_pagare'], 2).'", "onchange": "controlloTotale()" ]}
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td align="right">
|
2019-09-28 11:12:11 +02:00
|
|
|
{[ "type": "number", "name": "pagato['.$i.']", "decimals": 2, "value": "'.Translator::numberToLocale($scadenza['pagato']).'" ]}
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>
|
2019-09-28 11:12:11 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<td align="center">
|
2019-09-28 11:12:11 +02:00
|
|
|
{[ "type": "date", "name": "data_concordata['.$i.']", "value": "'.$scadenza['data_concordata'].'" ]}
|
2019-07-25 18:05:47 +02:00
|
|
|
</td>
|
2017-08-04 16:28:16 +02:00
|
|
|
</tr>';
|
|
|
|
}
|
2019-07-25 18:05:47 +02:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2019-07-25 18:05:47 +02:00
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<td align="right"><b>'.tr('Totale').'</b></td>
|
|
|
|
<td align="right" id="totale_utente">'.Translator::numberToLocale($totale_da_pagare).'</td>
|
|
|
|
<td align="right"></td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
</table>
|
2019-04-11 16:04:08 +02:00
|
|
|
|
|
|
|
<div class='pull-right'>
|
2019-10-29 16:29:59 +01:00
|
|
|
<a onclick="launch_modal( 'Registra contabile pagamento', '<?php echo $rootdir; ?>/add.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>&<?php echo !empty($record['iddocumento']) ? 'id_documenti='.$record['iddocumento'].'&single=1' : 'id_scadenze='.$id_record; ?>');" class="btn btn-sm btn-primary"><i class="fa fa-euro"></i> <?php echo tr('Registra contabile pagamento...'); ?></a>
|
2019-04-11 16:04:08 +02:00
|
|
|
</div>
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2018-10-19 16:19:49 +02:00
|
|
|
<div class="clearfix"></div>
|
2020-01-14 22:18:52 +01:00
|
|
|
<br>
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-04-13 02:56:39 +02:00
|
|
|
<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>',
|
2019-04-13 00:09:48 +02:00
|
|
|
]); ?>.<br><?php echo tr('Differenza di _TOT_ _CURRENCY_', [
|
|
|
|
'_TOT_' => '<span id="diff"></span>',
|
|
|
|
'_CURRENCY_' => currency(),
|
|
|
|
]); ?>.
|
2018-10-19 16:19:49 +02:00
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-05-02 10:03:57 +02:00
|
|
|
<input type="hidden" id="totale_da_pagare" value="<?php echo Translator::numberToLocale($totale_da_pagare, 2); ?>">
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
2020-05-26 11:31:53 +02:00
|
|
|
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
|
|
|
|
2019-02-21 12:24:57 +01:00
|
|
|
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-04-19 17:29:54 +02:00
|
|
|
<?php
|
2020-02-23 14:42:25 +01:00
|
|
|
if (empty($documento)) {
|
2020-02-24 12:21:47 +01:00
|
|
|
echo '
|
2019-04-19 17:29:54 +02:00
|
|
|
<a class="btn btn-danger ask" data-backto="record-list">
|
2020-02-23 14:42:25 +01:00
|
|
|
<i class="fa fa-trash"></i> '.tr('Elimina').'
|
|
|
|
</a>';
|
2020-02-24 12:21:47 +01:00
|
|
|
}
|
2019-07-25 18:05:47 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<table class="hide">
|
|
|
|
<tbody id="scadenza-template">
|
|
|
|
<tr class="danger">
|
2019-09-28 11:12:11 +02:00
|
|
|
<input type="hidden" name="id_scadenza[-id-]" value="">
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<td align="center">
|
|
|
|
{[ "type": "date", "name": "scadenza[-id-]" ]}
|
|
|
|
</td>
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<td align="right">
|
|
|
|
{[ "type": "number", "name": "da_pagare[-id-]", "decimals": 2, "onchange": "controlloTotale()" ]}
|
|
|
|
</td>
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<td align="right">
|
|
|
|
{[ "type": "number", "name": "pagato[-id-]", "decimals": 2 ]}
|
|
|
|
</td>
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
<td align="center">
|
|
|
|
{[ "type": "date", "name": "data_concordata[-id-]" ]}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var i = '.$i.';
|
|
|
|
$(document).on("click", "#add-scadenza", function(){
|
2019-07-26 17:40:52 +02:00
|
|
|
cleanup_inputs();
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-26 17:40:52 +02:00
|
|
|
i++;
|
2019-07-25 18:05:47 +02:00
|
|
|
var text = replaceAll($("#scadenza-template").html(), "-id-", "" + i);
|
2020-02-23 14:42:25 +01:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
$("#scadenze").append(text);
|
2019-07-26 17:40:52 +02:00
|
|
|
restart_inputs();
|
2019-07-25 18:05:47 +02:00
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
|
2020-02-23 14:42:25 +01:00
|
|
|
// Abilitazione dei controlli solo per Scadenze collegate a documenti
|
|
|
|
if (!empty($documento)) {
|
|
|
|
echo '
|
2017-08-04 16:28:16 +02:00
|
|
|
<script>
|
2019-05-02 10:03:57 +02:00
|
|
|
globals.cifre_decimali = 2;
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2019-05-24 20:27:43 +02:00
|
|
|
$(document).ready(function(){
|
2020-02-23 14:42:25 +01:00
|
|
|
controlloTotale();';
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2020-02-23 14:42:25 +01:00
|
|
|
if ($dir == 'uscita') {
|
|
|
|
echo '
|
2019-05-24 20:27:43 +02:00
|
|
|
$("#email-button").remove();';
|
2020-02-23 14:42:25 +01:00
|
|
|
}
|
|
|
|
echo '
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
function controlloTotale() {
|
2020-02-23 14:42:25 +01:00
|
|
|
totale_da_pagare = $("#totale_da_pagare").val().toEnglish();
|
2019-07-25 18:05:47 +02:00
|
|
|
totale_utente = 0;
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-02-23 14:42:25 +01:00
|
|
|
$("input[name*=da_pagare]").each(function() {
|
2019-07-25 18:05:47 +02:00
|
|
|
|
|
|
|
totale_utente += $(this).val().toEnglish();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
});
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
if (isNaN(totale_utente)) {
|
|
|
|
totale_utente = 0;
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
totale_utente = Math.round(totale_utente * 100) / 100;
|
|
|
|
totale_da_pagare = Math.round(totale_da_pagare * 100) / 100;
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
diff = Math.abs(totale_da_pagare) - Math.abs(totale_utente);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-25 18:05:47 +02:00
|
|
|
if (diff == 0) {
|
2020-02-23 14:42:25 +01:00
|
|
|
$("#save").removeClass("hide");
|
|
|
|
$("#totale").addClass("hide");
|
2019-07-25 18:05:47 +02:00
|
|
|
} else {
|
2020-02-23 14:42:25 +01:00
|
|
|
$("#save").addClass("hide");
|
|
|
|
$("#totale").removeClass("hide");
|
2019-07-25 18:05:47 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-02-23 14:42:25 +01:00
|
|
|
$("#diff").html(diff.toLocale());
|
|
|
|
$("#totale_utente").html(totale_utente.toLocale());
|
2019-07-25 18:05:47 +02:00
|
|
|
}
|
2020-02-23 14:42:25 +01:00
|
|
|
</script>';
|
|
|
|
}
|