noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 183/323: Task #0001536: Achat - Vente : n'uti


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 183/323: Task #0001536: Achat - Vente : n'utilisez que les codes TVA disponibles
Date: Wed, 14 Mar 2018 17:38:46 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 90ee4d4f475d1b313808913ebc1a69aa000b106a
Author: Dany De Bontridder <address@hidden>
Date:   Sat Feb 10 14:44:23 2018 +0100

    Task #0001536: Achat - Vente : n'utilisez que les codes TVA disponibles
---
 html/ajax_misc.php                          | 24 +++++++++++++++++++++++-
 html/js/scripts.js                          |  2 ++
 include/class/acc_ledger_purchase.class.php |  1 +
 include/class/acc_ledger_sold.class.php     |  1 +
 include/lib/itva_popup.class.php            | 19 +++++++++++++++++--
 5 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 13e11d4..70f4f93 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -419,7 +419,29 @@ EOF;
                break;
        case 'dsp_tva':
                $cn = Dossier::connect();
-               $Res = $cn->exec_sql("select * from tva_rate order by tva_rate 
desc");
+            // Filter the VAT 
+                $filter=$http->get("filter","string","none");
+                if ( $filter == 'sale')  {
+                    $Res = $cn->exec_sql("select * 
+                        from v_tva_rate 
+                        where 
+                        tva_sale <> '#'
+                            order by tva_rate desc");
+                    
+                } elseif ($filter == "purchase") {
+                    
+                    $Res = $cn->exec_sql("select * 
+                        from 
+                        v_tva_rate 
+                        where 
+                        tva_purchase <> '#'
+                            order by tva_rate desc");
+                }else {
+                    
+                    $Res = $cn->exec_sql("select * from v_tva_rate 
+                        where 
+                            order by tva_rate desc");
+                }
                $Max = Database::num_row($Res);
                $r = "";
                $r.=HtmlInput::title_box(_('Choisissez la 
TVA'),'tva_select',"close","","y");
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 6c8d1d3..46ddea9 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -496,6 +496,8 @@ function popup_select_tva(obj)
             queryString += '&code=' + obj.jcode;
         if (obj.compute)
             queryString += '&compute=' + obj.compute;
+        if (obj.filter)
+            queryString += '&filter=' + obj.filter;
 
         var action = new Ajax.Request(
                 "ajax_misc.php",
diff --git a/include/class/acc_ledger_purchase.class.php 
b/include/class/acc_ledger_purchase.class.php
index c931a09..7dfc938 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -1262,6 +1262,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                 
$Tva->js="onblur=\"format_number(this);onChange=clean_tva($i);compute_ledger($i)\"";
                 $Tva->in_table=true;
                 $Tva->set_attribute('compute',$i);
+                $Tva->set_filter("purchase");
                 $Tva->value=$march_tva_id;
                 $array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
 
diff --git a/include/class/acc_ledger_sold.class.php 
b/include/class/acc_ledger_sold.class.php
index 6dbf6b1..b7e8d53 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -1291,6 +1291,7 @@ EOF;
                 $Tva = new ITva_Popup($this->db);
                 $Tva->in_table = true;
                 $Tva->set_attribute('compute', $i);
+                $Tva->set_filter("sale");
 
                 $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . 
');compute_ledger(' . $i . ')"';
                 $Tva->value = $march_tva_id;
diff --git a/include/lib/itva_popup.class.php b/include/lib/itva_popup.class.php
index f4731a3..948ddda 100644
--- a/include/lib/itva_popup.class.php
+++ b/include/lib/itva_popup.class.php
@@ -54,13 +54,15 @@ class ITva_Popup extends HtmlInput
      * to have its own javascript for the button you can use 
this->but_javascript)
      * by default it is 'popup_select_tva(this)';
      */
+    private $filter; //!< filter the VAT by ledger PURCHASE or SALE or NO 
FILTER, default=NO
     public function __construct($p_name=null,$p_value="",$p_id="")
     {
         $this->name=$p_name;
         $this->button=true;
         $this->in_table=false;
-               $this->value=$p_value;
-               $this->id=$p_id;
+        $this->value=$p_value;
+        $this->id=$p_id;
+        $this->filter='none';
     }
     function with_button($p)
     {
@@ -114,6 +116,18 @@ class ITva_Popup extends HtmlInput
 
     }
     /**
+     * Set a filter to limit the choice of VAT ; 
+     * possible values are : 
+     *         - sale  if there is an accounting for sale
+     *         - purchase  if there is an accounting for purchase
+     *         - none  : show VAT 
+     * 
+     */
+    function set_filter($p_filter)
+    {
+        $this->filter=$p_filter;
+    }
+    /**
      address@hidden show a button, if it is pushed show a popup to select the 
need vat
      address@hidden
      * - a ipopup must be created before with the name popup_tva
@@ -136,6 +150,7 @@ class ITva_Popup extends HtmlInput
             $bt->set_attribute('jcode',$this->code->name);
         if ( isset($this->compute))
             $bt->set_attribute('compute',$this->compute);
+        $bt->set_attribute("filter", $this->filter);
         
$bt->javascript=(isset($this->but_javascript))?$this->but_javascript:'popup_select_tva(this)';
         $r=$bt->input();
         return $r;



reply via email to

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