noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 20/26: Code cleaning : remove useless class g


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 20/26: Code cleaning : remove useless class gestion_sold gestion_purchase and gestion_table
Date: Wed, 11 Aug 2021 11:08:16 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit ac31207ad9a70802abf6adb6a373b2ce333e3a31
Author: Dany wm De Bontridder <danydb@noalyss.eu>
AuthorDate: Tue Aug 3 17:28:47 2021 +0200

    Code cleaning : remove useless class gestion_sold gestion_purchase and 
gestion_table
---
 include/class/acc_ledger_history_generic.class.php |  13 +--
 include/class/gestion_purchase.class.php           | 127 ---------------------
 include/class/gestion_sold.class.php               | 114 ------------------
 include/class/gestion_table.class.php              |  37 ------
 include/constant.php                               |   7 +-
 include/database/quant_fin_sql.class.php           |  78 +++++++++++++
 include/database/quant_purchase_sql.class.php      |  97 ++++++++++++++++
 include/database/quant_sold.class.php              |  88 ++++++++++++++
 8 files changed, 271 insertions(+), 290 deletions(-)

diff --git a/include/class/acc_ledger_history_generic.class.php 
b/include/class/acc_ledger_history_generic.class.php
index 3b7a90c..284cbb5 100644
--- a/include/class/acc_ledger_history_generic.class.php
+++ b/include/class/acc_ledger_history_generic.class.php
@@ -325,10 +325,10 @@ class Acc_Ledger_History_Generic extends 
Acc_Ledger_History
             /* if ND */
             if ($p_array['jrn_def_type']=='ACH')
             {
-                $purchase=new Gestion_Purchase($this->db);
-                $purchase->search_by_jid($code['j_id']);
-                $purchase->load();
-                $dep_priv+=$purchase->qp_dep_priv;
+                $qp_id=$this->get_value("select qp_id from quant_purchase 
where j_id=$1",[$code['j_id']]);
+                $purchase=new Quant_Purchase_SQL($this->db,$qp_id);
+
+                $dep_priv=bcadd ($dep_priv,$purchase->qp_dep_priv);
                 $p_array['dep_priv']=$dep_priv;
                 $p_array['dna']=bcadd($p_array['dna'], 
$purchase->qp_nd_amount);
                 $p_array['tva_dna']=bcadd($p_array['tva_dna'],
@@ -338,9 +338,8 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
             }
             if ($p_array['jrn_def_type']=='VEN')
             {
-                $sold=new gestion_sold($this->db);
-                $sold->search_by_jid($code['j_id']);
-                $sold->load();
+                $qs_id=$this->db->get_value("select qs_id from quant_sold 
where j_id=$1",array($code['j_id']));
+                $sold=new Quant_Sold_SQL($this->db,$qs_id);
                 $p_array['tva_np']=bcadd($sold->qs_vat_sided, 
$p_array['tva_np']);
             }
         }
diff --git a/include/class/gestion_purchase.class.php 
b/include/class/gestion_purchase.class.php
deleted file mode 100644
index 152e651..0000000
--- a/include/class/gestion_purchase.class.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/*
- *   This file is part of NOALYSS.
- *
- *   NOALYSS is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   NOALYSS is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with NOALYSS; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-// Copyright Author Dany De Bontridder danydb@aevalys.eu
-
-/*!\file
-* \brief Definition of the class gestion_purchase
- */
-
-/*! \brief this object handles the table quant_purchase
- *
- */
-
-
-class gestion_purchase extends gestion_table
-{
-    var $qp_id;                                        /*!< id */
-    var $qp_internal;                          /*!< internal code */
-    var $qp_fiche;                                     /*!< card id 
(fiche.f_id) */
-    var $qp_quantite;                          /*!< quantity */
-    var $qp_price;                                     /*!< quantity */
-    var $qp_vat;                                       /*!< vat amount */
-    var $qp_vat_code;                          /*!< vat_code */
-    var $qp_nd_amount;                         /*!< no deductible */
-    var $qp_nd_tva;                            /*!< tva not deductible */
-    var $qp_nd_tva_recup;                      /*!< tva ded via taxe */
-    var $qp_supplier;                          /*!< supplier code (f_id) */
-    var $qp_valid;
-    var $j_id;                                         /*!< jrnx.j_id
-                                                                 */
-    var $qp_dep_priv;          /*!< private purchase */
-    var $qp_vat_sided;      /* autoliquidation */
-    /*!\brief return an array of gestion_table, the object are
-     * retrieved thanks the qs_internal
-     */
-    function get_list()
-    {
-        if ($this->qp_internal=="")
-            throw  new Exception(__FILE__.__LINE__." qs_internal est vide");
-        $sql="select  qp_id,
-             qp_internal,
-             qp_fiche,
-             qp_quantite,
-             qp_price,
-             qp_vat,
-             qp_vat_code,
-             tva_rate,
-             tva_label,
-             qp_nd_amount,
-             qp_nd_tva,
-             qp_nd_tva_recup,
-             qp_supplier,
-             j_id,
-             qp_dep_priv,
-             qp_vat_sided
-             from quant_purchase left join tva_rate on (qp_vat_code=tva_id)
-             where qp_internal='".$this->qp_internal."'";
-        $ret=$this->db->exec_sql($sql);
-        // $res contains all the line
-        $res=Database::fetch_all($ret);
-
-        if ( sizeof($res)==0) return null;
-        $count=0;
-        foreach ($res as $row)
-        {
-            $t_gestion_purchase=new gestion_purchase($this->db);
-            foreach ($row as $idx=>$value)
-            $t_gestion_purchase->$idx=$value;
-            $array[$count]=clone $t_gestion_purchase;
-            $count++;
-        }
-        return $array;
-    }
-    function search_by_jid($p_jid)
-    {
-        $res=$this->db->exec_sql("select qp_id from quant_purchase where 
j_id=".$p_jid);
-
-        if ( Database::num_row($res) == 1)
-            $this->qp_id=Database::fetch_result($res,0,0);
-        else
-            $this->qp_id=0;
-    }
-    function load()
-    {
-        $sql="select  qp_id,
-             qp_internal,
-             qp_fiche,
-             qp_quantite,
-             qp_price,
-             qp_vat,
-             qp_vat_code,
-             qp_nd_amount,
-             qp_nd_tva,
-             qp_nd_tva_recup,
-             qp_supplier,
-             j_id,
-             qp_dep_priv,
-             qp_vat_sided
-             from quant_purchase
-             where qp_id=".$this->qp_id;
-        $ret=$this->db->exec_sql($sql);
-        // $res contains all the line
-        $res=Database::fetch_all($ret);
-
-        if ( empty($res) ) return null;
-        foreach ($res[0] as $idx=>$value)
-        $this->$idx=$value;
-
-    }
-
-}
diff --git a/include/class/gestion_sold.class.php 
b/include/class/gestion_sold.class.php
deleted file mode 100644
index 5127ffd..0000000
--- a/include/class/gestion_sold.class.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/*
- *   This file is part of NOALYSS.
- *
- *   NOALYSS is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   NOALYSS is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with NOALYSS; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-// Copyright Author Dany De Bontridder danydb@aevalys.eu
-
-/*!\file
- * \brief definition of the class gestion_sold
- */
-
-/*! \brief this object handles the table quant_sold
- *
- */
-
-
-
-class gestion_sold extends gestion_table
-{
-    var $qs_id;                                        /*!< $qs_id primary key 
*/
-    var $qs_internal;                          /*!< qs_internal */
-    var $qs_fiche;                             /*!< f_id code  */
-    var $qs_quantite;                          /*!< quantity of the card */
-    var $qs_price;                             /*!< price */
-    var $qs_vat;                                       /*!< vat_amount */
-    var $qs_vat_code;                          /*!< vat_code */
-    var $qs_client;                            /*!< f_id of the customer */
-    var $qs_valid;                             /*!< will not be used */
-    var $j_id;                                 /*!< jrnx.j_id */
-    var $qs_vat_sided;
-    /*!\brief return an array of gestion_table, the object are
-     * retrieved thanks the qs_internal
-     */
-    function get_list()
-    {
-        if ($this->qs_internal=="")
-            throw  new Exception(__FILE__.__LINE__." qs_internal est vide");
-        $sql="select  qs_id,
-             qs_internal,
-             qs_fiche,
-             qs_quantite,
-             qs_price,
-             qs_vat,
-             tva_label,
-             tva_rate,
-             qs_vat_code,
-             qs_client,
-             j_id,
-             qs_vat_sided
-             from quant_sold left join tva_rate on (qs_vat_code=tva_id)
-             where qs_internal='".$this->qs_internal."'";
-        $ret=$this->db->exec_sql($sql);
-        // $res contains all the line
-        $res=Database::fetch_all($ret);
-
-        if ( $res == FALSE || sizeof($res)==0) return null;
-        $count=0;
-
-        foreach ($res as $row)
-        {
-            $t_gestion_sold=new gestion_sold($this->db);
-            foreach ($row as $idx=>$value)
-            $t_gestion_sold->$idx=$value;
-            $array[$count]=clone $t_gestion_sold;
-            $count++;
-        }
-        return $array;
-    }
-     function search_by_jid($p_jid)
-    {
-        $res=$this->db->exec_sql("select qs_id from quant_sold where 
j_id=".$p_jid);
-
-        if ( Database::num_row($res) == 1)
-            $this->qs_id=Database::fetch_result($res,0,0);
-        else
-            $this->qs_id=0;
-    }
-    function load()
-    {
-       $sql=" select  qs_id,
-             qs_internal,
-             qs_fiche,
-             qs_quantite,
-             qs_price,
-             qs_vat,
-             qs_vat_code,
-             qs_client,
-             j_id,
-             qs_vat_sided
-             from quant_sold 
-             where qs_id=$1";
-       $ret=$this->db->exec_sql($sql,array($this->qs_id));
-        // $res contains all the line
-        $res=Database::fetch_all($ret);
-
-        if ( $res==FALSE || empty($res) ) return null;
-        foreach ($res[0] as $idx=>$value)
-        $this->$idx=$value;
-    }
-}
diff --git a/include/class/gestion_table.class.php 
b/include/class/gestion_table.class.php
deleted file mode 100644
index d5e0a81..0000000
--- a/include/class/gestion_table.class.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/*
- *   This file is part of NOALYSS.
- *
- *   NOALYSS is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   NOALYSS is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with NOALYSS; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-// Copyright Author Dany De Bontridder danydb@aevalys.eu
-
-/*!\file
- * \brief definition of gestion_table
- */
-
-/*! \brief mother class for gestion
- *
- */
-class gestion_table
-{
-    var $db;                                           /*!< $db database 
connection */
-    /*!\brief contains only the dabase connx */
-    function __construct($p_cn)
-    {
-        $this->db=$p_cn;
-    }
-}
diff --git a/include/constant.php b/include/constant.php
index bda9ea5..884f5f7 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -450,10 +450,6 @@ function noalyss_class_autoloader($class) {
         "forecast_category_mtable" => 
"class/forecast_category_mtable.class.php",
         "forecast" => "class/forecast.class.php",
         "forecast_item_mtable" => "class/forecast_item_mtable.class.php",
-        "gestion_purchase" => "class/gestion_purchase.class.php",
-        "gestion_sold" => "class/gestion_sold.class.php",
-        "gestion_table" => "class/gestion_table.class.php",
-        "html_input_noalyss" => "class/html_input_noalyss.class.php",
         "lettering" => "class/lettering.class.php",
         "lettering_card" => "class/lettering.class.php",
         "lettering_account" => "class/lettering.class.php",
@@ -599,7 +595,8 @@ function noalyss_class_autoloader($class) {
         "document_state_mtable"=>"class/document_state_mtable.class.php",
         "noalyss\mobile"=>"class/mobile.class.php",
         "profile_mobile_sql"=>"database/profile_mobile_sql.class.php",
-        "mobile_device_mtable"=>"class/mobile_device_mtable.class.php"
+        "mobile_device_mtable"=>"class/mobile_device_mtable.class.php",
+        "html_input_noalyss"=>"class/html_input_noalyss.class.php"
     );
     if ( isset ($aClass[$class]) ) {
         require_once NOALYSS_INCLUDE."/".$aClass[$class];
diff --git a/include/database/quant_fin_sql.class.php 
b/include/database/quant_fin_sql.class.php
new file mode 100644
index 0000000..34f88ac
--- /dev/null
+++ b/include/database/quant_fin_sql.class.php
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * Autogenerated file
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+require_once NOALYSS_INCLUDE . '/lib/data_sql.class.php';
+require_once NOALYSS_INCLUDE . '/class/database.class.php';
+
+
+/**
+ * class_quant_fin_sql.php
+ *
+ * @file
+ * @brief ORM of the table public.quant_fin
+ */
+
+/**
+ * class_quant_fin_sql.php
+ *
+ * @class Quant_Fin_SQL
+ * @brief ORM of the table public.quant_fin
+ */
+class Quant_Fin_SQL extends \Table_Data_SQL
+{
+
+    function __construct(DatabaseCore $p_cn, $p_id = -1)
+    {
+        $this->table = "public.quant_fin";
+        $this->primary_key = "qf_id";
+        /*
+         * List of columns
+         */
+        $this->name = array(
+            "qf_id" => "qf_id"
+        , "qf_bank" => "qf_bank"
+        , "jr_id" => "jr_id"
+        , "qf_other" => "qf_other"
+        , "qf_amount" => "qf_amount"
+        , "j_id" => "j_id"
+        );
+        /*
+         * Type of columns
+         */
+        $this->type = array(
+            "qf_id" => "numeric"
+        , "qf_bank" => "numeric"
+        , "jr_id" => "numeric"
+        , "qf_other" => "numeric"
+        , "qf_amount" => "numeric"
+        , "j_id" => "numeric"
+        );
+
+
+        $this->default = array(
+            "qf_id" => "auto"
+        );
+
+        $this->date_format = "DD.MM.YYYY";
+        parent::__construct($p_cn, $p_id);
+    }
+
+
+}
\ No newline at end of file
diff --git a/include/database/quant_purchase_sql.class.php 
b/include/database/quant_purchase_sql.class.php
new file mode 100644
index 0000000..27325f6
--- /dev/null
+++ b/include/database/quant_purchase_sql.class.php
@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * Autogenerated file
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+require_once NOALYSS_INCLUDE . '/lib/data_sql.class.php';
+require_once NOALYSS_INCLUDE . '/class/database.class.php';
+
+
+/**
+ * class_quant_purchase_sql.php
+ *
+ * @file
+ * @brief ORM of the table public.quant_purchase
+ *
+ */
+
+/**
+ * @class Quant_Purchase_SQL
+ * @brief ORM of the table public.quant_purchase
+ */
+class Quant_Purchase_SQL extends \Table_Data_SQL
+{
+
+    function __construct(DatabaseCore $p_cn, $p_id = -1)
+    {
+        $this->table = "public.quant_purchase";
+        $this->primary_key = "qp_id";
+        /*
+         * List of columns
+         */
+        $this->name = array(
+            "qp_id" => "qp_id"
+        , "qp_internal" => "qp_internal"
+        , "j_id" => "j_id"
+        , "qp_fiche" => "qp_fiche"
+        , "qp_quantite" => "qp_quantite"
+        , "qp_price" => "qp_price"
+        , "qp_vat" => "qp_vat"
+        , "qp_vat_code" => "qp_vat_code"
+        , "qp_nd_amount" => "qp_nd_amount"
+        , "qp_nd_tva" => "qp_nd_tva"
+        , "qp_nd_tva_recup" => "qp_nd_tva_recup"
+        , "qp_supplier" => "qp_supplier"
+        , "qp_valid" => "qp_valid"
+        , "qp_dep_priv" => "qp_dep_priv"
+        , "qp_vat_sided" => "qp_vat_sided"
+        , "qp_unit" => "qp_unit"
+        );
+        /*
+         * Type of columns
+         */
+        $this->type = array(
+            "qp_id" => "numeric"
+        , "qp_internal" => "text"
+        , "j_id" => "numeric"
+        , "qp_fiche" => "numeric"
+        , "qp_quantite" => "numeric"
+        , "qp_price" => "numeric"
+        , "qp_vat" => "numeric"
+        , "qp_vat_code" => "numeric"
+        , "qp_nd_amount" => "numeric"
+        , "qp_nd_tva" => "numeric"
+        , "qp_nd_tva_recup" => "numeric"
+        , "qp_supplier" => "numeric"
+        , "qp_valid" => "text"
+        , "qp_dep_priv" => "numeric"
+        , "qp_vat_sided" => "numeric"
+        , "qp_unit" => "numeric"
+        );
+
+
+        $this->default = array(
+            "qp_id" => "auto"
+        );
+
+        $this->date_format = "DD.MM.YYYY";
+        parent::__construct($p_cn, $p_id);
+    }
+
+
+}
\ No newline at end of file
diff --git a/include/database/quant_sold.class.php 
b/include/database/quant_sold.class.php
new file mode 100644
index 0000000..5eb1b78
--- /dev/null
+++ b/include/database/quant_sold.class.php
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Autogenerated file
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+require_once NOALYSS_INCLUDE . '/lib/data_sql.class.php';
+require_once NOALYSS_INCLUDE . '/class/database.class.php';
+
+
+/**
+ * class_quant_sold_sql.php
+ *
+ * @file
+ * @brief ORM of the table public.quant_sold
+ */
+
+/**
+ * @class Quant_Sold_SQL
+ * @brief ORM of the table public.quant_sold
+ */
+class Quant_Sold_SQL extends \Table_Data_SQL
+{
+
+    function __construct(DatabaseCore $p_cn, $p_id = -1)
+    {
+        $this->table = "public.quant_sold";
+        $this->primary_key = "qs_id";
+        /*
+         * List of columns
+         */
+        $this->name = array(
+            "qs_id" => "qs_id"
+        , "qs_internal" => "qs_internal"
+        , "qs_fiche" => "qs_fiche"
+        , "qs_quantite" => "qs_quantite"
+        , "qs_price" => "qs_price"
+        , "qs_vat" => "qs_vat"
+        , "qs_vat_code" => "qs_vat_code"
+        , "qs_client" => "qs_client"
+        , "qs_valid" => "qs_valid"
+        , "j_id" => "j_id"
+        , "qs_vat_sided" => "qs_vat_sided"
+        , "qs_unit" => "qs_unit"
+        );
+        /*
+         * Type of columns
+         */
+        $this->type = array(
+            "qs_id" => "numeric"
+        , "qs_internal" => "text"
+        , "qs_fiche" => "numeric"
+        , "qs_quantite" => "numeric"
+        , "qs_price" => "numeric"
+        , "qs_vat" => "numeric"
+        , "qs_vat_code" => "numeric"
+        , "qs_client" => "numeric"
+        , "qs_valid" => "text"
+        , "j_id" => "numeric"
+        , "qs_vat_sided" => "numeric"
+        , "qs_unit" => "numeric"
+        );
+
+
+        $this->default = array(
+            "qs_id" => "auto"
+        );
+
+        $this->date_format = "DD.MM.YYYY";
+        parent::__construct($p_cn, $p_id);
+    }
+
+
+}
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]