Migrazione stampe contabili su mpdf

This commit is contained in:
MatteoPistorello 2020-10-09 12:03:09 +02:00
parent 4efe0af5f5
commit 53494ec4e1
11 changed files with 302 additions and 417 deletions

View File

@ -0,0 +1,81 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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';
$dare = 0;
$avere = 0;
for ($i = 0; $i < sizeof($records); ++$i) {
if ($records[$i]['totale'] >= 0) {
$dare += $records[$i]['totale'];
} else {
$avere += $records[$i]['totale'];
}
}
if (get('lev') == '2' || get('lev') == '3') {
echo '
<tr>
<th></th>
<th>SALDO FINALE</th>
<th class="text-right">'.moneyFormat(abs($dare)).'</th>
<th class="text-right">'.moneyFormat(abs($avere)).'</th>
</tr>';
} elseif(get('lev') == '1'){
$pareggio_dare = abs($dare);
$pareggio_avere = abs($avere);
echo '</table>
<table class="table table-striped table-bordered">
<tr>
<th width="25%">TOTALE ATTIVITÀ</th>
<th width="25%" class="text-right">'.moneyFormat(abs($dare)).'</th>
<th width="25%">PASSIVITÀ</th>
<th width="25%" class="text-right">'.moneyFormat(abs($avere)).'</th>
</tr>
<tr>';
if($risultato['totale'] <= 0){
echo '
<th></th>
<th></th>
<th>UTILE</th>
<th class="text-right">'.moneyFormat(abs($risultato['totale'])).'</th>
</tr>';
$pareggio_avere += abs($risultato['totale']);
} else{
echo '
<th>PERDITA</th>
<th class="text-right">'.moneyFormat(abs($risultato['totale'])).'</th>
<th></th>
<th></th>
</tr>';
$pareggio_dare += abs($risultato['totale']);
}
echo '
<tr>
<th>TOTALE A PAREGGIO</th>
<th class="text-right">'.moneyFormat(abs($pareggio_dare)).'</th>
<th>TOTALE A PAREGGIO</th>
<th class="text-right">'.moneyFormat(abs($pareggio_avere)).'</th>
</tr>
</table>';
}
echo '</tbody></table>';

View File

@ -0,0 +1,34 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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/>.
*/
echo '
<table style="color:#aaa; font-size:10px;">
<tr>
<td align="left" style="width:97mm;">
'.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).'
</td>
<td class="text-right" style="width:97mm;">
'.tr('Pagina _PAGE_ di _TOTAL_', [
'_PAGE_' => '{PAGENO}',
'_TOTAL_' => '{nb}',
]).'
</td>
</tr>
</table>';

View File

@ -0,0 +1,42 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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/>.
*/
/**
* Header di default.
* I contenuti di questo file vengono utilizzati per generare l'header delle stampe nel caso non esista un file header.php all'interno della stampa.
*
* Per modificare l'header della stampa basta aggiungere un file header.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/header.php).
*
* La personalizzazione specifica dell'header deve comunque seguire lo standard della cartella custom: anche se il file header.php non esiste nella stampa originaria, se si vuole personalizzare l'header bisogna crearlo all'interno della cartella custom.
*/
echo'
<h5 style="border-bottom:1px solid #777; display:block;">
<div class="col-xs-5">STAMPA MASTRINO <small>'.Translator::dateToLocale($date_start).' - '.Translator::dateTolocale($date_end).'</small></div>
<div class="col-xs-7 text-right">'.$azienda['ragione_sociale'].'</div>
</h5>
'.$conto1['descrizione'].'<br>';
if (get('lev') == '3') {
echo '
'.$conto2['numero'].' '.$conto2['descrizione'].'<br>
'.$conto3['numero'].' '.$conto3['descrizione'].'<br>';
} elseif (get('lev') == '2') {
echo'
'.$conto2['numero'].' '.$conto2['descrizione'].'<br>';
}

View File

