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

jrn.php File Reference

work with the ledger More...

Go to the source code of this file.

Functions

 RecordJrn ($p_dossier, $p_user, $p_jrn, $p_MaxDeb, $p_MaxCred, $p_array=null, $p_update=0)
 Record an entry in the selected journal.
 UpdateJrn ($p_cn, $p_jr_id)
 Display the form to UPDATE account operation.
 ViewRec ($p_array=null)
 debug function to be dropped
 CorrectRecord ($p_dossier, $p_user, $p_jrn, $p_MaxDeb, $p_MaxCred, $p_array)
 Call the RecordJrn. In fact does nothing.
 ViewRecord ($p_dossier, $p_jrn, $p_id, $p_MaxDeb, $p_MaxCred, $p_array)
 View the added operation.
 GetJrnProperty ($p_cn, $p_jrn)
 Get the properties of a journal.
 GetJrnProp ($p_dossier, $p_jrn, $is_connected=0)
 Get the properties of a journal.
 ViewJrn ($p_dossier, $p_user, $p_jrn, $p_url, $p_array=null)
 Vue des écritures comptables.
 GetData ($p_cn, $p_grpt)
 Get data from jrnx where p_grpt=jrnx(j_grpt).
 GetInternal ($p_cn, $p_id)
 parm :
  • gen :
  • return:
  • -1 si aucune valeur de trouvéeReturn the internal value

 GetAmount ($p_cn, $p_id)
 return the sum of jrn where the internal_code is the p_id
 VerifData ($p_cn, $p_array, $p_user)
 Verify the data before inserting or updating.
 GetJrnName ($p_cn, $p_id)
 Return the name of the jrn.
 NextJrn ($p_cn, $p_type)
 Get the number of the next jrn from the jrn_def.jrn_code.
 SetInternalCode ($p_cn, $p_grpt, $p_jrn)
 parm :
  • $p_cn connection

$p_grpt id in jr_grpt_id

  • $p_jrn jrn id jrn_def_id
  • $p_dossier dossier id gen :
    • return:

 GetDataJrnJrId ($p_cn, $p_jr_id)
 Get data from jrn and jrnx thanks the jr_id.


Detailed Description

work with the ledger

Definition in file jrn.php.


Function Documentation

CorrectRecord p_dossier,
p_user,
p_jrn,
p_MaxDeb,
p_MaxCred,
p_array
 

Call the RecordJrn. In fact does nothing.

parm :

  • the same as RecordJrn gen :
  • none return:
  • none

Definition at line 436 of file jrn.php.

References RecordJrn().

00437 {
00438 
00439    RecordJrn($p_dossier,$p_user,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array);
00440 }

GetAmount p_cn,
p_id
 

return the sum of jrn where the internal_code is the p_id

parm :

  • $p_cn database connection

p_id = jrn.jr_internal gen :

  • return:
  • number

Definition at line 814 of file jrn.php.

References $l_line, $Res, and ExecSql().

00814                                 {
00815   $Res=ExecSql($p_cn,"select jr_montant from jrn where jr_internal='$p_id'");
00816   if (pg_NumRows($Res)==0) return -1;
00817   $l_line=pg_fetch_array($Res,0);
00818   return $l_line['jr_montant'];
00819 }

GetData p_cn,
p_grpt
 

Get data from jrnx where p_grpt=jrnx(j_grpt).

parm :

  • connection

p_grpt gen :

  • none return:
  • return array

Definition at line 711 of file jrn.php.

References $l_id, $l_line, $MaxLine, $Res, echo_debug(), and ExecSql().

