noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 12/12: Bug : follow-up , add a new security a


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 12/12: Bug : follow-up , add a new security against the duplicate for Follo_Up reference (ag_ref)
Date: Sun, 8 Nov 2020 15:52:16 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 9d5d626ad80fd656f11914a95661d5b3d85ad4f0
Author: Dany wm De Bontridder <danydb@noalyss.eu>
AuthorDate: Sun Nov 8 21:47:03 2020 +0100

    Bug : follow-up , add a new security against the duplicate for Follo_Up 
reference (ag_ref)
---
 include/class/follow_up.class.php | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/class/follow_up.class.php 
b/include/class/follow_up.class.php
index 010958b..37191c6 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -539,13 +539,17 @@ class Follow_Up
             $this->ag_title=$doc_mod->dt_value;
         }
         $this->ag_id=$this->db->get_next_seq('action_gestion_ag_id_seq');
-         // Get The sequence id,
         $seq_name="seq_doc_type_".$this->dt_id;
-
-        // Create the reference
-        $ag_ref=$this->db->get_value('select dt_prefix from document_type 
where dt_id=$1', array($this->dt_id)).'-'.$this->db->get_next_seq($seq_name);
+        // to avoid duplicate
+        do {
+            // Create the reference
+            $ag_ref=$this->db->get_value('select dt_prefix from document_type 
where dt_id=$1', array($this->dt_id)).'-'.$this->db->get_next_seq($seq_name);
+            // if reference does not exist , finish the loop
+            if ( $this->db->get_value("select count(*) from action_gestion 
where ag_ref = $1",array($ag_ref)) == 0)
+            break;
+        } while (1);
+        // check if the reference already exist and try to compute new one
         $this->ag_ref=$ag_ref;
-
         // save into the database
         if ($this->ag_remind_date!=null||$this->ag_remind_date!='')
         {



reply via email to

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