noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 14/30: Bug Fiche_Def->insertAttribut when nee


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 14/30: Bug Fiche_Def->insertAttribut when needed to compute an attribute order
Date: Sat, 3 Dec 2022 08:35:08 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit eba1a727d00c9b5608527fd3b5507b5b8c943d9e
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Nov 23 18:33:21 2022 +0100

    Bug Fiche_Def->insertAttribut when needed to compute an attribute order
---
 include/class/fiche_def.class.php         | 2 +-
 unit-test/include/class/Fiche_DefTest.php | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/class/fiche_def.class.php 
b/include/class/fiche_def.class.php
index 3d169078f..261ff94ce 100644
--- a/include/class/fiche_def.class.php
+++ b/include/class/fiche_def.class.php
@@ -639,7 +639,7 @@ $order
         if ( $p_order == -1 ) {
             $order = $this->cn->get_value("select ad_default_order from 
attr_def where ad_id=$1",[$p_ad_id]);
             if ( $order == 0 || empty($order)) {
-                $max=$this->get_value("select count(*) from jnt_fic_attr where 
fd_id=$1",[$this->id]);
+                $max=$this->cn->get_value("select count(*) from jnt_fic_attr 
where fd_id=$1",[$this->id]);
                 $order=$max*15;
             }
         }
diff --git a/unit-test/include/class/Fiche_DefTest.php 
b/unit-test/include/class/Fiche_DefTest.php
index 03d0a2908..9dbaefcb5 100644
--- a/unit-test/include/class/Fiche_DefTest.php
+++ b/unit-test/include/class/Fiche_DefTest.php
@@ -158,6 +158,7 @@ class Fiche_DefTest extends Testcase
        }
        
     }
+
     /**
      * @testdox getAttribut
      */
@@ -183,7 +184,13 @@ class Fiche_DefTest extends Testcase
         // percent deductible
         $fiche_def->InsertAttribut(20);
         $fiche_def->InsertAttribut(21,120);
-        $fiche_def->InsertAttribut(22);
+
+        // check if the automatic order works
+        $defaultOrder=$g_connection->get_value("select ad_default_order from 
attr_def where ad_id=22");
+        $g_connection->exec_sql("update attr_def set ad_default_order=null 
where ad_id=22");
+        $fiche_def->InsertAttribut(22,-1);
+        $g_connection->exec_sql("update attr_def set ad_default_order=$1 where 
ad_id=22",[$defaultOrder]);
+
 
         // accouting for not deductible
         $fiche_def->InsertAttribut(51);



reply via email to

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