]> _ Git - cubeextranet.git/commitdiff
#2517 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 17 Jan 2019 15:30:19 +0000 (15:30 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 17 Jan 2019 15:30:19 +0000 (15:30 +0000)
inc/commons/class.common.ajax.php
inc/commons/class.common.tools.php

index 5a12774520709936274421a5e2c968ea3e9ebd8f..c7474d8b1507958487d599c36dc227a8362dd180 100644 (file)
@@ -472,18 +472,38 @@ Mot de passe : $password";
                $mail->send($transport);
        }
 
+       /**
+        * @param $args
+        * @param cubeAjax $x
+        * @throws PHPExcel_Exception
+        * @throws PHPExcel_Reader_Exception
+        */
        public static function importWSReferences($args, &$x)
        {
                global $core;
 
+               new PHPExcel();
 
                $e = explode('.', $_FILES['file']['name']);
-               $ext = array_pop($e);
-               new PHPExcel();
-               $reader = new PHPExcel_Reader_Excel2007();
+               $ext = mb_strtolower(array_pop($e));
+
+//             $x->enableXML=false;
+//             print_r($_FILES);
+//             exit;
+
+               if ($ext == 'xlsx') {
+                       $reader = new PHPExcel_Reader_Excel2007();
+               } else if ($ext == 'csv') {
+                       $reader = new PHPExcel_Reader_CSV();
+                       $reader->setDelimiter(";");
+               }
+
+
                $phpexcel = $reader->load($_FILES['file']['tmp_name']);
                $sheet = $phpexcel->getSheet(0);
                $maxRow = $sheet->getHighestRow(0);
+
+
                for ($i = 1; $i <= $maxRow; $i++) {
                        $ref = trim($sheet->getCellByColumnAndRow(0, $i));
                        $url = trim($sheet->getCellByColumnAndRow(1, $i)->getOldCalculatedValue());
@@ -495,6 +515,7 @@ Mot de passe : $password";
                                $url = trim($sheet->getCellByColumnAndRow(1, $i)->getFormattedValue());
                        }
 
+
                        if ($url == '' || $ref == '') {
                                continue;
                        }
index 914a1667e5321e198a6bb2c5c4f5d9b3b7703f97..522b849f42ed8ffdd50472b81969ac8a2f55bdb9 100644 (file)
@@ -1151,8 +1151,8 @@ class commonTools
                $res .= '<form action="importWSReferences" method="post" enctype="multipart/form-data">';
                $res .= '<table class="liste">';
                $res .= '<tr><th colspan="2"><strong>' . __('Importer un fichier de références') . '</strong></th></tr>';
-               $res .= '<tr><td>' . __("Fichier XLSX") . '<br>(colonne A : référence, colonne B : URL)</td><td><input type="file" name="file" accept=".xlsx" /></td></tr>';
-               $res .= '<tr><td>' . __("Type") . '</td><td><select name="type"><option>10doigts</option></select></td></tr>';
+               $res .= '<tr><td>' . __("Fichier XLSX") . '<br>(colonne A : référence, colonne B : URL)</td><td><input type="file" name="file" accept=".xlsx,.csv" /></td></tr>';
+               $res .= '<tr><td>' . __("Type") . '</td><td><select name="type"><option>10doigts</option><option value="ascocelda">Asco & Celda</option></select></td></tr>';
                $res .= '<tr><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Importer les références')) . '</a></td></td>';
                $res .= '</table>';
                $res .= '</form>';