Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

balance.php

Go to the documentation of this file.
00001 
00002 <?
00003 /*
00004  *   This file is part of PHPCOMPTA.
00005  *
00006  *   PhpCompta is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   PhpCompta is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with PHPCOMPTA; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 // Auteur Dany De Bontridder ddebontridder@yahoo.fr
00021 // /* $Revision: 1.7 $ */
00029 include_once ("ac_common.php");
00030 include_once("preference.php");
00031 include_once ("class_widget.php");
00032 include_once("class_balance.php");
00033 if ( $User->CheckAction($cn,BALANCE) == 0)
00034   {
00035     NoAccess();
00036     exit;
00037   }
00038 echo '<div class="u_content">';
00039 
00040 //-----------------------------------------------------
00041 // Form
00042 //-----------------------------------------------------
00043 // Show the export button
00044 if ( isset ($_POST['view']  ) ) {
00045   $submit=new widget();
00046   $hid=new widget("hidden");
00047 
00048   echo "<table>";
00049   echo '<TR>';
00050   echo '<TD><form method="POST" ACTION="print_balance.php">'.
00051     $submit->Submit('bt_pdf',"Export PDF").
00052     $hid->IOValue("from_periode",$_POST['from_periode']).
00053     $hid->IOValue("to_periode",$_POST['to_periode']);
00054 
00055   echo "</form></TD>";
00056   echo '<TD><form method="POST" ACTION="bal_csv.php">'.
00057     $submit->Submit('bt_csv',"Export CSV").
00058     $hid->IOValue("from_periode",$_POST['from_periode']).
00059     $hid->IOValue("to_periode",$_POST['to_periode']);
00060 
00061   echo "</form></TD>";
00062 
00063   echo "</TR>";
00064 
00065   echo "</table>";
00066 }
00067 
00068 // Show the form for period
00069 echo '<FORM action="user_impress.php?type=bal" method="post">';
00070 $w=new widget("select");
00071 $w->table=1;
00072 // filter on the current year
00073 $filter_year=" where p_exercice='".$User->getExercice()."'";
00074 
00075 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00076 $w->label="Depuis";
00077 if ( isset ($_POST['from_periode']) )
00078   $w->selected=$_POST['from_periode'];
00079 
00080 echo $w->IOValue('from_periode',$periode_start);
00081 $w->label=" jusqu'à ";
00082 $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00083 if ( isset ($_POST['to_periode']) )
00084   $w->selected=$_POST['to_periode'];
00085 
00086 echo $w->IOValue('to_periode',$periode_end);
00087 $c=new widget("checkbox");
00088 $c->label="centralisé";
00089 echo $c->IOValue('central');
00090 
00091 //$a=FormPeriodeMult($cn);
00092 //echo $a;
00093 echo '<input type="submit" name="view" value="ok">';
00094 
00095 
00096 //-----------------------------------------------------
00097 // Display result
00098 //-----------------------------------------------------
00099 if ( isset($_POST['view'] ) ) {
00100   $bal=new Balance($cn);
00101   
00102   $t_cent="";
00103   //$per=join(',',$periode);
00104   if ( isset($_POST['central']) ) {
00105     $bal->central='Y';
00106     $t_cent="centralisée";
00107   }
00108   else
00109   $bal->central='N';
00110 
00111   $row=$bal->GetRow($_POST['from_periode'],
00112                   $_POST['to_periode']);
00113     $a=GetPeriode($cn,$_POST['from_periode']);
00114     $b=GetPeriode($cn,$_POST['to_periode']);
00115     echo "<h2 class=\"info\"> période du ".$a['p_start']." au ".$b['p_end']."</h2>";
00116 
00117   echo '<table width="100%">';  
00118   $i=0;
00119   foreach ($row as $r) {
00120     $i++;
00121     if ( $i%2 == 0 )
00122       $tr="even";
00123     else
00124       $tr="odd";
00125 
00126     echo '<TR class="'.$tr.'">';
00127     echo '<TD>'.$r['poste'].'</TD>';
00128     echo '<TD>'.$r['label'].'</TD>';
00129     echo '<TD>'.$r['sum_deb'].'</TD>';
00130     echo '<TD>'.$r['sum_cred'].'</TD>';
00131     echo '<TD>'.$r['solde_deb'].'</TD>';
00132     echo '<TD>'.$r['solde_cred'].'</TD>';
00133     echo '</TR>';
00134   }
00135   echo '</table>';
00136 
00137  }// end submit
00138   echo "</div>";
00139 ?>