$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());
$url = trim($sheet->getCellByColumnAndRow(1, $i)->getFormattedValue());
}
+
if ($url == '' || $ref == '') {
continue;
}
$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>';