From 150cdec4bd779eb8970c1ea6f780fa7fcb80c7b0 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 17 Jan 2019 15:30:19 +0000 Subject: [PATCH] #2517 @1.5 --- inc/commons/class.common.ajax.php | 27 ++++++++++++++++++++++++--- inc/commons/class.common.tools.php | 4 ++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/inc/commons/class.common.ajax.php b/inc/commons/class.common.ajax.php index 5a1277452..c7474d8b1 100644 --- a/inc/commons/class.common.ajax.php +++ b/inc/commons/class.common.ajax.php @@ -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; } diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 914a1667e..522b849f4 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1151,8 +1151,8 @@ class commonTools $res .= '
'; $res .= ''; $res .= ''; - $res .= ''; - $res .= ''; + $res .= ''; + $res .= ''; $res .= ''; $res .= '
' . __('Importer un fichier de références') . '
' . __("Fichier XLSX") . '
(colonne A : référence, colonne B : URL)
' . __("Type") . '
' . __("Fichier XLSX") . '
(colonne A : référence, colonne B : URL)
' . __("Type") . '
' . $core->typo->BoutonOK(__('Importer les références')) . '
'; $res .= '
'; -- 2.39.5