00711                                  {
00712   echo_debug('jrn.php',__LINE__,"GetData $p_cn $p_grpt");
00713   $Res=ExecSql($p_cn,"select 
00714                         to_char(j_date,'DD.MM.YYYY') as j_date,
00715                         j_text,
00716                         j_debit,
00717                         j_poste,
00718                         j_montant,
00719                         j_id,
00720                         jr_comment,
00721                         to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
00722                         to_char(jr_date,'DD.MM.YYYY') as jr_date,
00723                         jr_id,jr_internal,jr_def_id
00724                      from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$p_grpt");
00725   $MaxLine=pg_NumRows($Res);
00726   if ( $MaxLine == 0 ) return null;
00727   $deb=0;$cred=0;
00728   for ( $i=0; $i < $MaxLine; $i++) {
00729     
00730     $l_line=pg_fetch_array($Res,$i);
00731     $l_array['op_date']=$l_line['j_date'];
00732     if ( $l_line['j_debit'] == 't' ) {
00733       $l_class=sprintf("class_deb%d",$deb);
00734       $l_montant=sprintf("mont_deb%d",$deb);
00735       $l_text=sprintf("text_deb%d",$deb);
00736       $l_array[$l_class]=$l_line['j_poste'];
00737       $l_array[$l_montant]=$l_line['j_montant'];
00738       $l_array[$l_text]=$l_line['j_text'];
00739       $l_id=sprintf("op_deb%d",$deb);
00740       $l_array[$l_id]=$l_line['j_id'];
00741       $deb++;
00742     }
00743     if ( $l_line['j_debit'] == 'f' ) {
00744       $l_class=sprintf("class_cred%d",$cred);
00745       $l_montant=sprintf("mont_cred%d",$cred);
00746       $l_array[$l_class]=$l_line['j_poste'];
00747       $l_array[$l_montant]=$l_line['j_montant'];
00748       $l_id=sprintf("op_cred%d",$cred);
00749       $l_array[$l_id]=$l_line['j_id'];
00750       $l_text=sprintf("text_cred%d",$deb);
00751       $l_array[$l_text]=$l_line['j_text'];
00752 
00753       $cred++;
00754     }
00755     $l_array['jr_internal']=$l_line['jr_internal'];
00756     $l_array['comment']=$l_line['jr_comment'];
00757     $l_array['ech']=$l_line['jr_ech'];
00758     $l_array['jr_id']=$l_line['jr_id'];
00759     $l_array['jr_def_id']=$l_line['jr_def_id'];
00760    }
00761   return array($l_array,$deb,$cred);
00762 }

GetDataJrnJrId p_cn,
p_jr_id
 

Get data from jrn and jrnx thanks the jr_id.

parm :

  • connection

p_jr_id (jrn.jr_id) gen :

  • none return:
  • return array

Definition at line 973 of file jrn.php.

References $array, $i, $line, $MaxLine, $Res, echo_debug(), and ExecSql().

Referenced by UpdateJrn().

00973                                          {
00974   echo_debug('jrn.php',__LINE__,"GetDataJrn $p_cn $p_jr_id");
00975   $Res=ExecSql($p_cn,"select 
00976                         j_text,
00977                         j_debit,
00978                         j_poste,
00979                        pcm_lib as vw_name,
00980                         j_montant,
00981                         jr_montant,
00982                         j_id,
00983                         jr_pj_name,
00984                         jr_grpt_id,
00985                         jr_comment,
00986                         to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
00987                         to_char(jr_date,'DD.MM.YYYY') as jr_date,
00988                         jr_id,jr_internal, jr_rapt,jrn_def_type
00989                      from 
00990                           jrnx 
00991                         inner join jrn on j_grpt=jr_grpt_id 
00992                         inner join jrn_def on jrn_def.jrn_def_id=jrn.jr_def_id
00993                         left outer join tmp_pcmn on  j_poste=pcm_val
00994                       where 
00995                          jr_id=$p_jr_id 
00996                       order by j_debit desc");
00997   $MaxLine=pg_NumRows($Res);
00998   echo_debug('jrn.php',__LINE__,"Found $MaxLine lines");
00999   if ( $MaxLine == 0 ) return null;
01000 
01001   for ( $i=0; $i < $MaxLine; $i++) {
01002     $line=pg_fetch_array($Res,$i);
01003     $array['j_debit']=$line['j_debit'];
01004     $array['vw_name']=$line['vw_name'];
01005     $array['jr_comment']=$line['jr_comment'];
01006     $array['j_montant']=$line['j_montant'];
01007     $array['jr_id']=$line['jr_id'];
01008     $array['jr_date']=$line['jr_date'];
01009     $array['jr_internal']=$line['jr_internal'];
01010     $array['j_poste']=$line['j_poste'];
01011     $array['jr_montant']=$line['jr_montant'];
01012     $array['jr_rapt']=$line['jr_rapt'];
01013     $array['jrn_def_type']=$line['jrn_def_type'];
01014     $array['jr_grpt_id']=$line['jr_grpt_id'];
01015     $array['jr_pj_name']=$line['jr_pj_name'];
01016     //    $array['']=$line[''];
01017 
01018     $ret_array[$i]=$array;
01019     }
01020   return $ret_array;
01021 }

GetInternal p_cn,
p_id
 

parm :

  • gen :
  • return:
  • -1 si aucune valeur de trouvéeReturn the internal value

parm :

  • p_cn database connection

p_id : jrn.jr_id gen :

  • none return:
  • null si aucune valeur de trouvée

Definition at line 793 of file jrn.php.

References $l_line, $Res, and ExecSql().

Referenced by ListJrn(), and UpdateJrn().

00793                                   {
00794 
00795   $Res=ExecSql($p_cn,"select jr_internal from jrn where jr_id=$p_id");
00796   if ( pg_NumRows($Res) == 0 ) return null;
00797   $l_line=pg_fetch_array($Res);
00798   return $l_line['jr_internal'];
00799 }

GetJrnName p_cn,
p_id
 

Return the name of the jrn.

parm :

  • p_cn connexion resource

jrn id gen :

  • none return:
  • string or null if not found

Definition at line 907 of file jrn.php.

References $Max, $Res, $ret, and ExecSql().

00907                                  {
00908   $Res=ExecSql($p_cn,"select jrn_def_name from ".
00909                " jrn_def where jrn_def_id=".
00910                $p_id);
00911   $Max=pg_NumRows($Res);
00912   if ($Max==0) return null;
00913   $ret=pg_fetch_array($Res,0);
00914   return $ret['jrn_def_name'];
00915 }

GetJrnProp p_dossier,
p_jrn,
is_connected = 0
 

Get the properties of a journal.

parm :

  • p_dossier the folder id

p_jrn the jrn id gen :

  • none return:
  • an array containing properties

Definition at line 549 of file jrn.php.

References $cn, $Res, DbConnect(), and ExecSql().

Referenced by ListJrn(), ViewJrn(), and ViewRecord().

00550 {
00551   if ( $is_connected == 0 ) 
00552     $cn=DbConnect($p_dossier);
00553   else
00554     $cn=$p_dossier;
00555 
00556   $Res=ExecSql($cn,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type, 
00557                    jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
00558                    jrn_def_fiche_deb,jrn_def_fiche_deb
00559                    from jrn_Def 
00560                       where jrn_def_id=$p_jrn");
00561   $Count=pg_NumRows($Res);
00562   if ( $Count == 0 ) {
00563     echo '<DIV="redcontent"><H2 class="error"> Paramètres journaux non trouvés</H2> </DIV>';
00564     return null;
00565   }
00566   return pg_fetch_array($Res,0);
00567 }

GetJrnProperty p_cn,
p_jrn
 

Get the properties of a journal.

parm :

  • p_cn database connection

p_jrn the jrn id gen :

  • none return:
  • an array containing properties

Definition at line 523 of file jrn.php.

References $Res, and ExecSql().

Referenced by FormODS(), RecordJrn(), and SetInternalCode().

00524 {
00525   $Res=ExecSql($p_cn,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type, 
00526                    jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
00527                    jrn_def_fiche_deb,jrn_def_fiche_deb
00528                    from jrn_Def 
00529                       where jrn_def_id=$p_jrn");
00530   $Count=pg_NumRows($Res);
00531   if ( $Count == 0 ) {
00532     echo '<DIV="redcontent"><H2 class="error"> Paramètres journaux non trouvés</H2> </DIV>';
00533     return null;
00534   }
00535   return pg_fetch_array($Res,0);
00536 }

NextJrn p_cn,
p_type
 

Get the number of the next jrn from the jrn_def.jrn_code.

parm :

  • $p_cn connection

$p_type jrn type gen :

  • none return:
  • string containing the next code

Definition at line 930 of file jrn.php.

References $Ret, and CountSql().

00931 {
00932   $Ret=CountSql($p_cn,"select * from jrn_def where jrn_def_type='".$p_type."'");
00933   return $Ret+1; 
00934 }

RecordJrn p_dossier,
p_user,
p_jrn,
p_MaxDeb,
p_MaxCred,
p_array = null,
p_update = 0
 

Record an entry in the selected journal.

parm :

  • p_dossier dossier id

p_user user id

  • p_jrn selected journal gen :
    • none return:
    • none

Definition at line 38 of file jrn.php.

References $a, $cn, $e, $l2_line, $l_line, $poste, $Res, $search, $sessid, $Sql, DbConnect(), echo_debug(), ExecSql(), GetJrnProperty(), GetPeriode(), METHOD, name, selected, and value.

Referenced by CorrectRecord().

00039 {
00040   include_once("postgres.php");
00041   include_once("preference.php");
00042 
00043   echo_debug('jrn.php',__LINE__,"RecordJrn($p_dossier,$p_user,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array,$p_update)");
00044   for ( $i = 0; $i < $p_MaxDeb; $i++) {
00045       ${"e_class_deb$i"}=0;
00046       ${"e_mont_deb$i"}=0;
00047   }
00048   for ( $i = 0; $i < $p_MaxCred; $i++) {
00049       ${"e_class_cred$i"}=0;
00050       ${"e_mont_cred$i"}=0;
00051   }
00052   $cn=DbConnect($p_dossier);
00053     // userPref contient la periode par default
00054     $userPref=GetUserPeriode($cn,$p_user);
00055     list ($l_date_start,$l_date_end)=GetPeriode($cn,$userPref);
00056     $e_op_rem=substr($l_date_start,2,8);
00057 
00058   if ( $p_array == null ) {
00059     $e_op_date="01";
00060     $e_comment="";
00061     $e_rapt="";
00062     $e_ech="";
00063     $e_sum_deb=0;
00064     $e_sum_cred=0;
00065   } else {
00066     foreach ( $p_array as $n=>$e) {
00067       ${"e_$n"}= $e;
00068   }
00069   }
00070   /* Get Jrn's properties */
00071   $l_line=GetJrnProperty($cn,$p_jrn);
00072   if ( $l_line == null ) return;
00073   echo '<DIV class="redcontent">';
00074   echo '<FORM NAME="encoding" ACTION="enc_jrn.php" METHOD="POST">';
00075 
00076   printf ('<H2 class="info"> %s %s </H2>',$l_line['jrn_def_name'],$l_line['jrn_def_code']);
00077 
00078   echo "<INPUT TYPE=HIDDEN NAME=\"MaxDeb\" VALUE=\"$p_MaxDeb\">";
00079   echo "<INPUT TYPE=HIDDEN NAME=\"MaxCred\" VALUE=\"$p_MaxCred\">";
00080   echo 'Date : <INPUT TYPE="TEXT" NAME="op_date" VALUE="'.
00081     $e_op_date.'" SIZE="4">'.
00082     $e_op_rem;
00083 
00084   // Comment
00085   echo '<br><SPAN>Comment  = <INPUT TYPE="TEXT" SIZE="70" NAME="comment" VALUE="'.$e_comment.'"></span>';
00086 
00087   // Chargement comptes disponibles
00088   if ( strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) {
00089     $valid_deb=split(" ",$l_line['jrn_def_class_deb']);
00090 
00091     // Creation query
00092     $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn where ";
00093     foreach ( $valid_deb as $item_deb) {
00094       if ( strlen (trim($item_deb))) {
00095         echo_debug('jrn.php',__LINE__,"l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb");
00096         if ( strstr($item_deb,"*") == true ) {
00097           $item_deb=strtr($item_deb,"*","%");
00098           $Sql=" pcm_val like '$item_deb' or";
00099         } else {
00100           $Sql=" pcm_val = '$item_deb' or";
00101         }
00102         $SqlDeb=$SqlDeb.$Sql;
00103       }
00104     }
00105     $SqlDeb = substr($SqlDeb,0,strlen($SqlDeb)-2)." order by pcm_val::text";
00106   } else
00107     {
00108       $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn  order by pcm_val::text";
00109     }
00110   echo_debug('jrn.php',__LINE__,"SqlDeb $SqlDeb");
00111   $Res=ExecSql($cn,$SqlDeb);
00112   $Count=pg_NumRows($Res);
00113 
00114   for ( $i=0;$i<$Count;$i++) {
00115     $l2_line=pg_fetch_array($Res,$i);
00116     $lib=substr($l2_line['pcm_lib'],0,35);
00117     $poste [$l2_line['pcm_val']]= $lib;
00118   }
00119 
00120   echo "<TABLE>";
00121   echo '<TR><TD><H2 class="info"> débit </H2></TD></TR>';
00122   for ( $i=0;$i < $p_MaxDeb;$i++) {
00123     echo "<tr>";
00124     echo "<TD>";
00125     printf ('<SELECT NAME="class_deb%d">',$i);
00126     foreach ( $poste as $key => $value){ 
00127       $selected="";
00128       if ( ${"e_class_deb$i"} == $key ) $selected="SELECTED";
00129       $a=sprintf('<OPTION VALUE="%s" %s >%s - % .40s',
00130              $key,
00131              $selected,
00132              $key,
00133              $value);
00134       echo $a;
00135     }
00136     echo "</SELECT>";
00137     printf ('</TD>');
00138 
00139     printf('<TD> Montant :<INPUT TYPE="TEXT" id="mont_deb%d" NAME="mont_deb%d" VALUE="%s" onChange="CheckTotal()"></TD>',
00140             $i,$i,${"e_mont_deb$i"},$i);
00141     echo "</tr>";
00142 
00143   }
00144   // Total debit
00145    echo '<TR><TD>';
00146    echo 'Total ';
00147    echo '</TD><TD>';
00148    echo '<input type="TEXT" NAME="sum_deb" VALUE="'.$e_sum_deb.'" onChange="CheckTotal()">';
00149    echo '</TD></TR>';
00150 if ( $p_update == 0 )  echo "<TR><TD> <INPUT TYPE=\"SUBMIT\" VALUE=\"+ de line\" NAME=\"add_line_deb\"></TD></TR>";
00151 
00152 
00153 
00154 
00155   echo '<TR><TD><H2 class="info"> crédit </H2> </TD></TR>';
00156   // Chargement comptes disponibles
00157   if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) {
00158     $valid_cred=split(" ",$l_line['jrn_def_class_cred']);
00159 
00160     // Creation query
00161     $SqlCred="select pcm_val,pcm_lib from tmp_pcmn where ";
00162     foreach ( $valid_cred as $item_cred) {
00163       if ( strlen (trim($item_cred))) {
00164         echo_debug('jrn.php',__LINE__,"l_line[jrn_def_class_cred] $l_line[jrn_def_class_cred] item_cred $item_cred");
00165         if ( strstr($item_cred,"*") == true ) {
00166           $item_cred=strtr($item_cred,"*","%");
00167           $Sql=" pcm_val like '$item_cred' or";
00168         } else {
00169           $Sql=" pcm_val = '$item_cred' or";
00170         }
00171         $SqlCred=$SqlCred.$Sql;
00172       }
00173     }
00174     $SqlCred = substr($SqlCred,0,strlen($SqlCred)-2)." order by pcm_val::text" ;
00175   } else
00176     {
00177       $SqlCred="select pcm_val,pcm_lib from tmp_pcmn  order by pcm_val::text";
00178     }
00179   echo_debug('jrn.php',__LINE__,"SqlCred $SqlCred");
00180   $Res=ExecSql($cn,$SqlCred);
00181   $Count=pg_NumRows($Res);
00182 
00183 
00184   for ( $i=0;$i<$Count;$i++) {
00185     $l2_line=pg_fetch_array($Res,$i);
00186     $lib=substr($l2_line['pcm_lib'],0,35);
00187     $poste_c[$l2_line['pcm_val']]=$lib;
00188   }
00189   for ( $i=0;$i < $p_MaxCred;$i++) {
00190     echo "<tr>";
00191     echo "<TD>";
00192     printf ('<SELECT NAME="class_cred%d">',$i);
00193     foreach ( $poste_c as $key => $value){ 
00194       $selected="";
00195       if ( ${"e_class_cred$i"} == $key ) $selected="SELECTED";
00196       $a=sprintf('<OPTION VALUE="%s" %s >%s - % .40s',
00197              $key,
00198              $selected,
00199              $key,
00200              $value);
00201       echo $a;
00202     }
00203         
00204     echo "</SELECT>";
00205     echo "</TD>";
00206 
00207     printf ('<TD> Montant :<INPUT TYPE="TEXT" id="mont_cred%d" NAME="mont_cred%d" VALUE="%s" onChange="CheckTotal()"></TD>',
00208             $i,$i,${"e_mont_cred$i"});
00209     echo "</tr>";
00210 
00211   }
00212   // Total Credit
00213   echo '<TR><TD>';
00214   echo 'Total';
00215   echo '</TD><TD>';
00216   echo '<input type="TEXT" NAME="sum_cred" VALUE="'.$e_sum_cred.'" onChange="CheckTotal()">';
00217   echo '</TD></TR>';
00218   echo "<TR><TD> <INPUT TYPE=\"SUBMIT\" VALUE=\"+ de line\" NAME=\"add_line_cred\"></TD></TR>";
00219   if ( isset ($_GET["PHPSESSID"]) ) {
00220     $sessid=$_GET["PHPSESSID"];
00221   }
00222   else {
00223     $sessid=$_POST["PHPSESSID"];
00224   }
00225 
00226   $search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchJrn(\''.$sessid."','rapt')\">";
00227   echo_debug('jrn.php',__LINE__,"search $search");
00228   // To avoid problem with unknown variable
00229   if ( ! isset ($e_rapt) ) {
00230         $e_rapt="";
00231   }
00232 
00233   echo '<TR><TD colspan="2">
00234          rapprochement : <INPUT TYPE="TEXT" name="rapt" value="'.$e_rapt.'">'.$search.'</TD></TR>';
00235   echo "</TABLE>";
00236 
00237   // To avoid problem with unknown variable
00238   if ( ! isset ($e_comment) ) {
00239         $e_comment="";
00240   }
00241  
00242 
00243 
00244   if ( $p_update==0) {
00245     echo '<input type="submit" Name="add_record" Value="Enregistre">';
00246   } else {
00247     echo '<input type="submit" Name="update_record" Value="Enregistre">';
00248   }
00249    echo '<input type="reset" Value="Efface">';
00250 
00251    // To avoid problem with unknown variable
00252     if ( ! isset ($e_sum_deb) ) {
00253                  $e_sum_deb=0;
00254     }
00255 
00256    // To avoid problem with unknown variable
00257      if ( ! isset ($e_sum_cred) ) {
00258                  $e_sum_cred=0;
00259       }
00260 
00261 
00262    echo '<SPAN ID="diff"></SPAN>';
00263   echo "</FORM>";
00264   echo '</DIV>';
00265   
00266 }

SetInternalCode p_cn,
p_grpt,
p_jrn
 

parm :

  • $p_cn connection

$p_grpt id in jr_grpt_id

  • $p_jrn jrn id jrn_def_id
  • $p_dossier dossier id gen :
    • return:

Definition at line 949 of file jrn.php.

References $num, $Res, ExecSql(), GetJrnProperty(), and NextSequence().

Referenced by RecordFin(), RecordInvoice(), RecordSell(), and TransferCSV().

00950 {
00951   //$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'")+1;
00952   $num = NextSequence($p_cn,'s_internal');
00953   $num=strtoupper(hexdec($num));
00954   $atype=GetJrnProperty($p_cn,$p_jrn);
00955   $type=$atype['jrn_def_code'];
00956   $internal_code=sprintf("%d%s-%s",$_SESSION['g_dossier'],$type,$num);
00957   $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal_code."' where ".
00958                " jr_grpt_id = ".$p_grpt);
00959   return $internal_code;
00960 }

UpdateJrn p_cn,
p_jr_id
 

Display the form to UPDATE account operation.

parm :

  • p_dossier

p_jrn

  • p_MaxDeb number of debit line
  • p_MaxCred " " credit " " - p_array array containing the others datas gen :
    • none return:
    • none

Definition at line 282 of file jrn.php.

References $a, $check, $col_vide, $file, $i, $r, $search, $sessid, echo_debug(), echo_error(), GetConcerned(), GetDataJrnJrId(), GetGrpt(), GetInternal(), name, return, and value.

00283 {
00284   echo_debug('jrn.php',__LINE__,"function UpdateJrn");
00285 
00286   $l_array=GetDataJrnJrId($p_cn,$p_jr_id);
00287   if ( $l_array == null ) {
00288     echo_error ("Not data found for UpdateJrn p_jr_id = $p_jr_id");
00289     return ;
00290   }
00291   // Javascript
00292   $r=JS_VIEW_JRN_MODIFY;
00293 
00294   // Build the form
00295   $col_vide="<TD></TD>";
00296   for ( $i =0 ; $i < sizeof($l_array); $i++) {
00297     $content=$l_array[$i] ;
00298 
00299       // for the first line
00300       if ( $i == 0 ) {
00301         $r.="<TABLE>";
00302         $r.="<TR>";
00303         // Date
00304         $r.="<TD>";
00305         $r.=$content['jr_date'];
00306         $r.="</TD>";
00307         // for upload document we need the grpt_id   
00308         $r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
00309 
00310         // comment can be changed
00311         $r.="<TD>";
00312         $r.='<INPUT TYPE="TEXT" name="comment" value="';
00313         $r.=$content['jr_comment'];
00314         $r.='" SIZE="25">';
00315         $r.="</TD>";
00316 
00317         // Internal
00318         $r.="<TD>";
00319         $r.=$content['jr_internal'];
00320         $r.="</TD>";
00321 
00322         if ( $content['jrn_def_type'] == 'ACH' or 
00323              $content['jrn_def_type'] == 'VEN' )
00324           {
00325             // Is Paid
00326             $r.="<TD>";
00327             $check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
00328             $r.='<TD>Payé <INPUT TYPE="CHECKBOX" name="is_paid" '.$check.'></TD>';
00329           }
00330         $r.="</TR>";
00331         $r.="</TABLE>";
00332         $r.="<TABLE>";
00333       }
00334       $r.="<TR>";
00335       if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
00336       //      $r.="<TD>".$content['j_debit']."</td>";
00337       
00338       $r.="<TD>".$content['j_poste']."</td>";
00339       if ( $content['j_debit'] == 't' ) $r.=$col_vide;
00340       $r.="<TD>".$content['vw_name']."</td>";
00341       if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
00342       $r.="<TD>".$content['j_montant']."</td>";
00343       $r.="</TR>";
00344 
00345       //    }//     foreach ($l_array[$i]  as $value=>$content) 
00346   }// for ( $i =0 ; $i < sizeof($l_array); $i++) 
00347     $file=new widget("file");
00348     $file->table=1;
00349         //document
00350     $r.='<TD>A effacer <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
00351     $r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s">%s</A>',
00352                 $content['jr_id'],
00353                 $content['jr_grpt_id'],
00354                 $content['jr_pj_name'])."</TD>";
00355     $r.="</TR></TABLE>";
00356     $r.="<hr>";
00357     $r.= "<table>"; 
00358     $r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
00359     $r.="</table>";
00360     $r.="<hr>";
00361 
00362   $r.="</table>";
00363   $r.="Total ".$content['jr_montant']."<br>";
00364   // show all the related operation
00365   $a=GetConcerned($p_cn,$content['jr_id']);
00366   
00367   if ( $a != null ) {
00368       $r.="<b>Operation concernée</b> <br>";
00369       if ( isset ($_GET["PHPSESSID"]) ) {
00370         $sessid=$_GET["PHPSESSID"];
00371       }
00372       else {
00373         $sessid=$_POST["PHPSESSID"];
00374       }
00375 
00376     $r.= '<div style="margin-left:30px;">';
00377     foreach ($a as $key => $element) {
00378       $r.=sprintf ('%s <INPUT TYPE="BUTTON" VALUE="Détail" onClick="viewDetail(\'%s\',\'%s\')">', 
00379                    GetInternal($p_cn,$element),GetGrpt($p_cn,$element),$sessid);
00380       $r.=sprintf('<INPUT TYPE="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',\'%s\')"><BR>',
00381                   $content['jr_id'],$element,$sessid);
00382     }//for
00383     $r.= "</div>";
00384   }// if ( $a != null ) {
00385 
00386   if ( isset ($_GET["PHPSESSID"]) ) {
00387     $sessid=$_GET["PHPSESSID"];
00388   }
00389   else {
00390     $sessid=$_POST["PHPSESSID"];
00391   }
00392   
00393   $search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchJrn(\''.$sessid."','rapt')\">";
00394 
00395   $r.= '<H2 class="info">rapprochement </H2> 
00396        <INPUT TYPE="TEXT" name="rapt" value="">'.$search;
00397   $r.='<input type="hidden" name="jr_id" value="'.$content['jr_id'].'">';
00398 
00399   //  echo $r;
00400   return $r;
00401 }

VerifData p_cn,
p_array,
p_user
 

Verify the data before inserting or updating.

parm :

  • p_cn connection

p_array array with all the values

  • p_user gen :
    • none return:
    • errorcode or ok

Definition at line 834 of file jrn.php.

References cmpDate(), echo_debug(), echo_error(), GetPeriode(), isDate(), name, and PeriodeClosed().

00835 {
00836   if ( ! isset ($p_cn) ||
00837        ! isset ($p_array)||
00838        ! isset ($p_user)||
00839        $p_array == null ){
00840     echo_error("JRN.PHP VerifData missing parameter");
00841     return BADPARM;
00842   }
00843   // Montre ce qu'on a encodé et demande vérif
00844   $next="";
00845   foreach ( $p_array as $name=>$element ) {
00846       echo_debug('jrn.php',__LINE__,"element $name -> $element ");
00847       // Sauve les données dans des variables
00848       ${"p_$name"}=$element;
00849     }
00850     // Verif Date
00851     if ( isDate($p_op_date) == null) {
00852       return BADDATE;
00853     }
00854     // userPref contient la periode par default
00855     $userPref=$p_user->GetPeriode();
00856     list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$userPref);
00857 
00858     // Date dans la periode active
00859     echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demandée $p_op_date");
00860     if ( cmpDate($p_op_date,$l_date_start)<0 || 
00861          cmpDate($p_op_date,$l_date_end)>0 )
00862       {
00863         return NOTPERIODE;
00864       }
00865     // Periode fermée 
00866     if ( PeriodeClosed ($p_cn,$userPref)=='t' )
00867       {
00868         return PERIODCLOSED;
00869       }
00870     $l_mont=0;
00871     if ( ! isset ($p_ech) ) $p_ech="";
00872 
00873     if ($p_ech!='' && isDate ( $p_ech) == null ){
00874       return INVALID_ECH;
00875     }
00876 
00877     $tot_deb= 0;
00878     $tot_cred= 0;
00879     for ( $i = 0; $i < $p_MaxCred; $i++) {
00880       if ( isset ( ${"p_mont_cred$i"} ))
00881         $tot_cred+=${"p_mont_cred$i"};
00882     }
00883     for ( $i = 0; $i < $p_MaxDeb; $i++) {
00884       if ( isset ( ${"p_mont_deb$i"} ))
00885         $tot_deb+=${"p_mont_deb$i"};
00886     }
00887     echo_debug('jrn.php',__LINE__,"Amont =      $tot_deb $tot_cred");
00888     if ( round($tot_deb,2) != round($tot_cred,2) ) { 
00889       return DIFF_AMOUNT;
00890     }
00891 
00892     return NOERROR;
00893 
00894 }

ViewJrn p_dossier,
p_user,
p_jrn,
p_url,
p_array = null
 

Vue des écritures comptables.

parm :

  • p_dossier,

p_user,

  • p_jrn
  • p_url for modif
  • array gen :
    • return:

Definition at line 583 of file jrn.php.

References $cn, $col_vide, $db, $l_id, $l_line, $MaxLine, $Res, $sessid, $sql, DbConnect(), echo_debug(), ExecSql(), FormatString(), GetJrnProp(), and isDate().

00583                                                                  {
00584   echo_debug('jrn.php',__LINE__,"function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) ");
00585   echo JS_VIEW_JRN_DETAIL;
00586   $db=sprintf("dossier%d",$p_dossier);
00587   $l_prop=GetJrnProp($p_dossier,$p_jrn);
00588   echo "<H2 class=\"info\">".$l_prop['jrn_def_name']."( ".$l_prop['jrn_def_code'].")"."</H2>";
00589   $cn=DbConnect($p_dossier);
00590   if ( $p_array == null) {
00591     include_once("preference.php");
00592     $l_periode=GetUserPeriode($cn,$p_user);
00593     $Res=ExecSql($cn,"select jr_id,j_id,jr_internal,to_char(j_date,'DD.MM.YYYY') as j_date,
00594                        j_montant,j_poste,pcm_lib,j_grpt,j_debit,j_centralized,j_tech_per,
00595                        pcm_lib
00596                    from jrnx inner join tmp_pcmn on j_poste=pcm_val
00597                              inner join jrn on jr_grpt_id=j_grpt
00598                    where 
00599                    j_jrn_def=$p_jrn and j_tech_per=$l_periode
00600                    order by j_id,j_grpt,j_debit desc");
00601   } else {
00602     // Construction Query 
00603     foreach ( $p_array as $key=>$element) {
00604       ${"l_$key"}=$element;
00605       echo_debug ("l_$key $element");
00606     }
00607     $sql="select j_id,to_char(j_date,'DD.MM.YYYY') as j_date,j_montant,j_poste,
00608                  pcm_lib,j_grpt,jr_id,j_debit,j_centralized,j_tech_per,jr_internal
00609                    from jrnx inner join tmp_pcmn on j_poste=pcm_val
00610                         inner join jrn on jr_grpt_id=j_grpt
00611                    where 
00612                    j_jrn_def=$p_jrn";
00613     $l_and="and ";
00614     if ( ereg("^[0-9]+$", $l_s_montant) || ereg ("^[0-9]+\.[0-9]+$", $l_s_montant) ) {
00615     $sql.=" and jr_montant $l_mont_sel $l_s_montant";
00616     }
00617     if ( isDate($l_date_start) != null ) {
00618       $sql.=$l_and." j_date >= to_date('".$l_date_start."','DD.MM.YYYY')";
00619     }
00620     if ( isDate($l_date_end) != null ) {
00621       $sql.=$l_and." j_date <= to_date('".$l_date_end."','DD.MM.YYYY')";
00622     }
00623     $l_s_comment=FormatString($l_s_comment);
00624     if ( $l_s_comment != null ) {
00625       $sql.=$l_and." upper(jr_comment) like upper('%".$l_s_comment."%') ";
00626     }
00627 
00628     $sql.=" order by j_id,j_grpt,j_debit desc";
00629     echo_debug ("search query is $sql");
00630     $Res=ExecSql($cn,$sql);
00631   }
00632   $MaxLine=pg_NumRows($Res);
00633   if ( $MaxLine == 0 ) return;
00634   $col_vide="<TD></TD>";
00635   echo '<TABLE ALIGN="center">';
00636   $l_id=0;
00637   for ( $i=0; $i < $MaxLine; $i++) {
00638     $l_line=pg_fetch_array($Res,$i);
00639     if ( $l_line['j_debit'] == 't' ) {
00640       echo '<TR style="background-color:lightblue;">';
00641     }
00642     else {
00643       echo '<TR>';
00644     }
00645     if ( $l_id == $l_line['j_grpt'] ) {
00646       echo $col_vide.$col_vide.$col_vide;
00647     } else {
00648       echo "<TD>";
00649       echo $l_line['j_date'];
00650       echo "</TD>";
00651       
00652       
00653           echo "<TD>";
00654           if ( isset ($_GET["PHPSESSID"])  ) {
00655             $sessid=$_GET["PHPSESSID"];
00656           } else {
00657             $sessid=$_POST["PHPSESSID"];
00658           }
00659 
00660           list($z_type,$z_num,$num_op)=split("-",$l_line['jr_internal']);
00661           printf ('<INPUT TYPE="BUTTON" VALUE="%s" onClick="viewDetail(\'%s\',\'%s\')">', 
00662                   $num_op,$l_line['j_grpt'],$sessid);
00663           //      echo $num_op;
00664           echo "</TD>";
00665 
00666 
00667           // no modification only cancel of wrong op.
00668           echo '<TD class="mlltitle">';
00669           echo "<A class=\"mtitle\" HREF=$p_url?action=update&line=".$l_line['jr_id'].">";
00670           echo "M";
00671           echo "</A></TD>";
00672       $l_id=$l_line['j_grpt'];
00673     }
00674     if ($l_line['j_debit']=='f')
00675       echo $col_vide;
00676     
00677     echo '<TD>';
00678     echo $l_line['j_poste'];
00679     echo '</TD>';
00680 
00681     echo '<TD>';
00682     echo $l_line['pcm_lib'];
00683     echo '</TD>';
00684     echo $col_vide;
00685 
00686     echo '<TD>';
00687     echo $l_line['j_montant'];
00688     echo '</TD>';
00689 
00690     if ( $l_line['j_debit']=='t')
00691       echo $col_vide;
00692 
00693     echo "</TR>";
00694 
00695 
00696   }
00697   echo '</TABLE>';
00698 }

ViewRec p_array = null  ) 
 

debug function to be dropped

parm :

  • gen :
  • return:

Definition at line 415 of file jrn.php.

References echo_debug().

00415                                   {
00416   if ($p_array == null) { 
00417     echo_debug('jrn.php',__LINE__,"p_array is null");
00418   }else {
00419     foreach ( $p_array as $n=>$e) {
00420       echo_debug('jrn.php',__LINE__,"a[$n]= $e");
00421     }
00422  
00423   }
00424 }

ViewRecord p_dossier,
p_jrn,
p_id,
p_MaxDeb,
p_MaxCred,
p_array
 

View the added operation.

parm :

  • p_dossier

p_jrn

  • p_id
  • p_MaxDeb
  • p_MaxCred
  • p_array gen :
    • none return:
    • none

Definition at line 457 of file jrn.php.

References $col_vide, echo_debug(), GetJrnProp(), GetPosteLibelle(), and table.

00458 {
00459   echo_debug ("ViewRecord : $p_dossier");
00460   echo_debug('jrn.php',__LINE__,"function ViewRecord ($p_dossier,$p_jrn,$p_id,$p_MaxCred,$p_MaxDeb,$p_array)");
00461   foreach ( $p_array as $key=>$element) {
00462     ${"e_$key"}=$element;
00463     echo_debug('jrn.php',__LINE__," e_$key=$element;");
00464 
00465   }
00466   // Get Jrn's Prop
00467   $l_prop=GetJrnProp($p_dossier,$p_jrn);
00468 
00469   include_once("poste.php");
00470   if ( $l_prop == null ) return;
00471   $col_vide="<TD></TD>";
00472   echo '<TABLE ALIGN=CENTER BORDER=1 style="border-style:groove">';
00473   echo '<TR>';
00474   echo "<TD>". $l_prop['jrn_def_name']."(".$l_prop['jrn_def_code'].") </TD>";
00475   echo "<TD> Date : $e_op_date</TD>";
00476   echo "</TR>";
00477   echo "</TABLE>";
00478 
00479 
00480   echo "<table width=600 border=0>";
00481   echo "<TR><TD>operation $p_id</TD></TR>";
00482   for ($i = 0; $i < $p_MaxDeb;$i++) {
00483     //Deb
00484     if ( strlen(trim(${"e_mont_deb$i"})) > 0 && ${"e_mont_deb$i"} > 0 ) {
00485       $class=GetPosteLibelle($p_dossier,${"e_class_deb$i"});
00486 
00487       echo '<TR style="background-color:lightblue"><TD>'.${"e_class_deb$i"}."</TD>$col_vide<TD> $class </TD> <TD>".${"e_mont_deb$i"}."</TD>$col_vide</TR>";
00488     }
00489   }
00490 
00491   // Cred
00492   for ($i = 0; $i < $p_MaxCred;$i++) {
00493     if ( strlen(trim(${"e_mont_cred$i"})) > 0 && ${"e_mont_cred$i"} > 0 ) {
00494       $class=GetPosteLibelle($p_dossier,${"e_class_cred$i"});
00495       
00496       echo '<TR style="background-color:lightgreen;">'.$col_vide.'<TD>'.${"e_class_cred$i"}."</TD><TD> $class </TD>$col_vide <TD>".${"e_mont_cred$i"}."</TD></TR>";
00497     }
00498   }
00499   echo "<TR style=\"background-color:lightgray\">";
00500   echo $col_vide;
00501   echo $col_vide;
00502   echo "<TD align=\"center\"> Total</TD>";
00503   echo "<TD> $e_sum_deb</TD><TD> $e_sum_cred</TD>";
00504   echo "</TABLE>";
00505   // Bouton again
00506   echo '<table align="center">';
00507   echo '<TR><TD class="mtitle">';
00508   echo ' <A class="mtitle" HREF="enc_jrn.php?action=record&max_deb='.$l_prop['jrn_deb_max_line'].'&max_cred='.$l_prop['jrn_cred_max_line'].'&p_jrn='.$p_jrn.'"> Ajouter</A>';
00509   echo '</TD></TR></TABLE>';
00510 }