noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_gestion_purchase.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 Definition of the class gestion_purchase
00024  */
00025 
00026 /*! \brief this object handles the table quant_purchase
00027  *
00028  */
00029 require_once ('class_gestion_table.php');
00030 
00031 
00032 class gestion_purchase extends gestion_table
00033 {
00034     var $qp_id;                                 /*!< id */
00035     var $qp_internal;                           /*!< internal code */
00036     var $qp_fiche;                                      /*!< card id (fiche.f_id) */
00037     var $qp_quantite;                           /*!< quantity */
00038     var $qp_price;                                      /*!< quantity */
00039     var $qp_vat;                                        /*!< vat amount */
00040     var $qp_vat_code;                           /*!< vat_code */
00041     var $qp_nd_amount;                          /*!< no deductible */
00042     var $qp_nd_tva;                             /*!< tva not deductible */
00043     var $qp_nd_tva_recup;                       /*!< tva ded via taxe */
00044     var $qp_supplier;                           /*!< supplier code (f_id) */
00045     var $qp_valid;
00046     var $j_id;                                          /*!< jrnx.j_id
00047                                                                   */
00048     var $qp_dep_priv;           /*!< private purchase */
00049     /*!\brief return an array of gestion_table, the object are
00050      * retrieved thanks the qs_internal
00051      */
00052     function get_list()
00053     {
00054         if ($this->qp_internal=="")
00055             exit (__FILE__.__LINE__." qs_internal est vide");
00056         $sql="select  qp_id,
00057              qp_internal,
00058              qp_fiche,
00059              qp_quantite,
00060              qp_price,
00061              qp_vat,
00062              qp_vat_code,
00063              tva_rate,
00064              tva_label,
00065              qp_nd_amount,
00066              qp_nd_tva,
00067              qp_nd_tva_recup,
00068              qp_supplier,
00069              j_id,
00070              qp_dep_priv
00071              from quant_purchase left join tva_rate on (qp_vat_code=tva_id)
00072              where qp_internal='".$this->qp_internal."'";
00073         $ret=$this->db->exec_sql($sql);
00074         // $res contains all the line
00075         $res=Database::fetch_all($ret);
00076 
00077         if ( sizeof($res)==0) return null;
00078         $count=0;
00079         foreach ($res as $row)
00080         {
00081             $t_gestion_purchase=new gestion_purchase($this->db);
00082             foreach ($row as $idx=>$value)
00083             $t_gestion_purchase->$idx=$value;
00084             $array[$count]=clone $t_gestion_purchase;
00085             $count++;
00086         }
00087         return $array;
00088     }
00089     function search_by_jid($p_jid)
00090     {
00091         $res=$this->db->exec_sql("select qp_id from quant_purchase where j_id=".$p_jid);
00092 
00093         if ( Database::num_row($res) == 1)
00094             $this->qp_id=Database::fetch_result($res,0,0);
00095         else
00096             $this->qp_id=0;
00097     }
00098     function load()
00099     {
00100         $sql="select  qp_id,
00101              qp_internal,
00102              qp_fiche,
00103              qp_quantite,
00104              qp_price,
00105              qp_vat,
00106              qp_vat_code,
00107              qp_nd_amount,
00108              qp_nd_tva,
00109              qp_nd_tva_recup,
00110              qp_supplier,
00111              j_id,
00112              qp_dep_priv
00113              from quant_purchase
00114              where qp_id=".$this->qp_id;
00115         $ret=$this->db->exec_sql($sql);
00116         // $res contains all the line
00117         $res=Database::fetch_all($ret);
00118 
00119         if ( empty($res) ) return null;
00120         foreach ($res[0] as $idx=>$value)
00121         $this->$idx=$value;
00122 
00123     }
00124 
00125 }
 All Data Structures Namespaces Files Functions Variables Enumerations