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

poste.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 
00021 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00022 /* $Revision: 1.9 $ */
00023 
00036 function GetPosteLibelle($p_dossier,$p_id,$is_cn=0)
00037 {
00038   include_once("postgres.php");
00039   if ( ! isset($is_cn) ) $is_cn=0;
00040   if ( $is_cn == 0) {
00041     $cn=DbConnect($p_dossier);
00042   } else {
00043     $cn=$p_dossier;
00044   }
00045   $Res=ExecSql($cn,"select pcm_lib from tmp_pcmn where pcm_val=$p_id");
00046   if ( pg_NumRows($Res) == 0) { return "non existing poste";}
00047   $l_poste=pg_fetch_row($Res,0);
00048   return $l_poste[0];
00049 }
00062 function GetNumberLine($p_dossier,$p_jrn) 
00063 {
00064   $cn=DbConnect($p_dossier);
00065   $Res=ExecSql($cn,"select jrn_deb_max_line,jrn_cred_max_line from jrn_def where jrn_def_id=$p_jrn");
00066   if ( pg_NumRows($Res) == 0 ) {
00067     echo "<H2 class=\"warning\"> Journal non trouvé </H2>";
00068     //    return (3,3);
00069   }
00070   $l_line=pg_fetch_array($Res,0);
00071   $l_deb=$l_line['jrn_deb_max_line'];
00072   $l_cred=$l_line['jrn_cred_max_line'];
00073   return array ($l_deb,$l_cred);
00074 
00075 }
00087 function PosteForm($p_cn) {
00088   $Res=ExecSql($p_cn,"select pcm_val,pcm_lib from tmp_pcmn 
00089          where pcm_val = any (select j_poste from jrnx) order by pcm_val::text");
00090   $Max=pg_NumRows($Res);
00091   if ($Max==0) return null;
00092   $ret='<SELECT NAME="poste[]" SIZE="15" MULTIPLE>';
00093   for ( $i = 0;$i< $Max;$i++) {
00094     $line=pg_fetch_array($Res,$i);
00095     $ret.=sprintf('<OPTION VALUE="%s" > %s - %s',
00096                   $line['pcm_val'],
00097                   $line['pcm_val'],
00098                   $line['pcm_lib']);
00099   }//for
00100   $ret.="</SELECT>";
00101   return $ret;
00102 }
00114 function GetSolde($p_cn,$p_account,$p_cond="") {
00115   $Res=ExecSql($p_cn,"select j_poste,sum(deb) as sum_deb, sum(cred) as sum_cred from 
00116           ( select j_poste, 
00117              case when j_debit='t' then j_montant else 0 end as deb, 
00118              case when j_debit='f' then j_montant else 0 end as cred 
00119           from jrnx join tmp_pcmn on j_poste=pcm_val 
00120               where  
00121             j_poste=$p_account
00122           ) as m group by j_poste ");
00123   $Max=pg_NumRows($Res);
00124   if ($Max==0) return 0;
00125   $r=pg_fetch_array($Res,0);
00126 
00127   return $r['sum_deb']-$r['sum_cred'];
00128 }
00129 ?>