phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r315 - trunk/import_card/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r315 - trunk/import_card/include
Date: Sun, 25 Mar 2012 16:38:53 +0200 (CEST)

Author: danydb
Date: 2012-03-25 16:38:53 +0200 (Sun, 25 Mar 2012)
New Revision: 315

Modified:
   trunk/import_card/include/class_import_card.php
Log:
Update existing card

Modified: trunk/import_card/include/class_import_card.php
===================================================================
--- trunk/import_card/include/class_import_card.php     2012-03-25 14:05:21 UTC 
(rev 314)
+++ trunk/import_card/include/class_import_card.php     2012-03-25 14:38:53 UTC 
(rev 315)
@@ -90,10 +90,6 @@
 
        /**
         * @brief record all rows
-        * @param
-        * @return
-        * @note
-        * @see
          @code
          array
          'plugin_code' => string 'IMPCARD' (length=7)
@@ -159,8 +155,11 @@
                        alert('Vous avez défini plusieurs fois la même 
colonne');
                        return -1;
                }
-
-
+               if ($valid_qcode == 0)
+               {
+                       alert("Vous devez donner la colonne quick_code");
+                       return 1;
+               }
                /*
                 * read the file and record card
                 */
@@ -192,14 +191,6 @@
                                $array[$attr] = $row[$i];
                        }
                        /*
-                        * If no quick code is given we compute it ourself
-                        */
-                       if ($valid_qcode == 0)
-                       {
-                               $attr = sprintf('av_text%d', 
ATTR_DEF_QUICKCODE);
-                               $array[$attr] = 'FID';
-                       }
-                       /*
                         * Force the creating of an accounting
                         */
                        if ($valid_accounting == 0)
@@ -209,7 +200,16 @@
                        }
                        try
                        {
-                               $fiche->insert($rfichedef, $array);
+                               // If quick_code already exists then update 
otherwise insert
+                               $quick_code= 
sprintf('av_text%d',ATTR_DEF_QUICKCODE);
+                               if ( 
$fiche->get_by_qcode($array[$quick_code],false)==0 )
+                               {
+                                       $fiche->update($array);
+                               }
+                               else
+                               {
+                                       $fiche->insert($rfichedef, $array);
+                               }
                                echo td($g_succeed);
                        }
                        catch (Exception $e)



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

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