phpcompta-dev
[Top][All Lists]
Advanced

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

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


From: phpcompta-dev
Subject: [Phpcompta-dev] r297 - trunk/import_card/include
Date: Sat, 4 Feb 2012 21:17:00 +0100 (CET)

Author: danydb
Date: 2012-02-03 23:38:38 +0100 (Fri, 03 Feb 2012)
New Revision: 297

Modified:
   trunk/import_card/include/class_import_card.php
Log:
indent properly


Modified: trunk/import_card/include/class_import_card.php
===================================================================
--- trunk/import_card/include/class_import_card.php     2012-02-03 22:35:14 UTC 
(rev 296)
+++ trunk/import_card/include/class_import_card.php     2012-02-03 22:38:38 UTC 
(rev 297)
@@ -1,4 +1,5 @@
 <?php
+
 /*
  *   This file is part of PhpCompta.
  *
@@ -15,215 +16,228 @@
  *   You should have received a copy of the GNU General Public License
  *   along with PhpCompta; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
+ */
 /* $Revision$ */
 
 // Copyright Author Dany De Bontridder address@hidden
 
-/*!\file
+/* !\file
  * \brief Manage import
  */
 
 class Import_Card
 {
-  /**
-   address@hidden for the form we have here all the hidden variables
-   address@hidden html string with the hidden dossier, plugin_code,action(sa)
-   */
-  static function hidden()
-  {
-    $r=HtmlInput::extension().Dossier::hidden();
-    return $r;
-  }
-  /**
-   address@hidden show the first screen, you must here enter the date format
-   * the file, the card category,
-   address@hidden html string
-   */
-  static function new_import()
-  {
-    global $cn;
-    ob_start();
-    $hidden=self::hidden().HtmlInput::hidden('sa','test');
-    $delimiter=new IText('rdelimiter');
-    $delimiter->size=1;
-    $delimiter->value=',';
 
-    $fd=new ISelect('rfichedef');
-    $fd->value=$cn->make_array('select fd_id,fd_label from fiche_def order by 
2');
-    $file=new IFile('csv_file');
-    $encodage=new ICheckBox('encodage');
-    $encodage->selected=true;
+       /**
+        * @brief for the form we have here all the hidden variables
+        * @return html string with the hidden dossier, plugin_code,action(sa)
+        */
+       static function hidden()
+       {
+               $r = HtmlInput::extension() . Dossier::hidden();
+               return $r;
+       }
 
-    require_once('template/input_file.php');
-    $r=ob_get_contents();
-    ob_clean();
-    echo $r;
+       /**
+        * @brief show the first screen, you must here enter the date format
+        * the file, the card category,
+        * @return html string
+        */
+       static function new_import()
+       {
+               global $cn;
+               ob_start();
+               $hidden = self::hidden() . HtmlInput::hidden('sa', 'test');
+               $delimiter = new IText('rdelimiter');
+               $delimiter->size = 1;
+               $delimiter->value = ',';
 
-  }
-  /**
-   *Test the CSV file, show the choosed delimiter, the CSV parsed,
-   * and replace column header by attribute
-   address@hidden 0 ok,  -1 error
-   */
-  static function test_import()
-  {
-    global $cn;
-    $hidden=self::hidden().HtmlInput::hidden('sa','record');
+               $fd = new ISelect('rfichedef');
+               $fd->value = $cn->make_array('select fd_id,fd_label from 
fiche_def order by 2');
+               $file = new IFile('csv_file');
+               $encodage = new ICheckBox('encodage');
+               $encodage->selected = true;
 
-    if ( trim($_FILES['csv_file']['name']) == '')
-      {
-       alert('Pas de fichier donné');
-       return -1;
-      }
-    $filename=tempnam($_ENV['TMP'],'upload_');
-    move_uploaded_file($_FILES["csv_file"]["tmp_name"],$filename);
+               require_once('template/input_file.php');
+               $r = ob_get_contents();
+               ob_clean();
+               echo $r;
+       }
 
-    $file_cat=$cn->get_value('select fd_label from fiche_def where 
fd_id=$1',array($_POST['rfichedef']));
-    $encoding=(isset ($_REQUEST['encodage']))?'Unicode':'latin1';
-    require_once('template/test_file.php');
-    return 0;
-  }
-  /**
-   address@hidden record all rows
-   address@hidden
-   address@hidden
-   address@hidden
-   address@hidden
address@hidden
-array
-  'plugin_code' => string 'IMPCARD' (length=7)
-  'gDossier' => string '30' (length=2)
-  'sa' => string 'record' (length=6)
-  'rfichedef' => string '17' (length=2)
-  'rdelimiter' => string ',' (length=1)
-  'encodage' => string '' (length=0)
-  'record_import' => string 'Valider' (length=7)
-  'head_col' =>
-    array
-      0 => string '15' (length=2)
-      1 => string '14' (length=2)
-      2 => string '-1' (length=2)
-      3 => string '-1' (length=2)
-      4 => string '-1' (length=2)
-      5 => string '-1' (length=2)
+       /**
+        * Test the CSV file, show the choosed delimiter, the CSV parsed,
+        * and replace column header by attribute
+        * @return 0 ok,  -1 error
+        */
+       static function test_import()
+       {
+               global $cn;
+               $hidden = self::hidden() . HtmlInput::hidden('sa', 'record');
 
address@hidden
-   */
-  static function record_import()
-  {
+               if (trim($_FILES['csv_file']['name']) == '')
+               {
+                       alert('Pas de fichier donné');
+                       return -1;
+               }
+               $filename = tempnam($_ENV['TMP'], 'upload_');
+               move_uploaded_file($_FILES["csv_file"]["tmp_name"], $filename);
 
-    global $cn,$g_failed,$g_succeed;
-    extract ($_POST);
-    $fd=fopen($filename,'r');
-    /*
-     * Check the column
-     */
-    $valid_col=0;$valid_name=0;$duplicate=0;$valid_qcode=0;$valid_accounting=0;
-    for ($i=0;$i<count($head_col);$i++)
-      {
-       if ($head_col[$i] != -1 )$valid_col++;
-       if ($head_col[$i] == 1 ) $valid_name=1;
-       if ( $head_col[$i] == ATTR_DEF_QUICKCODE ) $valid_qcode=1;
-       if ( $head_col[$i] == ATTR_DEF_ACCOUNT ) $valid_accounting=1;
+               $file_cat = $cn->get_value('select fd_label from fiche_def 
where fd_id=$1', array($_POST['rfichedef']));
+               $encoding = (isset($_REQUEST['encodage'])) ? 'Unicode' : 
'latin1';
+               require_once('template/test_file.php');
+               return 0;
+       }
 
-       for ($e=$i+1;$e<count($head_col);$e++)
-         if ($head_col[$i]==$head_col[$e] && $head_col[$e] != -1)
-           $duplicate++;
-      }
+       /**
+        * @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)
+         'rfichedef' => string '17' (length=2)
+         'rdelimiter' => string ',' (length=1)
+         'encodage' => string '' (length=0)
+         'record_import' => string 'Valider' (length=7)
+         'head_col' =>
+         array
+         0 => string '15' (length=2)
+         1 => string '14' (length=2)
+         2 => string '-1' (length=2)
+         3 => string '-1' (length=2)
+         4 => string '-1' (length=2)
+         5 => string '-1' (length=2)
 
-    if ( $valid_col==0)
-      {
-       alert("Aucune colonne n'est définie");
-       return -1;
-      }
-    if ( $valid_name==0)
-      {
-       alert("Les fiches doivent avoir au minimum un nom");
-       return -1;
-      }
-    if ( $duplicate != 0)
-      {
-       alert('Vous avez défini plusieurs fois la même colonne');
-       return -1;
-      }
+         @endcode
+        */
+       static function record_import()
+       {
 
+               global $cn, $g_failed, $g_succeed;
+               extract($_POST);
+               $fd = fopen($filename, 'r');
+               /*
+                * Check the column
+                */
+               $valid_col = 0;
+               $valid_name = 0;
+               $duplicate = 0;
+               $valid_qcode = 0;
+               $valid_accounting = 0;
+               for ($i = 0; $i < count($head_col); $i++)
+               {
+                       if ($head_col[$i] != -1)
+                               $valid_col++;
+                       if ($head_col[$i] == 1)
+                               $valid_name = 1;
+                       if ($head_col[$i] == ATTR_DEF_QUICKCODE)
+                               $valid_qcode = 1;
+                       if ($head_col[$i] == ATTR_DEF_ACCOUNT)
+                               $valid_accounting = 1;
 
-    /*
-     * read the file and record card
-     */
+                       for ($e = $i + 1; $e < count($head_col); $e++)
+                               if ($head_col[$i] == $head_col[$e] && 
$head_col[$e] != -1)
+                                       $duplicate++;
+               }
 
-    $row_count=0;
+               if ($valid_col == 0)
+               {
+                       alert("Aucune colonne n'est définie");
+                       return -1;
+               }
+               if ($valid_name == 0)
+               {
+                       alert("Les fiches doivent avoir au minimum un nom");
+                       return -1;
+               }
+               if ($duplicate != 0)
+               {
+                       alert('Vous avez défini plusieurs fois la même 
colonne');
+                       return -1;
+               }
 
-    echo '<table>';
 
-    ob_start();
-    while (($row=fgetcsv($fd,0,$_POST['rdelimiter'],$_POST['rsurround'])) !== 
false)
-      {
-       $fiche=new Fiche($cn);
-       $array=array();
-       $row_count++;
-       echo '<tr style="border:solid 1px black">';
-       echo td($row_count);
-       $count_col=count($row);
-       $col_count=0;
-       for ($i=0;$i<$count_col;$i++)
-         {
-           if ( $head_col[$i]==-1) continue;
+               /*
+                * read the file and record card
+                */
 
-           $header[$col_count]=$head_col[$i];
-           $col_count++;
+               $row_count = 0;
 
-           echo td ($row[$i]);
-           $attr=sprintf('av_text%d',$head_col[$i]);
-           $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)
-         {
-           $attr=sprintf('av_text%d',ATTR_DEF_ACCOUNT);
-           $array[$attr]='';
-         }
-         try
-         {
-               $fiche->insert($rfichedef,$array);
-               echo td($g_succeed);
-         }
-         catch(Exception $e)
-         {
-                 echo td($g_failed);
-                 echo td($e->getMessage());
-         }
-       echo '</tr>';
-      }
-    $table_content=ob_get_contents();
-    ob_clean();
-    echo '<tr>';
-    echo th('');
-    for ($e=0;$e<count($header);$e++)
-      {
-       $name=$cn->get_value('select ad_text from attr_def where 
ad_id=$1',array($header[$e]));
-       echo th($name);
-      }
-    echo '</tr>';
-    echo $table_content;
+               echo '<table>';
 
-    echo '</table>';
-    $name=$cn->get_value('select fd_label from fiche_def where 
fd_id=$1',array($rfichedef));
-    $cn->get_value('select 
comptaproc.fiche_attribut_synchro($1)',array($rfichedef));
-    echo '<span class="notice">';
-    echo $row_count.' fiches sont insérées dans la catégorie '.$name;
-    echo '</span>';
-    return 0;
-  }
+               ob_start();
+               while (($row = fgetcsv($fd, 0, $_POST['rdelimiter'], 
$_POST['rsurround'])) !== false)
+               {
+                       $fiche = new Fiche($cn);
+                       $array = array();
+                       $row_count++;
+                       echo '<tr style="border:solid 1px black">';
+                       echo td($row_count);
+                       $count_col = count($row);
+                       $col_count = 0;
+                       for ($i = 0; $i < $count_col; $i++)
+                       {
+                               if ($head_col[$i] == -1)
+                                       continue;
+
+                               $header[$col_count] = $head_col[$i];
+                               $col_count++;
+
+                               echo td($row[$i]);
+                               $attr = sprintf('av_text%d', $head_col[$i]);
+                               $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)
+                       {
+                               $attr = sprintf('av_text%d', ATTR_DEF_ACCOUNT);
+                               $array[$attr] = '';
+                       }
+                       try
+                       {
+                               $fiche->insert($rfichedef, $array);
+                               echo td($g_succeed);
+                       }
+                       catch (Exception $e)
+                       {
+                               echo td($g_failed);
+                               echo td($e->getMessage());
+                       }
+                       echo '</tr>';
+               }
+               $table_content = ob_get_contents();
+               ob_clean();
+               echo '<tr>';
+               echo th('');
+               for ($e = 0; $e < count($header); $e++)
+               {
+                       $name = $cn->get_value('select ad_text from attr_def 
where ad_id=$1', array($header[$e]));
+                       echo th($name);
+               }
+               echo '</tr>';
+               echo $table_content;
+
+               echo '</table>';
+               $name = $cn->get_value('select fd_label from fiche_def where 
fd_id=$1', array($rfichedef));
+               $cn->get_value('select comptaproc.fiche_attribut_synchro($1)', 
array($rfichedef));
+               echo '<span class="notice">';
+               echo $row_count . ' fiches sont insérées dans la catégorie ' . 
$name;
+               echo '</span>';
+               return 0;
+       }
+
 }
\ No newline at end of file



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