@ -0,0 +1,40 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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';
$azienda= $dbo->fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica='.setting('Azienda predefinita'));
$date_start = $_SESSION['period_start'];
$date_end = $_SESSION['period_end'];
if (get('lev') == '3') {
$conto3 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti3 WHERE id='.prepare($id_record));
$conto2 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti2 WHERE id='.prepare($conto3['idpianodeiconti2']));
$conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($conto2['idpianodeiconti1']));
// Movimenti
$records = $dbo->fetchArray('SELECT * FROM co_movimenti WHERE idconto='.prepare($id_record).' AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end));
} elseif (get('lev') == '2') {
$records = $dbo->fetchArray('SELECT CONCAT(co_pianodeiconti3.numero, " ",co_pianodeiconti3.descrizione) AS descrizione, SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2='.prepare($id_record).') GROUP BY idconto HAVING totale!=0');
$conto2 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti2 WHERE id='.prepare($id_record));
$conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($conto2['idpianodeiconti1']));
} elseif (get('lev') == '1') {
$records = $dbo->fetchArray('SELECT CONCAT(co_pianodeiconti2.numero, " ", co_pianodeiconti2.descrizione) AS titolo, CONCAT(co_pianodeiconti3.numero, " ",co_pianodeiconti3.descrizione) AS descrizione, SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1='.prepare($id_record).')) GROUP BY idconto HAVING totale!=0 ORDER BY co_pianodeiconti2.numero');
$conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($id_record));
$risultato = $dbo->fetchOne('SELECT SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Economico")))');
}
$prev_titolo = '';

View File

@ -1,47 +0,0 @@
<!--
~ OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
~ Copyright (C) DevCode s.n.c.
~
~ 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/>.
-->
<style>
body{ font-size:12px; }
th{ background:#eee; }
th.padded,
td.padded{
padding: 4px;
vertical-align: top;
}
.text-right{ text-align:right; }
.text-center{ text-align:center; }
.br{
border-right: 1px solid #999;
}
.bb{
border-bottom: 1px solid #999;
}
.bt{
border-top: 1px solid #999;
}
</style>
<page backcolor="#ffffff" backtop="29.5mm" backbottom="5mm" backleft="0mm" backright="0mm" footer="">
$body$
</page>

View File

@ -1,41 +0,0 @@
<!--
~ OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
~ Copyright (C) DevCode s.n.c.
~
~ 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/>.
-->
<page_header>
<table cellpadding='0' cellspacing='0'>
<tr><td style='border:1px solid #777; padding:4px;'>
<table cellpadding='0' cellspacing='0'>
<tr><td style='width:95mm;'>
<big>STAMPA MASTRINO <small style="font-size:11px; color:#777;">(|period_start| - |period_end|)</small></big><hr>
<small>|percorso|</small>
</td>
<td style='text-align:right; width:100mm;'>
|info_fornitore|
</td></tr>
</table>
</td></tr>
<tr><td style='border-left: 1px solid #777; border-bottom:1px solid #777; border-right: 1px solid #777;'>
<table style='table-layout:fixed;' cellpadding='0' cellspacing='0'>
<col width='79'><col width='452'><col width='80'><col width='79'>
<tr><th class='br padded'>DATA</th><th class='br padded'>DESCRIZIONE</th><th class='br padded'>DARE</th><th class='padded'>AVERE</th></tr>
</table>
</td></tr>
</table>
</page_header>

View File

@ -1,328 +0,0 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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';
$idconto = $_GET['idconto'];
$module_name = 'Piano dei conti';
$date_start = $_SESSION['period_start'];
$date_end = $_SESSION['period_end'];
// carica report html
$report = file_get_contents(base_dir().'/templates/partitario_mastrino/partitario.html');
$body = file_get_contents(base_dir().'/templates/partitario_mastrino/partitario_body.html');
include_once base_dir().'/templates/pdfgen_variables.php';
// Calcolo il percorso piano dei conti
if ($_GET['lev'] == '3') {
$rs = $dbo->fetchArray("SELECT idpianodeiconti2, CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti3 WHERE id=\"".$idconto.'"');
$percorso = $rs[0]['descrizione'];
$idpianodeiconti2 = $rs[0]['idpianodeiconti2'];
$rs = $dbo->fetchArray("SELECT idpianodeiconti1, CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti2 WHERE id=\"".$idpianodeiconti2.'"');
$percorso = $rs[0]['descrizione'].'<br>&nbsp;&nbsp;&nbsp;&nbsp;'.$percorso;
$idpianodeiconti1 = $rs[0]['idpianodeiconti1'];
$rs = $dbo->fetchArray("SELECT CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti1 WHERE id=\"".$idpianodeiconti1.'"');
($rs[0]['descrizione'] == '01 Patrimoniale') ? $descrizione = 'Stato patrimoniale' : $descrizione = 'Conto economico';
$percorso = $descrizione.'<br>&nbsp;&nbsp;'.$percorso;
} elseif ($_GET['lev'] == '2') {
$rs = $dbo->fetchArray("SELECT idpianodeiconti1, CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti2 WHERE id=\"".$idconto.'"');
$percorso = $rs[0]['descrizione'].'<br>&nbsp;&nbsp;&nbsp;&nbsp;'.$percorso;
$idpianodeiconti1 = $rs[0]['idpianodeiconti1'];
$rs = $dbo->fetchArray("SELECT CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti1 WHERE id=\"".$idpianodeiconti1.'"');
($rs[0]['descrizione'] == '01 Patrimoniale') ? $descrizione = 'Stato patrimoniale' : $descrizione = 'Conto economico';
$percorso = $descrizione.'<br>&nbsp;&nbsp;'.$percorso;
} elseif ($_GET['lev'] == '1') {
$rs = $dbo->fetchArray("SELECT CONCAT_WS(' ', numero, descrizione ) AS descrizione FROM co_pianodeiconti1 WHERE id=\"".$idconto.'"');
($rs[0]['descrizione'] == '01 Patrimoniale') ? $descrizione = 'Stato patrimoniale' : $descrizione = 'Conto economico';
$percorso = $descrizione.'<br>&nbsp;<br>&nbsp;';
}
$body = str_replace('|percorso|', $percorso, $body);
$body = str_replace('|info_fornitore|', $f_ragionesociale.'<br>'.$f_indirizzo.'<br>'.$f_citta, $body);
$body = str_replace('|period_start|', Translator::dateToLocale($date_start), $body);
$body = str_replace('|period_end|', Translator::dateToLocale($date_end), $body);
// Stampa da livello 3
if ($_GET['lev'] == '3') {
$body .= "<table style='table-layout:fixed; border-bottom:1px solid #777; border-right:1px solid #777; border-left:1px solid #777;' cellpadding='0' cellspacing='0'>
<col width='80'><col width='452'><col width='80'><col width='80'>
<tbody>\n";
// Inizializzo saldo finale
$saldo_finale = [];
// Calcolo saldo iniziale
$saldo_iniziale = 0;
$saldo_finale = $saldo_iniziale;
$rs = $dbo->fetchArray('SELECT *, SUM(totale) AS totale
FROM co_movimenti
WHERE idconto='.prepare($idconto).' AND
data >= '.prepare($date_start).' AND
data <= '.prepare($date_end).'
GROUP BY idmastrino
ORDER BY data ASC');
// Inizializzo saldo finale
$saldo_finale2 = [];
for ($i = 0; $i < sizeof($rs); ++$i) {
if ($rs[$i]['totale'] >= 0) {
$dare = moneyFormat(abs($rs[$i]['totale']), 2);
$avere = '';
} else {
$dare = '';
$avere = moneyFormat(abs($rs[$i]['totale']), 2);
}
$body .= " <tr><td class='br bb padded text-center'>".Translator::dateToLocale($rs[$i]['data'])."</td><td class='br bb padded'>".$rs[$i]['descrizione']."</td><td class='br bb padded text-right'>".$dare."</td><td class='bb padded text-right'>".$avere."</td></tr>\n";
$saldo_finale2[] = $rs[$i]['totale'];
}
if (sum($saldo_finale) < 0) {
$dare = '';
$avere = abs(sum($saldo_finale) + sum($saldo_finale2));
} else {
$dare = abs(sum($saldo_finale) + sum($saldo_finale2));
$avere = '';
}
// Mostro il saldo finale
$body .= " <tr><td class='br bb padded'></td><td class='br bb padded'><b>SALDO FINALE</b></td><td class='br bb padded text-right'><b>".moneyFormat(abs(sum($dare)), 2)."</b></td><td class='bb padded text-right'><b>".moneyFormat(abs(sum($avere)), 2)."</b></td></tr>\n";
$body .= " </tbody>
</table>\n";
}
// Stampa da livello 2
elseif ($_GET['lev'] == '2') {
$body .= "<table style='table-layout:fixed; border-bottom:1px solid #777; border-right:1px solid #777; border-left:1px solid #777;' cellpadding='0' cellspacing='0'>
<col width='80'><col width='452'><col width='80'><col width='80'>
<tbody>\n";
// Ciclo fra i sotto-conti di livello 2
$rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$idconto.'"');
for ($z = 0; $z < sizeof($rs3); ++$z) {
$v_dare = [];
$v_avere = [];
// Inizializzo saldo finale
$saldo_finale = [];
// Calcolo saldo iniziale
$saldo_iniziale = 0;
$saldo_finale[] = $saldo_iniziale;
$rs = $dbo->fetchArray('SELECT * FROM co_movimenti WHERE idconto="'.$rs3[$z]['id'].'" AND data >= '.prepare($date_start).' AND data <= '.prepare($date_end).' ORDER BY data ASC');
for ($i = 0; $i < sizeof($rs); ++$i) {
if ($rs[$i]['totale'] >= 0) {
$v_dare[] = abs($rs[$i]['totale']);
} else {
$v_avere[] = abs($rs[$i]['totale']);
}
}
$totale = sum($v_dare) - sum($v_avere);
if ($totale >= 0) {
$dare = moneyFormat(abs($totale), 2);
$avere = '';
} else {
$dare = '';
$avere = moneyFormat(abs($totale), 2);
}
// Mostro il saldo finale del conto di livello 3
if (sizeof($rs) > 0) {
$body .= " <tr><td class='br bb padded'></td><td class='br bb padded'>".$rs3[$z]['numero'].' '.$rs3[$z]['descrizione']."</td><td class='br bb padded text-right'>".$dare."</td><td class='bb padded text-right'>".$avere."</td></tr>\n";
}
}
$body .= " </tbody>
</table>\n";
}
// Stampa completa bilancio
elseif (get('lev') == '1') {
$ricavi = [];
$costi = [];
$totale_attivita = [];
$totale_passivita = [];
$body .= "<table style='table-layout:fixed; border-bottom:1px solid #777; border-right:1px solid #777; border-left:1px solid #777;' cellpadding='0' cellspacing='0'>
<col width='80'><col width='452'><col width='80'><col width='80'>
<tbody>\n";
// Ciclo fra il conto principale scelto (Economico o Patrimoniale)
$rs1 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti1 WHERE id="'.$idconto.'" ORDER BY numero DESC');
for ($x = 0; $x < sizeof($rs1); ++$x) {
// Ciclo fra i sotto-conti di livello 1
$rs2 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti2 WHERE idpianodeiconti1="'.$rs1[$x]['id'].'"');
for ($y = 0; $y < sizeof($rs2); ++$y) {
// Ciclo fra i sotto-conti di livello 2
$rs3 = $dbo->fetchArray('SELECT id, numero, descrizione, movimenti.totale FROM co_pianodeiconti3 LEFT JOIN (SELECT SUM(totale) AS totale, idconto FROM co_movimenti GROUP BY idconto) AS movimenti ON co_pianodeiconti3.id=movimenti.idconto WHERE idpianodeiconti2="'.$rs2[$y]['id'].'" AND movimenti.totale != 0');
if (!empty($rs3)) {
$body .= " <tr><th class='bb padded' colspan='4'><b>".$rs2[$y]['numero'].' '.$rs2[$y]['descrizione']."</b></th></tr>\n";
}
for ($z = 0; $z < sizeof($rs3); ++$z) {
$v_dare = [];
$v_avere = [];
if ($rs3[$z]['totale'] >= 0) {
$v_dare[] = abs($rs3[$z]['totale']);
} else {
$v_avere[] = abs($rs3[$z]['totale']);
}
$totale = sum($v_dare) - sum($v_avere);
if ($totale >= 0) {
$dare = abs($totale);
$avere = 0;
$totale_attivita[] = $dare;
$costi[] = abs($dare);
} else {
$dare = 0;
$avere = abs($totale);
$totale_passivita[] = $avere;
$ricavi[] = abs($avere);
}
// Mostro il saldo finale del conto di livello 3
$body .= " <tr><td class='br bb padded'></td><td class='br bb padded'>".$rs3[$z]['numero'].' '.$rs3[$z]['descrizione']."</td><td class='br bb padded text-right'>".moneyFormat(abs($dare), 2)."</td><td class='bb padded text-right'>".moneyFormat(abs($avere), 2)."</td></tr>\n";
}
}
}
// Stampa "Costi/Ricavi" se conto economico
if ($rs1[0]['descrizione'] == 'Economico') {
$body .= " <tr><th colspan='3' class='br bb padded'>RICAVI</th><th align='right' class='bb padded'>".moneyFormat(sum($ricavi), 2)."</th></tr>\n";
$body .= " <tr><th colspan='3' class='br bb padded'>COSTI</th><th align='right' class='bb padded'>".moneyFormat(sum($costi), 2)."</th></tr>\n";
$body .= " <tr><th colspan='3' class='br padded'>UTILE</th><th class='padded' align='right'>".moneyFormat(sum($ricavi) - sum($costi), 2)."</th></tr>\n";
}
// Stampa "Attività/Passività" se stato patrimoniale
else {
$costi = [];
$ricavi = [];
// Ciclo fra il conto economico per calcolare l'utile o la perdita
$rs1 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti1 WHERE NOT id="'.$idconto.'" ORDER BY numero DESC');
for ($x = 0; $x < sizeof($rs1); ++$x) {
// Ciclo fra i sotto-conti di livello 1
$rs2 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti2 WHERE idpianodeiconti1="'.$rs1[$x]['id'].'"');
for ($y = 0; $y < sizeof($rs2); ++$y) {
// Ciclo fra i sotto-conti di livello 2
$rs3 = $dbo->fetchArray('SELECT id, numero, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2="'.$rs2[$y]['id'].'"');
for ($z = 0; $z < sizeof($rs3); ++$z) {
// Inizializzo saldo finale
$saldo_finale = [];
// Calcolo saldo iniziale
$rs = $dbo->fetchArray('SELECT SUM(totale) AS totale FROM co_movimenti WHERE idconto="'.$rs2[$y]['id'].'" AND data < '.prepare($date_start).'');
$dare = [];
$avere = [];
$rs = $dbo->fetchArray('SELECT * FROM co_movimenti WHERE idconto="'.$rs3[$z]['id'].'" AND data >= '.prepare($date_start).' AND data <= '.prepare($date_end).' ORDER BY data ASC');
for ($i = 0; $i < sizeof($rs); ++$i) {
if ($rs[$i]['totale'] >= 0) {
$dare[] = abs($rs[$i]['totale']);
} else {
$avere[] = abs($rs[$i]['totale']);
}
}
$totale = sum($dare) - sum($avere);
if ($totale >= 0) {
$costi[] = abs($totale);
} else {
$ricavi[] = abs($totale);
}
}
}
}
$body .= " </tbody>\n";
$body .= " </table>\n";
// Tabella di riepilogo finale
$totale_attivita = abs(sum($totale_attivita));
$totale_passivita = abs(sum($totale_passivita));
$utile_perdita = abs(sum($ricavi)) - abs(sum($costi));
if ($utile_perdita < 0) {
$pareggio1 = $totale_attivita + abs($utile_perdita);
$pareggio2 = abs($totale_passivita);
} else {
$pareggio1 = $totale_attivita;
$pareggio2 = abs($totale_passivita) + abs($utile_perdita);
}
$body .= "<table style='table-layout:fixed; border-bottom:1px solid #777; border-right:1px solid #777; border-left:1px solid #777;' cellpadding='0' cellspacing='0'>
<col width='173'><col width='173'><col width='173'><col width='173'>
<tbody>\n";
// Attività
$body .= " <tr><th class='br bb padded'>TOTALE ATTIVIT&Agrave;</th><th align='right' class='bb br padded'>".moneyFormat($totale_attivita, 2)."</th>\n";
// Passività
$body .= " <th class='br bb padded'>PASSIVIT&Agrave;</th><th align='right' class='bb padded'>".moneyFormat($totale_passivita, 2)."</th></tr>\n";
if ($utile_perdita < 0) {
// Perdita d'esercizio
$body .= " <tr><th class='br bb padded'>PERDITA D'ESERCIZIO</th><th align='right' class='bb br padded'>".moneyFormat(abs($utile_perdita), 2)."</th>\n";
// Utile
$body .= " <th class='br bb padded'>&nbsp;</th><th align='right' class='bb padded'>&nbsp;</th></tr>\n";
} else {
// Perdita d'esercizio
$body .= " <tr><th class='br bb padded'>&nbsp;</th><th align='right' class='bb br padded'>&nbsp;</th>\n";
// Utile
$body .= " <th class='br bb padded'>UTILE</th><th align='right' class='bb padded'>".moneyFormat(abs($utile_perdita), 2)."</th></tr>\n";
}
// PAREGGIO 1
$body .= " <tr><th class='br padded'>TOTALE A PAREGGIO</th><th align='right' class='br padded'>".moneyFormat($pareggio1, 2)."</th>\n";
// PAREGGIO 2
$body .= " <th class='br padded'>TOTALE A PAREGGIO</th><th align='right' class='padded'>".moneyFormat($pareggio2, 2)."</th></tr>\n";
}
$body .= " </tbody>
</table>\n";
}

View File

@ -0,0 +1,47 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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($record['titolo'] != $prev_titolo && get('lev') == 1){
echo '
<tr>
<th colspan="4">'.$record['titolo'].'</th>
</tr>';
}
echo '
<tr>
<td>'.Translator::dateToLocale($record['data']).'</td>
<td>'.$record['descrizione'].'</td>';
if($record['totale']>=0){
echo '<td class="text-right">'.moneyFormat(abs($record['totale']), 2).'</td>
<td></td>';
}
else{
echo ' <td></td>
<td class="text-right">'.moneyFormat(abs($record['totale']), 2).'</td>';
}
echo '</tr>';
$prev_titolo = $record['titolo'];

View File

@ -0,0 +1,22 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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/>.
*/
return [
'font-size' => '11pt',
];

View File

@ -0,0 +1,32 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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';
echo '
<table class="table table-striped table-bordered" id="contents">
<thead>
<tr>
<th width="10%">DATA</th>
<th width="60%">DESCRIZIONE</th>
<th width="15%">DARE</th>
<th width="15%">AVERE</th>
</tr>
</thead>
<tbody>';

View File

@ -2,7 +2,10 @@
// File e cartelle deprecate
$files = [
'plugins/fornitori_articolo',
'plugins/fornitori_articolo',
'templates/partitario_mastrino/partitario.html',
'templates/partitario_mastrino/partitario_body.html',
'templates/partitario_mastrino/pdfgen.partitario_mastrino.php'
];
foreach ($files as $key => $value) {