openstamanager/modules/partitario/dettagli_conto.php

116 lines
3.4 KiB
PHP
Raw Normal View History

2019-07-08 15:48:48 +02:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* 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/>.
*/
2019-07-08 15:48:48 +02:00
include_once __DIR__.'/../../core.php';
$prima_nota = Modules::get('Prima nota');
2019-07-08 15:48:48 +02:00
$id_conto = get('id_conto');
// Calcolo totale conto da elenco movimenti di questo conto
$query = 'SELECT co_movimenti.*,
2021-07-23 17:27:31 +02:00
SUM(totale) AS totale,
dir FROM co_movimenti
LEFT OUTER JOIN co_documenti ON co_movimenti.iddocumento = co_documenti.id
LEFT OUTER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id
WHERE co_movimenti.idconto='.prepare($id_conto).' AND
co_movimenti.data >= '.prepare($_SESSION['period_start']).' AND
co_movimenti.data <= '.prepare($_SESSION['period_end']).'
GROUP BY co_movimenti.idmastrino
ORDER BY co_movimenti.data ASC, co_movimenti.descrizione';
2019-07-08 15:48:48 +02:00
$movimenti = $dbo->fetchArray($query);
if (!empty($movimenti)) {
echo '
<table class="table table-bordered table-hover table-condensed table-striped">
<tr>
<th>'.tr('Causale').'</th>
<th width="100">'.tr('Data').'</th>
<th width="100">'.tr('Dare').'</th>
<th width="100">'.tr('Avere').'</th>
<th width="100">'.tr('Scalare').'</th>
2019-07-08 15:48:48 +02:00
</tr>';
$scalare = 0;
2019-07-08 15:48:48 +02:00
// Elenco righe del partitario
foreach ($movimenti as $movimento) {
echo '
<tr>
<td>';
$modulo_fattura = ($movimento['dir'] == 'entrata') ? Modules::get('Fatture di vendita') : Modules::get('Fatture di acquisto');
2019-07-08 15:48:48 +02:00
if (!empty($movimento['primanota'])) {
echo Modules::link($prima_nota->id, $movimento['idmastrino'], $movimento['descrizione']);
2019-07-08 15:48:48 +02:00
} else {
echo Modules::link($modulo_fattura->id, $movimento['iddocumento'], $movimento['descrizione']);
2019-07-08 15:48:48 +02:00
}
2019-07-08 17:11:48 +02:00
echo '
</td>';
2019-07-08 15:48:48 +02:00
// Data
echo '
<td>
'.dateFormat($movimento['data']).'
</td>';
// Dare
if ($movimento['totale'] > 0) {
echo '
<td class="text-right">
'.moneyFormat(abs($movimento['totale']), 2).'
</td>
<td></td>';
}
// Avere
else {
echo '
<td></td>
<td class="text-right">
'.moneyFormat(abs($movimento['totale']), 2).'
</td>';
}
$scalare += $movimento['totale'];
echo '
<td class="text-right">
'.moneyFormat($scalare, 2).'
</td>';
2019-07-08 15:48:48 +02:00
echo '
</tr>';
}
echo '
</table>
<script>
function open_movimento(id_mastrino, id_module){
launch_modal("'.tr('Dettagli movimento').'", "'.$structure->fileurl('dettagli_movimento.php').'?id_mastrino=" + id_mastrino + "&id_module=" + id_module);
2019-07-08 15:48:48 +02:00
}
</script>';
} else {
echo '
2020-07-31 14:57:23 +02:00
<span>'.tr('Nessun movimento presente').'</span>';
2019-07-08 15:48:48 +02:00
}