noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_acc_operation.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS 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  *   NOALYSS 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 NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief  this file match the tables jrn & jrnx the purpose is to
00024  *   remove or save accountant writing to these table.
00025  */
00026 require_once ('class_user.php');
00027 require_once('class_acc_ledger.php');
00028 
00029 /*! \brief  this file match the tables jrn & jrnx the purpose is to
00030  *   remove or save accountant writing to these table.
00031  *
00032  */
00033 class Acc_Operation
00034 {
00035     var $db;                            /*!< database connx */
00036     var $jr_id;         /*!< pk of jrn */
00037     var $jrn_id;                        /*!< jrn_def_id */
00038     var $debit;                 /*!< debit or credit */
00039     var $user;                  /*!< current user */
00040     var $jrn;                   /*!< the ledger to use */
00041     var $poste;                 /*!< account  */
00042     var $date;                  /*!< the date */
00043     var $periode;                       /*!< periode to use */
00044     var $amount;                        /*!< amount of the operatoin */
00045     var $grpt;                  /*!< the group id */
00046     var $date_paid;
00047     /*!
00048      * \brief constructor set automatically the attributes user and periode
00049      * \param $p_cn the databse connection
00050      */
00051     function __construct($p_cn)
00052     {
00053         global $g_user;
00054         $this->db=$p_cn;
00055         $this->qcode="";
00056         $this->user=$_SESSION['g_user'];
00057         $this->periode=$g_user->get_periode();
00058         $this->jr_id=0;
00059     }
00060     /**
00061      *@brief retrieve the grpt_id from jrn for a jr_id
00062      *@return jrn.jr_grpt_id or an empty string if not found
00063      */
00064     function seek_group()
00065     {
00066         $ret=$this->db->get_value('select jr_grpt_id from jrn where jr_id=$1',
00067                                   array($this->jr_id));
00068         return $ret;
00069     }
00070     /**
00071      *@brief  Insert into the table Jrn
00072      *The needed data are :
00073      * - this->date
00074      * - this->amount
00075      * - this->poste
00076      * - this->grpt
00077      * - this->jrn
00078      * - this->type ( debit or credit)
00079      * - this->user
00080      * - this->periode
00081      * - this->qcode
00082      * - this->desc optional
00083      *@note if the amount is less than 0 then side changes, for example debit becomes
00084      *a credit and vice versa
00085      *@return jrnx.j_id
00086      */
00087 
00088     function insert_jrnx()
00089     {
00090       if ( $this->poste == "") { return false; throw new  Exception (__FILE__.':'.__LINE__.' Poste comptable vide');}
00091         /* for negative amount the operation is reversed */
00092         if ( $this->amount < 0 )
00093         {
00094             $this->type=($this->type=='d')?'c':'d';
00095         }
00096         $this->amount=abs($this->amount);
00097         $debit=($this->type=='c')?'false':'true';
00098         $this->desc=(isset($this->desc))?$this->desc:'';
00099         $Res=$this->db->exec_sql("select insert_jrnx
00100                                  ($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
00101                                  array(
00102                                      $this->date, //$1
00103                                      round($this->amount,2), //$2
00104                                      $this->poste, //$3
00105                                      $this->grpt, //$4
00106                                      $this->jrn, //$5
00107                                      $debit, //$6
00108                                      $this->user, //$7
00109                                      $this->periode, //$8
00110                                      $this->qcode, // $9
00111                                      $this->desc)); //$10
00112         if ( $Res===false) return $Res;
00113         $this->jrnx_id=$this->db->get_current_seq('s_jrn_op');
00114         return $this->jrnx_id;
00115 
00116     }
00117     /*!\brief set the pj of a operation in jrn. the jr_id must be set
00118      *\note if the jr_id it fails
00119      */
00120     function set_pj()
00121     {
00122         if ( strlen(trim($this->pj)) == 0 )
00123         {
00124             $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
00125             $this->db->exec_sql($sql,array(null,$this->jr_id));
00126             return '';
00127         }
00128         /* is pj uniq ? */
00129         if ( $this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
00130                                   array($this->pj,$this->jrn)
00131                                  ) == 0 )
00132         {
00133             $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
00134             $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
00135         }
00136         else
00137         {
00138             /* get pref */
00139             $pref=$this->db->get_value("select jrn_def_pj_pref from jrn_def where jrn_def_id=$1",
00140                                        array($this->jrn));
00141             /*  try another seq */
00142             $flag=0;
00143             $limit=100;
00144             while ( $flag == 0 )
00145             {
00146                 /*  limit the search to $limit */
00147                 if ( $limit < 1 )
00148                 {
00149                     $this->pj='';
00150                     $flag=2;
00151                     break;
00152                 }
00153 
00154                 $seq=$this->db->get_next_seq('s_jrn_pj'.$this->jrn);
00155                 $this->pj=$pref.$seq;
00156 
00157                 /* check if the new pj numb exist */
00158                 $c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
00159                                         array($this->pj,$this->jrn)
00160                                        );
00161                 if ( $c == 0 )
00162                 {
00163                     $flag=1;
00164                     break;
00165                 }
00166                 $limit--;
00167             }
00168             /* a pj numb is found */
00169             if ( $flag == 1 )
00170             {
00171                 $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
00172                 $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
00173             }
00174         }
00175         return $this->pj;
00176     }
00177 
00178     /*!
00179      *\brief  Insert into the table Jrn, the amount is computed from jrnx thanks the
00180      *        group id ($p_grpt)
00181      *
00182      * \return  sequence of jr_id
00183      *
00184      */
00185 
00186     function insert_jrn()
00187     {
00188         $p_comment=$this->desc;
00189 
00190         $diff=$this->db->get_value("select check_balance ($1)",array($this->grpt));
00191         if ( $diff != 0 )
00192         {
00193 
00194             echo "Erreur : balance incorrecte :diff = $diff";
00195             return false;
00196         }
00197 
00198         $echeance=( isset( $this->echeance) && strlen(trim($this->echeance)) != 0)?$this->echeance:null;
00199         if ( ! isset($this->mt) )
00200         {
00201             $this->mt=microtime(true);
00202         }
00203         // if amount == -1then the triggers will throw an error
00204         //
00205         $Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,".
00206                                  "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt)   values (".
00207                                  "$1,$2,$3,".
00208                                  "to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8)",
00209                                  array ($this->jrn, $this->amount,$p_comment,
00210                                         $this->date,$echeance,$this->grpt,$this->periode,$this->mt)
00211                                 );
00212         if ( $Res == false)  return false;
00213         $this->jr_id=$this->db->get_current_seq('s_jrn');
00214         return $this->jr_id;
00215     }
00216     /*!
00217      * \brief  Return the internal value, the property jr_id must be set before
00218      *
00219      * \return  null si aucune valeur de trouv
00220      *
00221      */
00222     function get_internal()
00223     {
00224         if ( ! isset($this->jr_id) )
00225             throw new Exception('jr_id is not set',1);
00226         $Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
00227         if ( Database::num_row($Res) == 0 ) return null;
00228         $l_line=Database::fetch_array($Res);
00229         $this->jr_internal= $l_line['jr_internal'];
00230         return $this->jr_internal;
00231     }
00232     /*!\brief search an operation thankx it internal code
00233      * \param internal code
00234      * \return 0 ok -1 nok
00235      */
00236     function seek_internal($p_internal)
00237     {
00238         $res=$this->db->exec_sql('select jr_id from jrn where jr_internal=$1',
00239                                  array($p_internal));
00240         if ( Database::num_row($Res) == 0 ) return -1;
00241         $this->jr_id=Database::fetch_result($Res,0,0);
00242         return 0;
00243     }
00244     /*!\brief retrieve data from jrnx
00245       *\note the data are filtered by the access of the current user
00246      * \return an array
00247      */
00248     function get_jrnx_detail()
00249     {
00250         global $g_user;
00251         $filter_sql=$g_user->get_ledger_sql('ALL',3);
00252         $filter_sql=str_replace('jrn_def_id','jr_def_id',$filter_sql);
00253         if ( $this->jr_id==0 ) return;
00254         $sql=" select  jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
00255              vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
00256              " from jrnx join jrn on (jr_grpt_id=j_grpt)
00257              join tmp_pcmn on (j_poste=pcm_val)
00258              left join vw_fiche_attr on (j_qcode=quick_code)
00259              where
00260              jr_id=$1 and $filter_sql order by j_debit desc";
00261         $res=$this->db->exec_sql($sql,array($this->jr_id));
00262         if ( Database::num_row ($res) == 0 ) return array();
00263         $all=Database::fetch_all($res);
00264         return $all;
00265     }
00266     /*!\brief add a comment to the line (jrnx.j_text) */
00267     function update_comment($p_text)
00268     {
00269         $sql="update jrnx set j_text=$1 where j_id=$2";
00270         $this->db->exec_sql($sql,array($p_text,$this->jrnx_id));
00271     }
00272     /*!\brief add a comment to the operation (jrn.jr_text) */
00273     function operation_update_comment($p_text)
00274     {
00275         $sql="update jrn set jr_comment=$1 where jr_id=$2";
00276         $this->db->exec_sql($sql,array($p_text,$this->jr_id));
00277     }
00278     /*!\brief add a limit of payment to the operation (jrn.jr_ech) */
00279     function operation_update_date_limit($p_text)
00280     {
00281         if ( isDate($p_text) == null )
00282         {
00283             $p_text=null;
00284         }
00285         $sql="update jrn set jr_ech=to_date($1,'DD.MM.YYYY') where jr_id=$2";
00286         $this->db->exec_sql($sql,array($p_text,$this->jr_id));
00287     }
00288     /*!\brief return the jrn_def_id from jrn */
00289     function get_ledger()
00290     {
00291         $sql="select jr_def_id from jrn where jr_id=$1";
00292         $row=$this->db->get_value($sql,array($this->jr_id));
00293         return $row;
00294     }
00295     /*!\brief display_jrnx_detail : get the data from get_jrnx_data and
00296        return a string with HTML code
00297      * \param table(=0 no code for table,1 code for table,2 code for CSV)
00298 
00299     */
00300     function display_jrnx_detail($p_table)
00301     {
00302         $show=$this->get_jrnx_detail();
00303 
00304         $r='';
00305         $r_notable='';
00306         $csv="";
00307         foreach ($show as $l)
00308         {
00309             $border="";
00310             if ( $l['j_poste'] == $this->poste || ($l['j_qcode']==$this->qcode && trim($this->qcode) != ''))
00311                 $border=' class="highlight"';
00312             $r.='<tr '.$border.'>';
00313             $r.='<td>';
00314             $a=$l['j_qcode'];
00315             
00316             $r_notable.=$a;
00317             $r.=$a;
00318             $csv.='"'.$a.'";';
00319             $r.='</td>';
00320 
00321             $r.='<td  '.$border.'>';
00322             $a=$l['j_poste'];
00323             $r_notable.=$a;
00324             $r.=$a;
00325             $csv.='"'.$a.'";';
00326             $r.='</td>';
00327 
00328             $r.='<td  '.$border.'>';
00329             //       $a=($l['vw_name']=="")?$l['j_qcode']:$l['pcm_lib'];
00330             $a=(strlen(trim($l['j_qcode']))==0)?$l['pcm_lib']:$l['vw_name'];
00331             $r_notable.=$a;
00332             $r.=h($a);
00333             $csv.='"'.$a.'";';
00334             $r.='</td>';
00335 
00336             $r.='<td  '.$border.'>';
00337             $a=$l['j_montant'];
00338             $r_notable.=$a;
00339             $r.=$a;
00340             $csv.=$a.';';
00341             $r.='</td>';
00342 
00343             $r.='<td  '.$border.'>';
00344             $a=$l['debit'];
00345             $r_notable.=$a;
00346             $r.=$a;
00347             $csv.='"'.$a.'"';
00348 
00349             $csv.="\r\n";
00350             $r.='</td>';
00351             $r.='<td  '.$border.'>';
00352             $a=($l['letter']!=-1)?$l['letter']:'';
00353             $r_notable.=$a;
00354             $r.=$a;
00355             $csv.='"'.$a.'"';
00356 
00357             $csv.="\r\n";
00358             $r.='</td>';
00359 
00360 
00361             $r.='</tr>';
00362         }
00363         switch ($p_table)
00364         {
00365         case 1:
00366             return $r;
00367             break;
00368         case 0:
00369             return $r_notable;
00370             break;
00371         case 2:
00372             return $csv;
00373         }
00374         return "ERROR PARAMETRE";
00375     }
00376     /*!
00377      * @brief  Get data from jrnx where p_grpt=jrnx(j_grpt)
00378      *
00379      * @param connection
00380      * @return array of 3 elements
00381      *  - First Element is an array
00382     @verbatim
00383     Array
00384     (
00385         [op_date] => 01.12.2009
00386         [class_cred0] => 7000008
00387         [mont_cred0] => 8880.0000
00388         [op_cred0] => 754
00389         [text_cred0] =>
00390         [jr_internal] => 23VEN-01-302
00391         [comment] =>
00392         [ech] =>
00393         [jr_id] => 302
00394         [jr_def_id] => 2
00395         [class_deb0] => 4000005
00396         [mont_deb0] => 10744.8000
00397         [text_deb0] =>
00398         [op_deb0] => 755
00399         [class_cred1] => 4511
00400         [mont_cred1] => 1864.8000
00401         [op_cred1] => 756
00402         [text_cred1] =>
00403     )
00404     @endverbatim
00405      *  - Second  : number of line with debit
00406      *  - Third  : number of line with credit
00407      */
00408     function get_data ($p_grpt)
00409     {
00410         $Res=$this->db->exec_sql("select
00411                                  to_char(j_date,'DD.MM.YYYY') as j_date,
00412                                  j_text,
00413                                  j_debit,
00414                                  j_poste,
00415                                  coalesce(j_qcode,'-') as qcode,
00416                                  j_montant,
00417                                  j_id,
00418                                  jr_comment,
00419                                  to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
00420                                  to_char(jr_date,'DD.MM.YYYY') as jr_date,
00421                                  jr_id,jr_internal,jr_def_id,jr_pj
00422                                  from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$1",array($p_grpt));
00423         $MaxLine=Database::num_row($Res);
00424         if ( $MaxLine == 0 ) return null;
00425         $deb=0;
00426         $cred=0;
00427         for ( $i=0; $i < $MaxLine; $i++)
00428         {
00429 
00430             $l_line=Database::fetch_array($Res,$i);
00431             $l_array['op_date']=$l_line['j_date'];
00432             if ( $l_line['j_debit'] == 't' )
00433             {
00434                 $l_class=sprintf("class_deb%d",$deb);
00435                 $l_montant=sprintf("mont_deb%d",$deb);
00436                 $l_text=sprintf("text_deb%d",$deb);
00437                 $l_qcode=sprintf("qcode_deb%d",$deb);
00438                 $l_array[$l_class]=$l_line['j_poste'];
00439                 $l_array[$l_montant]=$l_line['j_montant'];
00440                 $l_array[$l_text]=$l_line['j_text'];
00441                 $l_array[$l_qcode]=$l_line['qcode'];
00442                 $l_id=sprintf("op_deb%d",$deb);
00443                 $l_array[$l_id]=$l_line['j_id'];
00444                 $deb++;
00445             }
00446             if ( $l_line['j_debit'] == 'f' )
00447             {
00448                 $l_class=sprintf("class_cred%d",$cred);
00449                 $l_montant=sprintf("mont_cred%d",$cred);
00450                 $l_array[$l_class]=$l_line['j_poste'];
00451                 $l_array[$l_montant]=$l_line['j_montant'];
00452                 $l_id=sprintf("op_cred%d",$cred);
00453                 $l_array[$l_id]=$l_line['j_id'];
00454                 $l_text=sprintf("text_cred%d",$cred);
00455                 $l_array[$l_text]=$l_line['j_text'];
00456                 $l_qcode=sprintf("qcode_cred%d",$cred);
00457                 $l_array[$l_qcode]=$l_line['qcode'];
00458                 $cred++;
00459             }
00460             $l_array['jr_internal']=$l_line['jr_internal'];
00461             $l_array['comment']=$l_line['jr_comment'];
00462             $l_array['ech']=$l_line['jr_ech'];
00463             $l_array['jr_id']=$l_line['jr_id'];
00464             $l_array['jr_def_id']=$l_line['jr_def_id'];
00465         }
00466         return array($l_array,$deb,$cred);
00467     }
00468     /**
00469     *@brief retrieve data from jrnx and jrn
00470     *@return return an object
00471     *@note
00472     *@see
00473     @code
00474 
00475     @endcode
00476     */
00477     function get()
00478     {
00479         $ret=new Acc_Misc($this->db,$this->jr_id);
00480         $ret->get();
00481         return $ret;
00482     }
00483     /**
00484      *@brief retrieve data from the table QUANT_*
00485      *@return return an object or null if there is no
00486      * data from the QUANT table
00487      *@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc
00488      */
00489     function get_quant()
00490     {
00491         $ledger_id=$this->get_ledger();
00492         if ( $ledger_id=='') throw new Exception('Journal non trouvé');
00493         $oledger=new Acc_Ledger($this->db,$ledger_id);
00494 
00495         // retrieve info from jrn_info
00496 
00497 
00498         switch($oledger->get_type())
00499         {
00500         case 'VEN':
00501             $ret=new Acc_Sold($this->db,$this->jr_id);
00502             break;
00503         case 'ACH':
00504             $ret=new Acc_Purchase($this->db,$this->jr_id);
00505             break;
00506         case 'FIN':
00507             $ret=new Acc_Fin($this->db,$this->jr_id);
00508             break;
00509         default:
00510                         $ret=new Acc_Misc($this->db,$this->jr_id);
00511                         break;
00512         }
00513         $ret->get();
00514         if ( empty($ret->det->array))
00515         {
00516             $ret=new Acc_Misc($this->db,$this->jr_id);
00517             $ret->get();
00518         }
00519         $ret->get_info();
00520         return $ret;
00521     }
00522     /**
00523      * @brief retrieve info from the jrn_info, create 2 new arrays
00524      * obj->info->command and obj->info->other
00525      * the columns are the idx
00526      */
00527     function get_info()
00528     {
00529         $this->info=new stdClass();
00530         // other info
00531         $array=$this->db->get_value("select ji_value from jrn_info where
00532             jr_id=$1 and id_type=$2",array($this->jr_id,'OTHER'));
00533         $this->info->other= $array;
00534 
00535         // Bon de commande
00536         $array=$this->db->get_value("select ji_value from jrn_info where
00537             jr_id=$1 and id_type=$2",array($this->jr_id,'BON_COMMANDE'));
00538         $this->info->command=  $array;
00539 
00540     }
00541     /**
00542      * Save into jrn_info
00543      * @param $p_info msg to save
00544      * @param $p_type is OTHER or BON_COMMAND
00545      */
00546     function save_info($p_info,$p_type)
00547     {
00548         if ( ! in_array($p_type,array('OTHER','BON_COMMANDE'))) return;
00549         if (trim($p_info)=="") {
00550             $this->db->exec_sql('delete from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
00551             return;
00552         }
00553         $exist=$this->db->get_value('select count(ji_id) from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
00554         if ( $exist == "0" ) {
00555             //insert into jrn_info
00556             $this->db->exec_sql('insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)',
00557                     array($this->jr_id,$p_type,$p_info));
00558         } elseif ( $exist == 1) {
00559             //update
00560             $this->db->exec_sql('update jrn_info set ji_value=$3 where jr_id=$1 and id_type=$2',
00561                     array($this->jr_id,$p_type,$p_info));
00562         }
00563     }
00564     static function test_me()
00565     {
00566         $_SESSION['g_user']='phpcompta';
00567         $_SESSION['g_pass']='dany';
00568         global $g_user;
00569         $cn=new Database(dossier::id());
00570         $g_user=new User($cn);
00571         $a=new Acc_Operation($cn);
00572         $a->jr_id=1444;
00573         $b=$a->get_quant();
00574         var_dump($b);
00575     }
00576 }
00577 /////////////////////////////////////////////////////////////////////////////
00578 class Acc_Detail extends Acc_Operation
00579 {
00580     function __construct($p_cn,$p_jrid=0)
00581     {
00582         parent::__construct($p_cn);
00583         $this->jr_id=$p_jrid;
00584         $this->det=new stdClass();
00585     }
00586     /**
00587      *@brief retrieve some common data from jrn as
00588      * the datum, the comment,payment limit...
00589      */
00590     function get()
00591     {
00592         $sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
00593              jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,jr_ech,
00594              jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
00595              jr_pj_number, jr_mt,jr_rapt,jr_date_paid
00596              FROM jrn where jr_id=$1";
00597         $array=$this->db->get_array($sql,array($this->jr_id));
00598         if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée');
00599         foreach ($array[0] as $key=>$val)
00600         {
00601             $this->det->$key=$val;
00602         }
00603         $sql="select n_text from jrn_note where jr_id=$1";
00604         $this->det->note=$this->db->get_value($sql,array($this->jr_id));
00605         $this->det->note=strip_tags($this->det->note);
00606     }
00607 }
00608 /////////////////////////////////////////////////////////////////////////////
00609 /**
00610  *@brief this class manage data from the JRNX and JRN
00611  * table
00612  *@note Data member are the column of the table
00613  */
00614 class Acc_Misc extends Acc_Detail
00615 {
00616     var $signature;             /*!< signature of the obj ODS */
00617     var $array;         /*!< an array containing the data from JRNX */
00618     function __construct($p_cn,$p_jrid=0)
00619     {
00620         parent::__construct($p_cn,$p_jrid);
00621         $this->signature='ODS';
00622         $this->det=new stdClass();
00623     }
00624     function get()
00625     {
00626         parent::get();
00627         $sql="SELECT j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,
00628              j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_date,
00629              j_tech_per, j_qcode
00630              FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste";
00631         $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
00632     }
00633 }
00634 /////////////////////////////////////////////////////////////////////////////
00635 /**
00636  *@brief this class manage data from the QUANT_SOLD
00637  * table
00638  *@note Data member are the column of the table
00639  */
00640 class Acc_Sold extends Acc_Detail
00641 {
00642     function __construct($p_cn,$p_jrid=0)
00643     {
00644         parent::__construct($p_cn,$p_jrid);
00645         $this->signature='VEN';
00646         $this->det=new stdClass();
00647     }
00648     function get()
00649     {
00650         parent::get();
00651         $sql="SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat,
00652              qs_vat_code, qs_client, qs_valid, j_id,j_text,qs_vat_sided
00653              FROM quant_sold  join jrnx using(j_id) where j_grpt=$1";
00654         $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
00655     }
00656     
00657 }
00658 /////////////////////////////////////////////////////////////////////////////
00659 /**
00660  *@brief this class manage data from the QUANT_PURCHASE
00661  * table
00662  *@note Data member are the column of the table
00663 
00664  */
00665 class Acc_Purchase extends Acc_Detail
00666 {
00667     function __construct($p_cn,$p_jrid=0)
00668     {
00669         parent::__construct($p_cn,$p_jrid);
00670         $this->signature='ACH';
00671     }
00672 
00673     function get()
00674     {
00675         parent::get();
00676         $sql="SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat,
00677              qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier,
00678              qp_valid, qp_dep_priv,j_text,qp_vat_sided
00679              FROM quant_purchase  join jrnx using(j_id) where j_grpt=$1";
00680         $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
00681     }
00682 }
00683 /////////////////////////////////////////////////////////////////////////////
00684 /**
00685  *@brief this class manage data from the QUANT_FIN
00686  * table
00687  *@note Data member are the column of the table
00688  */
00689 class Acc_Fin extends Acc_Detail
00690 {
00691     function __construct($p_cn,$p_jrid=0)
00692     {
00693         parent::__construct($p_cn,$p_jrid);
00694         $this->signature='FIN';
00695     }
00696 
00697     function get()
00698     {
00699         parent::get();
00700         $sql="SELECT qf_id, qf_bank, jr_id, qf_other, qf_amount
00701              FROM quant_fin where jr_id = $1";
00702         $this->det->array=$this->db->get_array($sql,array($this->jr_id));
00703     }
00704 }
 All Data Structures Namespaces Files Functions Variables Enumerations