';
/* add a all ledger choice */
echo _('Filtre')." ";
$rad=new IRadio();
$array_ledger=$g_user->get_ledger('ALL',3);
$array=get_array_column($array_ledger,'jrn_def_id');
$selected=(isset($_GET['r_jrn']))?$_GET['r_jrn']:null;
$select_cat=(isset($_GET['r_cat']))?$_GET['r_cat']:null;
$array_cat=Acc_Ledger::array_cat();
echo '
';
if ( ! isset($_GET['p_filter']) || $_GET['p_filter']==0) $rad->selected='t';
else $rad->selected=false;
echo '- '.$rad->input('p_filter',0)._('Aucun filtre, tous les journaux').'
';
if ( isset($_GET['p_filter']) && $_GET['p_filter']==1) $rad->selected='t';
else $rad->selected=false;
echo '- '.$rad->input('p_filter',1)._('Filtré par journal');
echo HtmlInput::button_choice_ledger(array('div'=>'','type'=>'ALL','all_type'=>1));
echo '
';
if ( isset($_GET['p_filter']) && $_GET['p_filter']==2) $rad->selected='t';
else $rad->selected=false;
echo '- '.$rad->input('p_filter',2)._('Filtré par catégorie').HtmlInput::select_cat($array_cat).'
';
echo '
';
echo _('Totaux par sous-niveaux');
$ck_lev1=new ICheckBox('lvl1');
$ck_lev2=new ICheckBox('lvl2');
$ck_lev3=new ICheckBox('lvl3');
$ck_lev1->value=1;
$ck_lev2->value=1;
$ck_lev3->value=1;
echo '
';
if ($http->get('lvl1',"string",false) !== false)
$ck_lev1->selected=true;
if ($http->get('lvl2',"string",false) !== false)
$ck_lev2->selected=true;
if ($http->get('lvl3',"string",false) !== false)
$ck_lev3->selected=true;
echo '- '.$ck_lev1->input()._('Niveau 1').'
';
echo '- '.$ck_lev2->input()._('Niveau 2').'
';
echo '- '.$ck_lev3->input()._('Niveau 3').'
';
echo '
';
$unsold=new ICheckBox('unsold');
if ($http->get('unsold',"string",false) !== false)
$unsold->selected=true;
// previous exercice if checked
$previous_exc=new ICheckBox('previous_exc');
if ($http->get('previous_exc',"string",false) !== false)
$previous_exc->selected=true;
$from_poste=new IPoste();
$from_poste->name="from_poste";
$from_poste->set_attribute('ipopup','ipop_account');
$from_poste->set_attribute('label','from_poste_label');
$from_poste->set_attribute('account','from_poste');
$from_poste->value=$http->get('from_poste',"string",'');
$from_span=new ISpan("from_poste_label","");
$to_poste=new IPoste();
$to_poste->name="to_poste";
$to_poste->set_attribute('ipopup','ipop_account');
$to_poste->set_attribute('label','to_poste_label');
$to_poste->set_attribute('account','to_poste');
$to_poste->value=$http->get('to_poste',"string",'');
$to_span=new ISpan("to_poste_label","");
echo "
";
echo _("Plage de postes")." :".$from_poste->input();
echo $from_span->input();
echo " "._("jusque")." :".$to_poste->input();
echo $to_span->input();
echo "
";
echo '
';
echo '
';
echo _("Uniquement comptes non soldés")." ".$unsold->input();
echo '
';
echo '
';
echo _("Avec la balance de l'année précédente")." ".$previous_exc->input();
echo '
';
echo '
';
?>
value=1;
$is_summary=$http->get("summary","string", 0);
$summary->set_check($is_summary);
echo $summary->input();
?>
';
echo HtmlInput::submit("view",_("Visualisation"));
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;
$from_periode=$http->get("from_periode","number");
$to_periode=$http->get("to_periode","number");
$row=$bal->get_row($from_periode,$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 _('Cherche').Icon_Action::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 N-1').' | ';
}
echo ''._('Ouverture').' | ';
echo ''._('Débit').' | ';
echo ''._('Crédit').' | ';
echo ''._('Solde').' | ';
$i=0;
if ( $previous == 1) {
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_deb_ope','sum_cred_ope','sum_cred_previous','sum_deb_previous','solde_previous');
}
else {
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_deb_ope','sum_cred_ope') ;
}
foreach($a_sum as $a)
{
$lvl1[$a]=0;
$lvl2[$a]=0;
$lvl3[$a]=0;
}
$lvl1_old='';
$lvl2_old='';
$lvl3_old='';
bcscale(2);
$nb_row = count($row);
// Compute for the summary
$summary_tab=$bal->summary_init();
$summary_prev_tab=$bal->summary_init();
foreach ($row as $r)
{
$i++;
if ( $i%2 == 0 )
$tr="even";
else
$tr="odd";
$view_history=HtmlInput::history_account($r['poste'], $r['poste'], "",$exercice);
if ($previous == 1 ) {
$r['solde_previous']=bcsub($r['solde_deb_previous'],$r['solde_cred_previous']);
}
/*
* 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;"');
// compare with previous exercice
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;" ');
$delta_previous=${'lvl'.$ind}['solde_previous'];
$side_previous=($delta_previous > 0 ) ? "D":"C";
echo td(nbm(abs($delta_previous))." $side_previous",'class="previous_year" style="text-align:right;font-weight:bold;" ');
}
// Ouverture
$solde3=bcsub(${'lvl'.$ind}['sum_deb_ope'],${'lvl'.$ind}['sum_cred_ope']);
$side3=($solde3<0)?" C":" D";
$side3=($solde3==0)?" ":$side3;
echo td(nbm(abs($solde3)).$side3,'style="text-align:right;font-weight:bold;"');
// Saldo debit
$solde_deb=bcsub(${'lvl'.$ind}['sum_deb'],${'lvl'.$ind}['sum_deb_ope']);
echo td(nbm($solde_deb),'style="text-align:right;font-weight:bold;"');
// Saldo cred
$solde_cred=bcsub(${'lvl'.$ind}['sum_cred'],${'lvl'.$ind}['sum_cred_ope']);
echo td(nbm($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]);
}
// For the Total row , there is no accounting
if ( $r['poste'] == "") {
$tr="highlight";
}
$summary_tab=$bal->summary_add($summary_tab,$r['poste'],$r['sum_deb'],$r['sum_cred']);
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" ');
$solde_previous=bcsub($r['solde_deb_previous'],$r['solde_cred_previous']);
$side=($solde_previous<0)?"D":"C";
$side=($solde_previous==0)?"":$side;
$r['solde_previous']=$solde_previous;
echo td(nbm(abs($solde_previous))." ".$side,' class="previous_year"');
$summary_prev_tab=$bal->summary_add($summary_prev_tab,
$r['poste'],
$r['sum_deb_previous'],
$r['sum_cred_previous']);
}
$solde=bcsub($r['sum_deb_ope'],$r['sum_cred_ope']);
$side=($solde < 0)?" C":" D";
$side=($solde==0)?"":$side;
echo td(nbm(abs($solde)).$side,'style="text-align:right;"');
echo td(nbm(bcsub($r['sum_deb'],$r['sum_deb_ope'])),'style="text-align:right;"');
echo td(nbm(bcsub($r['sum_cred'],$r['sum_cred_ope'])),'style="text-align:right;"');
$solde2=bcsub($r['sum_deb'],$r['sum_cred']);
$side=($solde2 < 0)?" C":" D";
$side=($solde2==0)?"":$side;
echo td(nbm(abs($solde2)).$side,'style="text-align:right;"');
if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3'])) echo ' | ';
echo '
';
}
echo '
';
// display the summary
if ($is_summary==1) {
if ( $previous == 1) {
echo '';
echo '
';
echo _("Résumé Exercice précédent");
echo '
';
$bal->summary_display($summary_prev_tab);
echo "";
}
echo '';
echo '
';
echo _("Résumé Exercice courant");
echo '
';
$bal->summary_display($summary_tab);
echo "";
}
}// end submit
echo " ";
?>