phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r317 - in trunk/import_doli: . include


From: phpcompta-dev
Subject: [Phpcompta-dev] r317 - in trunk/import_doli: . include
Date: Sun, 25 Mar 2012 17:05:05 +0200 (CEST)

Author: danydb
Date: 2012-03-25 17:05:05 +0200 (Sun, 25 Mar 2012)
New Revision: 317

Modified:
   trunk/import_doli/README.txt
   trunk/import_doli/include/class_import_card.php
   trunk/import_doli/index.php
Log:
si fiche existe alors update sinon ajout
quick_code est obligatoire !

Modified: trunk/import_doli/README.txt
===================================================================
--- trunk/import_doli/README.txt        2012-03-25 14:55:43 UTC (rev 316)
+++ trunk/import_doli/README.txt        2012-03-25 15:05:05 UTC (rev 317)
@@ -1 +1 @@
-Skeleton of a plugin. It contains the structure and example.
+Import data from dolibarr
\ No newline at end of file

Modified: trunk/import_doli/include/class_import_card.php
===================================================================
--- trunk/import_doli/include/class_import_card.php     2012-03-25 14:55:43 UTC 
(rev 316)
+++ trunk/import_doli/include/class_import_card.php     2012-03-25 15:05:05 UTC 
(rev 317)
@@ -30,7 +30,7 @@
 
        /**
         * @brief for the form we have here all the hidden variables
-        * @return html string with the hidden dossier, plugin_code,action(sa)
+        * @return html string with the hidden dossier, plugin_code,action(sb)
         */
        static function hidden()
        {
@@ -47,7 +47,7 @@
        {
                global $cn;
                ob_start();
-               $hidden = self::hidden() . HtmlInput::hidden('sa', 'test');
+               $hidden = self::hidden() . HtmlInput::hidden('sb', 'test');
                $delimiter = new IText('rdelimiter');
                $delimiter->size = 1;
                $delimiter->value = ',';
@@ -72,7 +72,7 @@
        static function test_import()
        {
                global $cn;
-               $hidden = self::hidden() . HtmlInput::hidden('sa', 'record');
+               $hidden = self::hidden() . HtmlInput::hidden('sb', 'record');
 
                if (trim($_FILES['csv_file']['name']) == '')
                {
@@ -90,15 +90,11 @@
 
        /**
         * @brief record all rows
-        * @param
-        * @return
-        * @note
-        * @see
          @code
          array
          'plugin_code' => string 'IMPCARD' (length=7)
          'gDossier' => string '30' (length=2)
-         'sa' => string 'record' (length=6)
+         'sb' => string 'record' (length=6)
          'rfichedef' => string '17' (length=2)
          'rdelimiter' => string ',' (length=1)
          'encodage' => string '' (length=0)
@@ -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)

Modified: trunk/import_doli/index.php
===================================================================
--- trunk/import_doli/index.php 2012-03-25 14:55:43 UTC (rev 316)
+++ trunk/import_doli/index.php 2012-03-25 15:05:05 UTC (rev 317)
@@ -29,26 +29,76 @@
  */
 require_once('include/class_import_card.php');
 global $cn;
-echo '<div style="float:right"><a class="mtitle" style="font-size:140%" 
href="http://wiki.phpcompta.eu/doku.php?id=importation_de_fiche"; 
target="_blank">Aide</a>'.
+echo '<div style="float:right"><a class="mtitle" style="font-size:140%" 
href="http://wiki.phpcompta.eu/doku.php?id=importation_dolibarr"; 
target="_blank">Aide</a>'.
 '<span style="font-size:0.8em;color:red;display:inline">vers:SVNINFO</span>'.
 '</div>';
 $cn=new Database(dossier::id());
-if ( ! isset($_REQUEST['sa']))
+
+
+Extension::check_version(4600);
+
+// Javascript
+/* ob_start();
+ require_once('impdoli-javascript.js');
+$j=ob_get_contents();
+ob_clean();
+echo create_script($j);
+*/
+
+
+$url='?'.dossier::get().'&plugin_code='.$_REQUEST['plugin_code']."&ac=".$_REQUEST['ac'];
+
+$array=array (
+       array($url.'&sa=fiche',_('Fiches'),_('Importation de nouvelles 
fiches'),1),
+       array($url.'&sa=opr',_('Opérations'),_('Importation d\'opérations'),1),
+       array($url.'&sa=parm',_('Paramètrage'),_('Paramètrage'),5)
+       );
+
+$sa=(isset($_REQUEST['sa']))?$_REQUEST['sa']:1;
+switch($sa)
   {
-    Import_Card::new_import();
-    exit();
+  case 'fiche':
+    $default=1;
+    break;
+  case 'opr':
+    $default=2;
+    break;
+  case 'parm':
+    $default=3;
+    break;
+  default:
+    $default=0;
   }
 
-if ( $_REQUEST['sa']=='test')
+  if ($cn->exist_schema('import_dolibarr') == false)
   {
-    if (Import_Card::test_import() == 0 )    exit();
-    Import_Card::new_import();
-    exit();
+    /*require_once('include/class_install_plugin.php');
 
+    $iplugn=new Install_Plugin($cn);
+    $iplugn->install();
+*/
   }
+echo ShowItem($array,'H','mtitle','mtitle',$default,' 
style="width:80%;margin-left:10%"');
 
-if($_REQUEST['sa'] == 'record')
-  {
-    if (Import_Card::record_import() ==0 )     exit();
-    Import_Card::new_import();
-  }
\ No newline at end of file
+if ($default==1)
+{
+       if ( ! isset($_REQUEST['sb']))
+       {
+               Import_Card::new_import();
+               exit();
+       }
+
+       if ( $_REQUEST['sb']=='test')
+       {
+               if (Import_Card::test_import() == 0 )    exit();
+               Import_Card::new_import();
+               exit();
+
+       }
+
+       if($_REQUEST['sb'] == 'record')
+       {
+               if (Import_Card::record_import() ==0 )     exit();
+               Import_Card::new_import();
+  }
+}



---
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]