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     var $qp_vat_sided;      /* autoliquidation */
00050     /*!\brief return an array of gestion_table, the object are
00051      * retrieved thanks the qs_internal
00052      */
00053     function get_list()
00054     {
00055         if ($this->qp_internal=="")
00056             throw  new Exception(__FILE__.__LINE__." qs_internal est vide");
00057         $sql="select  qp_id,
00058              qp_internal,
00059              qp_fiche,
00060              qp_quantite,
00061              qp_price,
00062              qp_vat,
00063              qp_vat_code,
00064              tva_rate,
00065              tva_label,
00066              qp_nd_amount,
00067              qp_nd_tva,
00068              qp_nd_tva_recup,
00069              qp_supplier,
00070              j_id,
00071              qp_dep_priv,
00072              qp_vat_sided
00073              from quant_purchase left join tva_rate on (qp_vat_code=tva_id)
00074              where qp_internal='".$this->qp_internal."'";
00075         $ret=$this->db->exec_sql($sql);
00076         // $res contains all the line
00077         $res=Database::fetch_all($ret);
00078 
00079         if ( sizeof($res)==0) return null;
00080         $count=0;
00081         foreach ($res as $row)
00082         {
00083             $t_gestion_purchase=new gestion_purchase($this->db);
00084             foreach ($row as $idx=>$value)
00085             $t_gestion_purchase->$idx=$value;
00086             $array[$count]=clone $t_gestion_purchase;
00087             $count++;
00088         }
00089         return $array;
00090     }
00091     function search_by_jid($p_jid)
00092     {
00093         $res=$this->db->exec_sql("select qp_id from quant_purchase where j_id=".$p_jid);
00094 
00095         if ( Database::num_row($res) == 1)
00096             $this->qp_id=Database::fetch_result($res,0,0);
00097         else
00098             $this->qp_id=0;
00099     }
00100     function load()
00101     {
00102         $sql="select  qp_id,
00103              qp_internal,
00104              qp_fiche,
00105              qp_quantite,
00106              qp_price,
00107              qp_vat,
00108              qp_vat_code,
00109              qp_nd_amount,
00110              qp_nd_tva,
00111              qp_nd_tva_recup,
00112              qp_supplier,
00113              j_id,
00114              qp_dep_priv,
00115              qp_vat_sided
00116              from quant_purchase
00117              where qp_id=".$this->qp_id;
00118         $ret=$this->db->exec_sql($sql);
00119         // $res contains all the line
00120         $res=Database::fetch_all($ret);
00121 
00122         if ( empty($res) ) return null;
00123         foreach ($res[0] as $idx=>$value)
00124         $this->$idx=$value;
00125 
00126     }
00127 
00128 }
 All Data Structures Namespaces Files Functions Variables Enumerations