';
/*
* Let you change the exercice
*/
echo '
'._('Exercice').' ';;
echo '';
echo '';
// Show the form for period
echo '
';
echo '
';
//-----------------------------------------------------
// Form
//-----------------------------------------------------
// Show the export button
if ( isset ($_GET['view'] ) )
{
$hid=new IHidden();
echo "
";
echo '';
echo ' ";
echo ' ";
echo '';
echo HtmlInput::print_window();
echo ' ';
echo " ";
echo "
";
}
//-----------------------------------------------------
// Display result
//-----------------------------------------------------
if ( isset($_GET['view'] ) )
{
$bal=new Acc_Balance($cn);
if ( $_GET['p_filter']==1)
{
for ($e=0;$e
jrn[]=$selected[$e];
}
if ( $_GET['p_filter'] == 0 )
{
$bal->jrn=null;
}
if ( $_GET['p_filter'] == 2 && isset ($_GET['r_cat']))
{
$bal->filter_cat($_GET['r_cat']);
}
$bal->from_poste=$_GET['from_poste'];
$bal->to_poste=$_GET['to_poste'];
if ( isset($_GET['unsold'])) $bal->unsold=true;
$previous=(isset($_GET['previous_exc']))?1:0;
$row=$bal->get_row($_GET['from_periode'],
$_GET['to_periode'],
$previous);
$previous= (isset ($row[0]['sum_cred_previous']))?1:0;
$periode=new Periode($cn);
$a=$periode->get_date_limit($_GET['from_periode']);
$b=$periode->get_date_limit($_GET['to_periode']);
echo " période du ".$a['p_start']." au ".$b['p_end']." ";
echo '';
echo _('Filtre').HtmlInput::infobulle(24);
echo HtmlInput::filter_table("t_balance", "0,1","1");
echo ' ';
echo '';
echo 'Poste Comptable ';
echo 'Libellé ';
if ( $previous == 1 ){
echo 'Débit N-1 ';
echo 'Crédit N-1 ';
echo 'Solde Débiteur N-1 ';
echo 'Solde Créditeur N-1 ';
if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3']))
echo 'Solde N-1 ';
}
echo 'Débit ';
echo 'Crédit ';
echo 'Solde Débiteur ';
echo 'Solde Créditeur ';
if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3']))
echo 'Solde ';
$i=0;
if ( $previous == 1) {
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_previous','sum_deb_previous','solde_deb_previous','solde_cred_previous');
}
else {
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred') ;
}
foreach($a_sum as $a)
{
$lvl1[$a]=0;
$lvl2[$a]=0;
$lvl3[$a]=0;
}
$lvl1_old='';
$lvl2_old='';
$lvl3_old='';
bcscale(2);
foreach ($row as $r)
{
$i++;
if ( $i%2 == 0 )
$tr="even";
else
$tr="odd";
$view_history= sprintf('%s ',
$r['poste'], $gDossier, $r['poste']);
/*
* level x
*/
foreach (array(3,2,1) as $ind)
{
if ( ! isset($_GET['lvl'.$ind]))continue;
if (${'lvl'.$ind.'_old'} == '') ${'lvl'.$ind.'_old'}=mb_substr($r['poste'],0,$ind);
if ( ${'lvl'.$ind.'_old'} != mb_substr($r['poste'],0,$ind))
{
echo '';
echo td(${'lvl'.$ind.'_old'},'style="font-weight:bold;"');
echo td(${'lvl'.$ind.'_old'}." "._("Total niveau")." ".$ind,'style="font-weight:bold;"');
if ($previous==1) {
echo td(nbm(${'lvl'.$ind}['sum_deb_previous']),'class="previous_year" style="font-weight:bold;"');
echo td(nbm(${'lvl'.$ind}['sum_cred_previous']),' class="previous_year" style="font-weight:bold;" ');
echo td(nbm(${'lvl'.$ind}['solde_deb_previous']),'class="previous_year" style="font-weight:bold;"');
echo td(nbm(${'lvl'.$ind}['solde_cred_previous']),'class="previous_year" style="font-weight:bold;"');
$delta_previous=bcsub(${'lvl'.$ind}['solde_cred_previous'],${'lvl'.$ind}['solde_deb_previous']);
$side_previous=($delta_previous > 0 ) ? "C":"D";
echo td(nbm(abs($delta_previous))." $side_previous",'class="previous_year" style="text-align:right;font-weight:bold;" ');
}
echo td(nbm(${'lvl'.$ind}['sum_deb']),'style="text-align:right;font-weight:bold;" ');
echo td(nbm(${'lvl'.$ind}['sum_cred']),'style="text-align:right;font-weight:bold;"');
echo td(nbm(${'lvl'.$ind}['solde_deb']),'style="text-align:right;font-weight:bold;"');
echo td(nbm(${'lvl'.$ind}['solde_cred']),'style="text-align:right;font-weight:bold;"');
$delta=bcsub(${'lvl'.$ind}['solde_cred'],${'lvl'.$ind}['solde_deb']);
$side=($delta > 0 ) ? "C":"D";
echo td(nbm(abs($delta))." $side",'style="text-align:right;font-weight:bold;" ');
echo ' ';
${'lvl'.$ind.'_old'}=mb_substr($r['poste'],0,$ind);
foreach($a_sum as $a)
{
${'lvl'.$ind}[$a]=0;
}
}
}
foreach($a_sum as $a)
{
$lvl1[$a]=bcadd($lvl1[$a],$r[$a]);
$lvl2[$a]=bcadd($lvl2[$a],$r[$a]);
$lvl3[$a]=bcadd($lvl3[$a],$r[$a]);
}
echo '';
echo td($view_history);
echo td(h($r['label']));
if ($previous == 1 ) {
echo td(nbm($r['sum_deb_previous']),' class="previous_year"');
echo td(nbm($r['sum_cred_previous']),' class="previous_year" ');
echo td(nbm($r['solde_deb_previous']),' class="previous_year"');
echo td(nbm($r['solde_cred_previous']),'class="previous_year" ');
if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3'])) echo ' ';
}
echo td(nbm($r['sum_deb']),'style="text-align:right;"');
echo td(nbm($r['sum_cred']),'style="text-align:right;"');
echo td(nbm($r['solde_deb']),'style="text-align:right;"');
echo td(nbm($r['solde_cred']),'style="text-align:right;"');
if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3'])) echo ' ';
echo ' ';
}
echo '
';
}// end submit
echo " ";
?>