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

impress_poste.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 1.11 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 include_once("class_widget.php");
00030 //-----------------------------------------------------
00031 // If print is asked
00032 // First time in html
00033 // after in pdf or cvs
00034 //-----------------------------------------------------
00035 if ( isset( $_POST['bt_html'] ) ) {
00036   include("class_poste.php");
00037   $go=0;
00038 // we ask a poste_id
00039   if ( strlen(trim($_POST['poste_id'])) != 0 )
00040     {
00041       // Check if the post is numeric and exists
00042       if ( isNumber($_POST['poste_id']) &&
00043           CountSql($cn,'select * from tmp_pcmn where pcm_val='.FormatString($_POST['poste_id'])) != 0 )
00044         {
00045           $Poste=new poste($cn,$_POST['poste_id']);$go=1;
00046         }
00047     }
00048   if ( strlen(trim($_POST['f_id'])) != 0 )
00049     {
00050       require_once("class_fiche.php");
00051       // thanks the qcode we found the poste account
00052       $fiche=new fiche($cn,$_POST['f_id']);
00053       $fiche->GetByQCode($_POST['f_id']);
00054       $p=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
00055       if ( $p != "- ERROR -") {
00056         $Poste=new poste($cn,$p);
00057         $go=1;  
00058       }
00059    }
00060   
00061   // A account or a quick code is given
00062   if ( $go == 1) 
00063     {
00064       
00065      $Poste->GetName();
00066      list($array,$tot_deb,$tot_cred)=$Poste->GetRow( $_POST['from_periode'],
00067                                                      $_POST['to_periode']
00068                                                      );
00069      
00070      $rep="";
00071      $submit=new widget();
00072      $hid=new widget("hidden");
00073      echo '<div class="u_content">';
00074      echo '<h2 class="info">'.$Poste->id." ".$Poste->name.'</h2>';
00075      echo "<table >";
00076      echo '<TR>';
00077      echo '<TD><form method="GET" ACTION="user_impress.php">'.
00078        $submit->Submit('bt_other',"Autre poste").
00079        $hid->IOValue("type","poste")."</form></TD>";
00080      
00081      echo '<TD><form method="POST" ACTION="poste_pdf.php">'.
00082        $submit->Submit('bt_pdf',"Export PDF").
00083        $hid->IOValue("type","poste").
00084        $hid->IOValue("poste_id",$Poste->id).
00085        $hid->IOValue("from_periode",$_POST['from_periode']).
00086        $hid->IOValue("to_periode",$_POST['to_periode']);
00087      
00088      echo "</form></TD>";
00089      echo '<TD><form method="POST" ACTION="poste_csv.php">'.
00090        $submit->Submit('bt_csv',"Export CSV").
00091        $hid->IOValue("type","poste").
00092        $hid->IOValue("poste_id",$Poste->id).
00093        $hid->IOValue("from_periode",$_POST['from_periode']).
00094        $hid->IOValue("to_periode",$_POST['to_periode']);
00095 
00096      echo "</form></TD>";
00097   
00098      echo "</TR>";
00099      
00100      echo "</table>";
00101      if ( count($Poste->row ) == 0 ) 
00102        exit;
00103 
00104      echo "<TABLE class=\"result\" width=\"100%\">";
00105      echo "<TR>".
00106        "<TH> Code interne </TH>".
00107        "<TH> Date</TH>".
00108        "<TH> Description </TH>".
00109        "<TH> Débit  </TH>".
00110         "<TH> Crédit </TH>".
00111        "</TR>";
00112      
00113      foreach ( $Poste->row as $op ) { 
00114        echo "<TR>".
00115          "<TD>".$op['jr_internal']."</TD>".
00116          "<TD>".$op['j_date']."</TD>".
00117          "<TD>".$op['description']."</TD>".
00118          "<TD>".$op['deb_montant']."</TD>".
00119          "<TD>".$op['cred_montant']."</TD>".
00120          "</TR>";
00121     
00122      }
00123      $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
00124      $diff=abs($tot_deb-$tot_cred);
00125      echo "<TR>".
00126        "<TD>$solde_type</TD>".
00127        "<TD>$diff</TD>".
00128        "<TD></TD>".
00129        "<TD>$tot_deb</TD>".
00130        "<TD>$tot_cred</TD>".
00131        "</TR>";
00132 
00133      echo "</table>";
00134      echo "</div>";
00135      exit;
00136    }
00137 } 
00138 //-----------------------------------------------------
00139 // Show the jrn and date
00140 //-----------------------------------------------------
00141 include_once("postgres.php");
00142 //-----------------------------------------------------
00143 // Form
00144 //-----------------------------------------------------
00145 echo '<div class="u_content">';
00146 echo JS_SEARCH_POSTE;
00147 echo JS_SEARCH_CARD;
00148 echo '<FORM ACTION="?type=poste" METHOD="POST">';
00149 echo '<TABLE><TR>';
00150 $span=new widget("span");
00151 
00152 $w=new widget("js_search_poste");
00153 $w->table=1;
00154 $w->label="Choississez le poste";
00155 print $w->IOValue("poste_id");
00156 echo $span->IOValue('poste_id_label');
00157 $w_poste=new widget("js_search_only");
00158 $w_poste->table=1;
00159 $w_poste->label="Ou Choississez la fiche";
00160 $w_poste->extra='all';
00161 print $w_poste->IOValue("f_id");
00162 echo $span->IOValue('f_id_label');
00163 print '</TR>';
00164 print '<TR>';
00165 // filter on the current year
00166 $select=new widget("select");
00167 $select->table=1;
00168 $filter_year=" where p_exercice='".$User->getExercice()."'";
00169 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00170 $select->label="Depuis";
00171 print $select->IOValue('from_periode',$periode_start);
00172 $select->label=" jusqu'à ";
00173 $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode  $filter_year order by p_id");
00174 print $select->IOValue('to_periode',$periode_end);
00175 print "</TR>";
00176 print "<TR><TD>";
00177 $all=new widget("checkbox");
00178 $all->label="Tous les postes";
00179 $all->disabled=true;
00180 echo $all->IOValue("all");
00181 echo '</TABLE>';
00182 print $w->Submit('bt_html','Impression');
00183 
00184 echo '</FORM>';
00185 echo '</div>';
00186 ?>