noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 06/07: New : 0002190: Journaux : option pour


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 06/07: New : 0002190: Journaux : option pour supprimer la quantité
Date: Sat, 3 Sep 2022 17:16:04 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 192060909dd8c53918ae0d316ab59f4ad0a4a194
Author: Dany De Bontridder <dany@alchimerys.be>
AuthorDate: Sat Sep 3 22:32:08 2022 +0200

    New : 0002190: Journaux : option pour supprimer la quantité
---
 html/ajax_misc.php                               |   6 ++--
 html/js/acc_ledger.js                            |  40 +++++++++++++++++++++++
 include/ajax/ajax_update_visibility_quantity.php |  35 ++++++++++++++++++++
 include/class/acc_ledger_purchase.class.php      |   5 ++-
 include/class/acc_ledger_sale.class.php          |   9 +++--
 include/sql/patch/upgrade176.sql                 |  14 ++++++++
 include/template/form_ledger_detail.php          |   7 ++--
 unit-test/dossier25.sql.gz                       | Bin 392940 -> 393069 bytes
 unit-test/include/class/acc_ledgerTest.php       |   2 +-
 9 files changed, 110 insertions(+), 8 deletions(-)

diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 1f891235d..e54dfef3c 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -313,7 +313,9 @@ $path = array(
     // Mobile device menu from mobile_device_mtable
     "mobile_device_menu"=>"ajax_mobile_device_menu",
     // other_tax
-    "other_tax"=>"ajax_other_tax"
+    "other_tax"=>"ajax_other_tax",
+    //visibility quantity
+    "update_visibility_quantity"=>"ajax_update_visibility_quantity"
 ) ;
 
 if (array_key_exists($op, $path)) {
@@ -639,7 +641,7 @@ EOF;
             {
                 echo '<div>';
                 echo '<h1 >'.$ajrn[0]['jrn_def_name'].'</h1>';
-                if ( trim($ajrn[0]['jrn_def_description']) != "") {
+                if ( noalyss_trim($ajrn[0]['jrn_def_description']) != "") {
                     echo '<p style="border:1px 
solid;margin-top:0px;padding:1rem">'.$ajrn[0]['jrn_def_description'].'</p>';
                 }
                 echo '</div>';
diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index 0ebebe666..2e70ac942 100644
--- a/html/js/acc_ledger.js
+++ b/html/js/acc_ledger.js
@@ -141,6 +141,7 @@ function error_get_predef(request, json)
     alert_box(content[49]);
 
 }
+
 /**
  *  update the list of available predefined operation when we change the 
ledger.
  */
@@ -265,6 +266,45 @@ function update_row(ctl)
         alert_box(e.message);
     }
 }
