Skip to content
Snippets Groups Projects
Commit bafa2530 authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX empty cell when we export report

parent 40c1877a
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* /*
* Copyright 2008-2015 Maarch * Copyright 2008-2017 Maarch
* *
* This file is part of Maarch Framework. * This file is part of Maarch Framework.
* *
* Maarch Framework is free software: you can redistribute it and/or modify * Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Maarch Framework is distributed in the hope that it will be useful, * Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/ */
require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_functions.php"); require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_functions.php");
$core_tools = new core_tools(); $core_tools = new core_tools();
$core_tools->test_user(); $core_tools->test_user();
$core_tools->test_service('reports', 'reports'); $core_tools->test_service('reports', 'reports');
if(isset($_POST["data"])){ if (isset($_POST["data"])) {
try{ try {
$functions = new functions(); $functions = new functions();
$_POST['data'] = urldecode($_POST['data']); $_POST['data'] = urldecode($_POST['data']);
$data = json_decode($_POST['data']); $data = json_decode($_POST['data']);
//var_dump($data); //var_dump($data);
$_SESSION['export']['filename'] = 'export_reports_maarch.csv'; $_SESSION['export']['filename'] = 'export_reports_maarch.csv';
$contenu = ''; $contenu = '';
$fp = fopen('apps/maarch_entreprise/tmp/export_reports_maarch.csv', 'w'); $fp = fopen('apps/maarch_entreprise/tmp/export_reports_maarch.csv', 'w');
$data_to_array = $functions->object2array($data); $data_to_array = $functions->object2array($data);
foreach($data_to_array as $line){ foreach ($data_to_array as $line) {
//conversion en UTF-8 //conversion en UTF-8
$line['LABEL'] = $functions->wash_html($line['LABEL'], "UTF-8"); $line['LABEL'] = $functions->wash_html($line['LABEL'], "UTF-8");
$line['VALUE'] = $functions->wash_html($line['VALUE'], "UTF-8"); $line['VALUE'] = $functions->wash_html($line['VALUE'], "UTF-8");
fputcsv($fp, $line, ';'); if (empty($line['VALUE'])) {
} // Evite d'avoir une cellule vide
$line['VALUE'] = 0;
fclose($fp); }
$return['status'] = 1; fputcsv($fp, $line, ';');
} catch(Exeption $e){ }
$return['response'] = "ERROR : " . $e;
$return['status'] = 0; fclose($fp);
} $return['status'] = 1;
} catch (Exeption $e) {
} $return['response'] = "ERROR : " . $e;
echo json_encode($return); $return['status'] = 0;
?> }
}
echo json_encode($return);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment