altocompta/include/compta_fin_saldo.inc.php
sparkyx 6c3154abbd Code improvement : change fiche function
getAttribut becomes load_attribute,
 strAttribut becomes set_attribute
getAttribut becomes get_attribute
2025-08-01 17:44:22 +02:00

168 lines
5.5 KiB
PHP

<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS 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 2 of the License, or
* (at your option) any later version.
*
* NOALYSS 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 NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**
* \file
* \brief show bank saldo
*
*/
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
echo '<div class="content">';
$fiche=new Fiche($cn);
$array=$fiche->get_bk_account();
echo '<div class="content">';
echo dossier::hidden();
global $g_user;
// Get exercice user
$exercice=$g_user->get_exercice();
// display exercice user
echo h1(_("Exercice")." ".$exercice);
echo _('Cherche').' : '.HtmlInput::filter_table("fin_saldo_tb", '0,1,2,3', '1');
echo '<table class="sortable" style="margin-left:2%;width:96%" class="result" id="fin_saldo_tb">';
echo tr(th('Quick Code', ' class=" sorttable_sorted"',
Icon_Action::infobulle(17))
.th(_('Compte en banque'), ' style="text-align:left"')
.th(_('Journal'), ' style="text-align:center"')
.th(_('Description'), ' style="text-align:center"')
.th(_("Devise"))
.th(_("Montant Devise"))
.th(_('solde opération'),
' style="text-align:right" class="sorttable_numeric"')
.th(_('solde extrait/relevé'),
' style="text-align:right" class="sorttable_numeric"')
.th(_('différence'),
' style="text-align:right" class="sorttable_numeric"')
);
// Filter the saldo
// on the current year
$filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$g_user->get_exercice()."')";
// for highligting tje line
$idx=0;
bcscale(2);
$tot_extrait=0; $tot_diff=0; $tot_operation=0;
$nb_array=(empty($array))?0:count($array);
// for each account
for ($i=0; $i<$nb_array; $i++)
{
if ($array[$i]->id==0)
{
echo '<tr >';
echo td(h2(_("Journal mal configuré"), ' class="error" '),
' colspan="5" style="width:auto" ');
echo '</tr>';
continue;
}
// get the saldo
$m=$array[$i]->get_solde_detail($filter_year);
$solde=bcsub($m['debit'],$m['credit']);
// print the result if the saldo is not equal to 0
if ($m['debit']!=0.0||$m['credit']!=0.0)
{
// Get it in currency
$ledger=$array[$i]->get_bank_ledger();
$currency_code=$ledger->get_currency()->get_code();
/**
* if we don't use the defaut currency
*/
if ( $ledger->get_currency()->get_id() == 0)
{
$currency_amount=$solde;
}
else
{
$currency_amount=$array[$i]->get_bk_balance_currency();
}
/* get saldo for not reconcilied operations */
$saldo_not_reconcilied=$array[$i]->get_bk_balance($filter_year." and (trim(jr_pj_number) ='' or jr_pj_number is null)");
/* get saldo for reconcilied operation */
$saldo_reconcilied=$array[$i]->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)");
if ($idx%2!=0)
$odd="odd";
else
$odd="even";
$idx++;
echo "<tr class=\"$odd\">";
echo "<TD >".
IButton::history_card($array[$i]->id,
$array[$i]->get_attribute(ATTR_DEF_QUICKCODE)).
"</TD>";
$saldo_rec=noalyss_bcsub($saldo_reconcilied['debit'],
$saldo_reconcilied['credit']);
$diff=noalyss_bcsub($saldo_not_reconcilied['debit'],
$saldo_not_reconcilied['credit']);
echo "<TD >".
$array[$i]->get_attribute(ATTR_DEF_NAME).
"</TD>".
td(h($array[$i]->ledger_name)).
td(h($array[$i]->ledger_description)).
td($currency_code).
'<TD class="sorttable_numeric" sorttable_customkey="'.$currency_amount.'" style="text-align:right">'.
nbm($currency_amount).
'</td>'.
'<TD class="sorttable_numeric" sorttable_customkey="'.$solde.'" style="text-align:right">'.
nbm($solde).
"</TD>".
'<TD class="sorttable_numeric" sorttable_customkey="'.$saldo_rec.'" style="text-align:right">'.
nbm($saldo_rec).
"</TD>".
'<TD class="sorttable_numeric" sorttable_customkey="'.$diff.'" style="text-align:right">'.
nbm($diff).
"</TD>".
"</TR>";
$tot_extrait=bcadd($tot_extrait, $solde);
$tot_operation=bcadd($tot_operation, $saldo_rec);
$tot_diff=bcadd($tot_diff, $diff);
}
}// for
echo '<tfoot>';
echo '<tr class="highlight">';
echo td('');
echo td('');
echo td('');
echo td(_('TOTAUX'), 'style="font-weight:bold;text-align:center"');
echo td('');
echo td('');
echo td(nbm($tot_extrait), 'style="font-weight:bold" class="num"');
echo td(nbm($tot_operation), ' style="font-weight:bold" class="num"');
echo td(nbm($tot_diff), ' style="font-weight:bold" class="num"');
echo '</tr>';
echo '</tfoot>';
echo "</table>";
echo "</div>";
return;
?>