+
+/**
+ * @brief hide or show the column quantity
+ */
+function update_visibility_quantity()
+{
+    var jrn = g("p_jrn").value;
+    var dossier = g("gDossier").value;
+    var querystring = 'gDossier=' + dossier + '&l=' + jrn + 
"&op=update_visibility_quantity";
+    var action = new Ajax.Request(
+        "ajax_misc.php",
+        {
+            method: 'get',
+            parameters: querystring,
+            onSuccess: function (req) {
+                try {
+                    // retrieve quantity
+                    var 
quantity_col=document.getElementsByClassName("col_quant");
+                    for (var i=0;i < quantity_col.length;i++){
+                        if (req.responseText=="0") {
+                            // hide the columns quantity and return
+                            quantity_col[i].hide();
+                            quantity_col[i].addClassName('d-none');
+                        }
+                        if (req.responseText=="1") {
+                            // show the columns quantity and return
+                            quantity_col[i].show();
+                            quantity_col[i].removeClassName('d-none');
+                        }
+                    }
+                } catch (e) {
+                    console.error("update_visibility_quantity"+e.message);
+                }
+
+
+            }
+        }
+    );
+}
 /**
  *  Put into the span, the name of the bank, the bank account
  * and the quick_code
diff --git a/include/ajax/ajax_update_visibility_quantity.php 
b/include/ajax/ajax_update_visibility_quantity.php
new file mode 100644
index 000000000..6bbffdca9
--- /dev/null
+++ b/include/ajax/ajax_update_visibility_quantity.php
@@ -0,0 +1,35 @@
+<?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 respond ajax request, the get contains
+ *  the value :
+ * - l for ledger
+ * - gDossier
+ * Must return 1 if quantity is visible or 0 if not
+ */
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+global $http;
+$cn=Dossier::connect();
+$ledger=new Acc_Ledger($cn,$http->get("l","number",0));
+$ledger->load();
+if ($ledger->id==0) throw new Exception("UPDVIS34.Invalide ledger");
+echo $ledger->has_quantity();
\ No newline at end of file
diff --git a/include/class/acc_ledger_purchase.class.php 
b/include/class/acc_ledger_purchase.class.php
index 20ff4c7fd..926b3930b 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -1131,6 +1131,8 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
     public function input($p_array=null,$p_readonly=0)
     {
         global $g_parameter,$g_user;
+        // load ledger definition
+        $this->load();
         $http=new HttpInput();
         if ( $p_array != null ) extract($p_array, EXTR_SKIP);
 
@@ -1217,7 +1219,8 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
         $add_js.='update_name();';
         $add_js.='update_pay_method();';
         $add_js.='update_row("sold_item");';
-        $add_js.='update_other_tax()';
+        $add_js.='update_other_tax();';
+        $add_js.='update_visibility_quantity();';
 
         $wLedger=$this->select_ledger('ACH',2,FALSE);
         
diff --git a/include/class/acc_ledger_sale.class.php 
b/include/class/acc_ledger_sale.class.php
index 608be7a10..9213986f8 100644
--- a/include/class/acc_ledger_sale.class.php
+++ b/include/class/acc_ledger_sale.class.php
@@ -253,6 +253,8 @@ class Acc_Ledger_Sale extends Acc_Ledger {
 
     public function insert($p_array = null) {
         global $g_parameter;
+        // load ledger definition
+        $this->load();
         extract($p_array, EXTR_SKIP);
         $this->verify($p_array);
 
@@ -873,7 +875,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
         $r.='</tr>';
         $r.='</table>';
         $r.='</div>';
-        $r.='<div style="position:float;clear:both">';
+        $r.='<div style="float:none;clear:both">';
         $r.='</div>';
         
         $r.='<h2>' . _('Détail articles vendus') . '</h2>';
@@ -1254,6 +1256,8 @@ EOF;
 
     function input($p_array = null, $p_readonly = 0) {
         global $g_parameter, $g_user;
+        // load ledger definition
+        $this->load();
         $http=new HttpInput();
         if ($p_array != null) {
             extract($p_array, EXTR_SKIP);
@@ -1329,7 +1333,8 @@ EOF;
         $add_js.='update_name();';
         $add_js.='update_pay_method();';
         $add_js.='update_row("sold_item");';
-        $add_js.='update_other_tax()';
+        $add_js.='update_other_tax();';
+        $add_js.='update_visibility_quantity();';
 
         $wLedger = $this->select_ledger('VEN', 2,FALSE);
         if ($wLedger == null)
diff --git a/include/sql/patch/upgrade176.sql b/include/sql/patch/upgrade176.sql
new file mode 100644
index 000000000..9defb8a02
--- /dev/null
+++ b/include/sql/patch/upgrade176.sql
@@ -0,0 +1,14 @@
+begin;
+
+ALTER TABLE public.jrn_def ADD jrn_def_quantity int2 NULL DEFAULT 1;
+COMMENT ON COLUMN public.jrn_def.jrn_def_quantity IS 'Use the quantity column, 
0->disable,1->enable,used only with Sale and Purchase otherwise ignored';
+update public.jrn_def set jrn_def_quantity=1;
+ALTER TABLE public.jrn_def ALTER COLUMN jrn_def_quantity SET NOT NULL;
+-- change PARAM by CFG
+
+update menu_ref set me_code='CFG' , me_menu='Configuration' ,me_description 
='Configuration de votre dossier' where me_code='PARAM';
+
+update profile_menu set me_code ='CFG' where me_code='PARAM';
+update profile_menu set me_code_dep  ='CFG' where me_code_dep ='PARAM';
+insert into version (val,v_description) values (177,'Use of quantity column 
optional and rename PARAM');
+commit;
\ No newline at end of file
diff --git a/include/template/form_ledger_detail.php 
b/include/template/form_ledger_detail.php
index d3b536b56..493a8e320 100644
--- a/include/template/form_ledger_detail.php
+++ b/include/template/form_ledger_detail.php
@@ -81,6 +81,9 @@
      
       
 <br>
+<?php
+$hidden=($this->has_quantity()==0)?'d-none':'';
+?>
 <h2><?php echo $f_legend_detail?></h2>
 <table id="sold_item" >
 <tr>
@@ -88,7 +91,7 @@
       <th class="visible_gt800 visible_gt1155"><?php echo 
_('Dénomination')?></th>
 <?php if ($flag_tva =='Y') : ?>
       <th><?php echo _('prix/unité htva')?><?php echo 
Icon_Action::infobulle(6)?></th>
-      <th><?php echo _('quantité')?></th>
+      <th class="col_quant <?=$hidden?>"><?php echo _('quantité')?></th>
       <th class="visible_gt800" ><?php echo _('Total HTVA')?></th>
          <th><?php echo _('tva')?></th>
       <th class="visible_gt800"><?php echo _('tot.tva')?></th>
@@ -112,7 +115,7 @@ echo '<td>'.$item['bt'].$item['card_add'].'</td>';
 <td class="visible_gt800 visible_gt1155"><?php echo $item['denom'] ?></td>
 <?php 
 echo td($item['pu']);
-echo td($item['quantity' ]);
+echo td($item['quantity' ],'class="col_quant '. $hidden.'"');
 echo td($item['htva'],' class="visible_gt800" ');
 if ($flag_tva=='Y')  {
        echo td($item['tva']);
diff --git a/unit-test/dossier25.sql.gz b/unit-test/dossier25.sql.gz
index 57a842401..cde5fcc91 100644
Binary files a/unit-test/dossier25.sql.gz and b/unit-test/dossier25.sql.gz 
differ
diff --git a/unit-test/include/class/acc_ledgerTest.php 
b/unit-test/include/class/acc_ledgerTest.php
index 1fae92b93..3d37fe5f1 100644
--- a/unit-test/include/class/acc_ledgerTest.php
+++ b/unit-test/include/class/acc_ledgerTest.php
@@ -850,7 +850,7 @@ class Acc_LedgerTest extends TestCase
         \Noalyss\Facility::save_file(__DIR__."/file", 
"acc_ledger-input_new.html", $result);
         $size=filesize(__DIR__."/file/acc_ledger-input_new.html");
                 
-        $this->assertEquals(16514,$size," output input_new is not what it is 
expected");
+        $this->assertEquals(16325,$size," output input_new is not what it is 
expected");
     }
 
     /**



reply via email to

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