phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r234 - trunk/coprop/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r234 - trunk/coprop/include
Date: Wed, 4 Jan 2012 16:01:28 +0100 (CET)

Author: danydb
Date: 2012-01-04 16:01:28 +0100 (Wed, 04 Jan 2012)
New Revision: 234

Modified:
   trunk/coprop/include/class_copro_key.php
Log:
add function verify

Modified: trunk/coprop/include/class_copro_key.php
===================================================================
--- trunk/coprop/include/class_copro_key.php    2012-01-04 15:01:13 UTC (rev 
233)
+++ trunk/coprop/include/class_copro_key.php    2012-01-04 15:01:28 UTC (rev 
234)
@@ -28,6 +28,20 @@
  */
 class Copro_key
 {
+    function verify ($p_array,$b_dupl=true)
+    {
+        global $cn;
+        extract ($p_array);
+        if (strlen(trim ($cr_name))==0) 
+            throw new Exception("Le nom est vide");
+        if ($b_dupl )
+        {
+            $dupl=$cn->count_sql("select * from copro.clef_repartition where 
cr_name=$1",$cr_name);
+            if ( $dupl >0 )
+                throw new Exception("Une clef avec ce nom existe déja");
+        }
+        
+    }
 
        function insert($p_array)
        {
@@ -35,9 +49,10 @@
                extract($p_array);
                try
                {
+                    $this->verify($p_array);
                        $cn->start();
-                       $this->cr_id = $cn->get_value("insert into 
coprop.clef_repartition(cr_start,cr_end,cr_note,cr_name)
-                               
values(to_date($1,'DD.MM.YYYY'),to_date($2,'DD.MM.YYYY'),$3,$4) returning 
cr_id", array(strip_tags($cr_start), strip_tags($cr_end), strip_tags($cr_note), 
strip_tags($cr_name)));
+                       $this->cr_id = $cn->get_value("insert into 
coprop.clef_repartition(cr_note,cr_name)
+                               values($1,$2) returning cr_id", array( 
strip_tags($cr_note), strip_tags($cr_name)));
                        for ($i = 0; $i < count($f_id); $i++)
                        {
                                if (${"part" . $f_id[$i]} == '')
@@ -59,12 +74,12 @@
                extract($p_array);
                try
                {
+                    $this->verify($p_array,false);
                        $cn->start();
-                       $cn->exec_sql("update coprop.clef_repartition set 
cr_start=to_date($1,'DD.MM.YYYY'),
-                               cr_end=to_date($2,'DD.MM.YYYY'),
+                       $cn->exec_sql("update coprop.clef_repartition set 
                                cr_note=$3,cr_name=$4
                                where cr_id=$5",
-                                       array(strip_tags($cr_start), 
strip_tags($cr_end), strip_tags($cr_note), strip_tags($cr_name),$this->cr_id));
+                                       array( strip_tags($cr_note), 
strip_tags($cr_name),$this->cr_id));
                        $cn->exec_sql("delete from 
coprop.clef_repartition_detail where cr_id=$1",array($this->cr_id));
                        for ($i = 0; $i < count($f_id); $i++)
                        {




reply via email to

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