Export modules support UTF8
This commit is contained in:
parent
0aa9cca4e1
commit
2ced5a0d32
@ -36,13 +36,13 @@ class Export
|
||||
|
||||
var $array_export_code=array(); // Tableau de "idmodule_numlot"
|
||||
var $array_export_module=array(); // Tableau de "nom de modules"
|
||||
var $array_export_label=array(); // Tableau de "libellé de lots"
|
||||
var $array_export_label=array(); // Tableau de "libelle de lots"
|
||||
var $array_export_sql=array(); // Tableau des "requetes sql"
|
||||
var $array_export_fields=array(); // Tableau des listes de champ+libellé à exporter
|
||||
var $array_export_alias=array(); // Tableau des listes de champ+alias à exporter
|
||||
var $array_export_fields=array(); // Tableau des listes de champ+libell<EFBFBD> <20> exporter
|
||||
var $array_export_alias=array(); // Tableau des listes de champ+alias <EFBFBD> exporter
|
||||
var $array_export_special=array(); // Tableau des operations speciales sur champ
|
||||
|
||||
// Création des modéles d'export
|
||||
// To store export modules
|
||||
var $hexa;
|
||||
var $datatoexport;
|
||||
var $model_name;
|
||||
@ -50,7 +50,7 @@ class Export
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB Handler accès base de données
|
||||
* \param DB Handler acces base de donnees
|
||||
*/
|
||||
function Export($DB)
|
||||
{
|
||||
@ -59,9 +59,9 @@ class Export
|
||||
|
||||
|
||||
/**
|
||||
* \brief Charge les lots de données exportables
|
||||
* \brief Charge les lots de donn<EFBFBD>es exportables
|
||||
* \param user Objet utilisateur qui exporte
|
||||
* \param filter Code export pour charger un lot de données particulier
|
||||
* \param filter Code export pour charger un lot de donn<EFBFBD>es particulier
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
@ -124,13 +124,13 @@ class Export
|
||||
$this->array_export_module[$i]=$module;
|
||||
// Code du dataset export
|
||||
$this->array_export_code[$i]=$module->export_code[$r];
|
||||
// Libellé du dataset export
|
||||
// Libell<EFBFBD> du dataset export
|
||||
$this->array_export_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ à exporter (clé=champ, valeur=libellé)
|
||||
// Tableau des champ <EFBFBD> exporter (cl<63>=champ, valeur=libell<6C>)
|
||||
$this->array_export_fields[$i]=$module->export_fields_array[$r];
|
||||
// Tableau des entites à exporter (clé=champ, valeur=entite)
|
||||
// Tableau des entites <EFBFBD> exporter (cl<63>=champ, valeur=entite)
|
||||
$this->array_export_entities[$i]=$module->export_entities_array[$r];
|
||||
// Tableau des alias à exporter (clé=champ, valeur=alias)
|
||||
// Tableau des alias <EFBFBD> exporter (cl<63>=champ, valeur=alias)
|
||||
$this->array_export_alias[$i]=$module->export_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_export_special[$i]=$module->export_special_array[$r];
|
||||
@ -154,10 +154,10 @@ class Export
|
||||
* \brief Lance la generation du fichier
|
||||
* \param user User qui exporte
|
||||
* \param model Modele d'export
|
||||
* \param datatoexport Lot de donnée à exporter
|
||||
* \param array_selected Tableau des champs à exporter
|
||||
* \remarks Les tableaux array_export_xxx sont déjà chargées pour le bon datatoexport
|
||||
* aussi le parametre datatoexport est inutilisé
|
||||
* \param datatoexport Lot de donn<EFBFBD>e <EFBFBD> exporter
|
||||
* \param array_selected Tableau des champs <EFBFBD> exporter
|
||||
* \remarks Les tableaux array_export_xxx sont d<EFBFBD>j<EFBFBD> charg<EFBFBD>es pour le bon datatoexport
|
||||
* aussi le parametre datatoexport est inutilis<EFBFBD>
|
||||
*/
|
||||
function build_file($user, $model, $datatoexport, $array_selected)
|
||||
{
|
||||
@ -201,17 +201,19 @@ class Export
|
||||
$filename.='.'.$objmodel->getDriverExtension();
|
||||
$dirname=$conf->export->dir_temp.'/'.$user->id;
|
||||
|
||||
// Open file
|
||||
$outputlangs=$langs; // Lang for output
|
||||
|
||||
// Open file
|
||||
create_exdir($dirname);
|
||||
$result=$objmodel->open_file($dirname."/".$filename);
|
||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($langs);
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$langs);
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs);
|
||||
|
||||
while ($objp = $this->db->fetch_object($resql))
|
||||
{
|
||||
@ -239,11 +241,11 @@ class Export
|
||||
}
|
||||
// end of special operation processing
|
||||
|
||||
$objmodel->write_record($this->array_export_alias[$indice],$array_selected,$objp);
|
||||
$objmodel->write_record($this->array_export_alias[$indice],$array_selected,$objp,$outputlangs);
|
||||
}
|
||||
|
||||
// Genere en-tete
|
||||
$objmodel->write_footer($langs);
|
||||
$objmodel->write_footer($outputlangs);
|
||||
|
||||
// Close file
|
||||
$objmodel->close_file();
|
||||
@ -264,8 +266,8 @@ class Export
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Créé un modéle d'export
|
||||
* \param user Objet utilisateur qui crée
|
||||
* \brief Cr<EFBFBD><EFBFBD> un mod<EFBFBD>le d'export
|
||||
* \param user Objet utilisateur qui cr<EFBFBD>e
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
@ -296,8 +298,8 @@ class Export
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recupère de la base les caractéristiques d'un modele d'export
|
||||
* \param rowid id du modéle à récupérer
|
||||
* \brief Recup<EFBFBD>re de la base les caract<EFBFBD>ristiques d'un modele d'export
|
||||
* \param rowid id du mod<EFBFBD>le <EFBFBD> r<EFBFBD>cup<EFBFBD>rer
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
|
||||
@ -111,7 +111,11 @@ if (sizeof($export->array_export_code))
|
||||
|
||||
}
|
||||
|
||||
print '<tr class="total"><td class="total" colspan="2" align="center"><form action="'.DOL_URL_ROOT.'/exports/export.php?leftmenu=export"><input type="submit" class="button" value="'.$langs->trans("NewExport").'"></form></td></tr>';
|
||||
print '<tr class="total"><td class="total" colspan="2" align="center">';
|
||||
print '<form action="'.DOL_URL_ROOT.'/exports/export.php?leftmenu=export"><input type="submit" class="button" value="'.$langs->trans("NewExport").'"';
|
||||
print ($user->rights->export->creer?'':' disabled="true"');
|
||||
print '></form>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -804,6 +804,7 @@ class MenuLeft {
|
||||
$langs->load("exports");
|
||||
$newmenu->add_submenu(DOL_URL_ROOT."/exports/index.php?leftmenu=export",$langs->trans("FormatedExport"),0, $user->rights->export->lire);
|
||||
$newmenu->add_submenu(DOL_URL_ROOT."/exports/export.php?leftmenu=export",$langs->trans("NewExport"),1, $user->rights->export->creer);
|
||||
//$newmenu->add_submenu(DOL_URL_ROOT."/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire);
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_MODULE_IMPORT)
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/includes/modules/export/export_csv.modules.php
|
||||
* \ingroup export
|
||||
* \brief Fichier de la classe permettant de générer les export au format CSV
|
||||
* \brief Fichier de la classe permettant de g<EFBFBD>n<EFBFBD>rer les export au format CSV
|
||||
* \author Laurent Destailleur
|
||||
* \version $Id$
|
||||
*/
|
||||
@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/export/modules_export.php");
|
||||
|
||||
/**
|
||||
* \class ExportCsv
|
||||
* \brief Classe permettant de générer les factures au modèle Crabe
|
||||
* \brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les factures au mod<EFBFBD>le Crabe
|
||||
*/
|
||||
class ExportCsv extends ModeleExports
|
||||
{
|
||||
@ -49,11 +49,11 @@ class ExportCsv extends ModeleExports
|
||||
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db Handler accès base de donnée
|
||||
\param db Handler acc<EFBFBD>s base de donn<EFBFBD>e
|
||||
*/
|
||||
function ExportCsv($db)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf;
|
||||
$this->db = $db;
|
||||
|
||||
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
@ -103,14 +103,15 @@ class ExportCsv extends ModeleExports
|
||||
* \param file Path of filename
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function open_file($file)
|
||||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("ExportCsv::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
$langs->load("exports");
|
||||
$outputlangs->load("exports");
|
||||
$this->handle = fopen($file, "wt");
|
||||
if (! $this->handle)
|
||||
{
|
||||
@ -126,9 +127,9 @@ class ExportCsv extends ModeleExports
|
||||
* \brief Output header into file
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_header($langs)
|
||||
function write_header($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -136,11 +137,11 @@ class ExportCsv extends ModeleExports
|
||||
* \brief Output title line into file
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$langs)
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
{
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$newvalue=$langs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$this->csv_clean($newvalue);
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
@ -153,10 +154,8 @@ class ExportCsv extends ModeleExports
|
||||
/**
|
||||
* \brief Output record line into file
|
||||
*/
|
||||
function write_record($array_alias,$array_selected_sorted,$objp)
|
||||
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
@ -167,7 +166,7 @@ class ExportCsv extends ModeleExports
|
||||
// Translation newvalue
|
||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$langs->transnoentities($reg[1]);
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
$newvalue=$this->csv_clean($newvalue);
|
||||
@ -181,11 +180,11 @@ class ExportCsv extends ModeleExports
|
||||
|
||||
/**
|
||||
* \brief Output footer into file
|
||||
* \param langs Output language
|
||||
* \param outputlangs Output language
|
||||
*/
|
||||
function write_footer($langs)
|
||||
function write_footer($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/modules/export/export_excel.modules.php
|
||||
\ingroup export
|
||||
\brief Fichier de la classe permettant de générer les export au format Excel
|
||||
\author Laurent Destailleur
|
||||
\version $Id$
|
||||
*/
|
||||
\file htdocs/includes/modules/export/export_excel.modules.php
|
||||
\ingroup export
|
||||
\brief Fichier de la classe permettant de g<EFBFBD>n<EFBFBD>rer les export au format Excel
|
||||
\author Laurent Destailleur
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php");
|
||||
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbookbig.inc.php");
|
||||
@ -32,112 +32,122 @@ require_once(PHP_WRITEEXCEL_PATH."/functions.writeexcel_utility.inc.php");
|
||||
|
||||
|
||||
/**
|
||||
\class ExportExcel
|
||||
\brief Classe permettant de générer les export au format Excel
|
||||
*/
|
||||
\class ExportExcel
|
||||
\brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les export au format Excel
|
||||
*/
|
||||
|
||||
class ExportExcel extends ModeleExports
|
||||
{
|
||||
var $id;
|
||||
var $label;
|
||||
var $extension;
|
||||
var $version;
|
||||
var $id;
|
||||
var $label;
|
||||
var $extension;
|
||||
var $version;
|
||||
|
||||
var $label_lib;
|
||||
var $version_lib;
|
||||
var $label_lib;
|
||||
var $version_lib;
|
||||
|
||||
var $workbook; // Handle fichier
|
||||
var $worksheet; // Handle onglet
|
||||
var $row;
|
||||
var $col;
|
||||
|
||||
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db Handler accès base de donnée
|
||||
*/
|
||||
function ExportExcel($db)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$this->db = $db;
|
||||
|
||||
$this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Excel'; // Label of driver
|
||||
$this->extension='xls'; // Extension for generated file by this driver
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib='Php_WriteExcel';
|
||||
$this->version_lib='0.3.0';
|
||||
|
||||
$this->row=0;
|
||||
}
|
||||
|
||||
function getDriverId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function getDriverLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function getDriverExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
function getDriverVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
function getLibLabel()
|
||||
{
|
||||
return $this->label_lib;
|
||||
}
|
||||
|
||||
function getLibVersion()
|
||||
{
|
||||
return $this->version_lib;
|
||||
}
|
||||
var $workbook; // Handle fichier
|
||||
var $worksheet; // Handle onglet
|
||||
var $row;
|
||||
var $col;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Open output file
|
||||
* \param file Path of filename
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function open_file($file)
|
||||
{
|
||||
global $langs;
|
||||
dolibarr_syslog("ExportExcel::open_file file=".$file);
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db Handler acc<EFBFBD>s base de donn<EFBFBD>e
|
||||
*/
|
||||
function ExportExcel($db)
|
||||
{
|
||||
global $conf;
|
||||
$this->db = $db;
|
||||
|
||||
$this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Excel'; // Label of driver
|
||||
$this->extension='xls'; // Extension for generated file by this driver
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib='Php_WriteExcel';
|
||||
$this->version_lib='0.3.0';
|
||||
|
||||
$this->row=0;
|
||||
}
|
||||
|
||||
function getDriverId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function getDriverLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function getDriverExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
function getDriverVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
function getLibLabel()
|
||||
{
|
||||
return $this->label_lib;
|
||||
}
|
||||
|
||||
function getLibVersion()
|
||||
{
|
||||
return $this->version_lib;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Open output file
|
||||
* \param file Path of filename
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
dolibarr_syslog("ExportExcel::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
$langs->load("exports");
|
||||
$this->workbook = &new writeexcel_workbookbig($file);
|
||||
$this->workbook->set_sheetname($langs->trans("Sheet"));
|
||||
$this->worksheet = &$this->workbook->addworksheet();
|
||||
|
||||
// $this->worksheet->set_column(0, 50, 18);
|
||||
$outputlangs->load("exports");
|
||||
$this->workbook = &new writeexcel_workbookbig($file);
|
||||
$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
|
||||
$this->worksheet = &$this->workbook->addworksheet();
|
||||
|
||||
// $this->worksheet->set_column(0, 50, 18);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function write_header($outputlangs)
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function write_header($langs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$langs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
// Create a format for the column headings
|
||||
$formatheader =$this->workbook->addformat();
|
||||
$formatheader->set_bold();
|
||||
@ -145,85 +155,91 @@ class ExportExcel extends ModeleExports
|
||||
//$formatheader->set_size(12);
|
||||
//$formatheader->set_font("Courier New");
|
||||
//$formatheader->set_align('center');
|
||||
|
||||
|
||||
//$this->worksheet->insert_bitmap('A1', 'php.bmp', 16, 8);
|
||||
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$alias=$array_export_fields_label[$code];
|
||||
//print "dd".$alias;
|
||||
if (empty($alias)) dolibarr_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
$this->worksheet->write($this->row, $this->col, $langs->transnoentities($alias), $formatheader);
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function write_record($array_alias,$array_selected_sorted,$objp)
|
||||
{
|
||||
global $langs;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$alias=$array_export_fields_label[$code];
|
||||
//print "dd".$alias;
|
||||
if (empty($alias)) dolibarr_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
$formatdate=$this->workbook->addformat();
|
||||
$formatdate->set_num_format('yyyy-mm-dd');
|
||||
$formatdate->set_num_format('yyyy-mm-dd');
|
||||
//$formatdate->set_num_format(0x0f);
|
||||
|
||||
|
||||
$formatdatehour=$this->workbook->addformat();
|
||||
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
|
||||
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
|
||||
//$formatdatehour->set_num_format(0x0f);
|
||||
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$alias=$array_alias[$code];
|
||||
$newvalue=$objp->$alias;
|
||||
// Nettoyage newvalue
|
||||
$newvalue=clean_html($newvalue);
|
||||
// Traduction newvalue
|
||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$langs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
if (eregi('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',$newvalue))
|
||||
{
|
||||
$arrayvalue=split('[\.,]',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdate);
|
||||
}
|
||||
elseif (eregi('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$',$newvalue))
|
||||
{
|
||||
$arrayvalue=split('[\.,]',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue);
|
||||
}
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$alias=$array_alias[$code];
|
||||
$newvalue=$objp->$alias;
|
||||
// Nettoyage newvalue
|
||||
$newvalue=clean_html($newvalue);
|
||||
// Traduction newvalue
|
||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newvalue=$outputlangs->convToOuptutCharset($newvalue);
|
||||
}
|
||||
|
||||
if (eregi('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',$newvalue))
|
||||
{
|
||||
$arrayvalue=split('[\.,]',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdate);
|
||||
}
|
||||
elseif (eregi('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$',$newvalue))
|
||||
{
|
||||
$arrayvalue=split('[\.,]',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue);
|
||||
}
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function write_footer($langs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function write_footer($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function close_file()
|
||||
{
|
||||
$this->workbook->close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
function close_file()
|
||||
{
|
||||
$this->workbook->close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/includes/modules/export/export_csv.modules.php
|
||||
* \ingroup export
|
||||
* \brief Fichier de la classe permettant de générer les export au format CSV
|
||||
* \brief Fichier de la classe permettant de g<EFBFBD>n<EFBFBD>rer les export au format CSV
|
||||
* \author Laurent Destailleur
|
||||
* \version $Id$
|
||||
*/
|
||||
@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/export/modules_export.php");
|
||||
|
||||
/**
|
||||
* \class ExportCsv
|
||||
* \brief Classe permettant de générer les factures au modèle Crabe
|
||||
* \brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les factures au mod<EFBFBD>le Crabe
|
||||
*/
|
||||
class ExportTsv extends ModeleExports
|
||||
{
|
||||
@ -49,11 +49,11 @@ class ExportTsv extends ModeleExports
|
||||
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db Handler accès base de donnée
|
||||
\param db Handler acc<EFBFBD>s base de donn<EFBFBD>e
|
||||
*/
|
||||
function ExportTsv($db)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf;
|
||||
$this->db = $db;
|
||||
|
||||
$this->id='tsv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
@ -103,14 +103,15 @@ class ExportTsv extends ModeleExports
|
||||
* \param file Path of filename
|
||||
* \return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function open_file($file)
|
||||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("ExportTsv::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
$langs->load("exports");
|
||||
$outputlangs->load("exports");
|
||||
$this->handle = fopen($file, "wt");
|
||||
if (! $this->handle)
|
||||
{
|
||||
@ -126,7 +127,7 @@ class ExportTsv extends ModeleExports
|
||||
* \brief Output header into file
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_header($langs)
|
||||
function write_header($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -136,11 +137,11 @@ class ExportTsv extends ModeleExports
|
||||
* \brief Output title line into file
|
||||
* \param langs Output language
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$langs)
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
{
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$newvalue=$langs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$this->tsv_clean($newvalue);
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
@ -153,10 +154,8 @@ class ExportTsv extends ModeleExports
|
||||
/**
|
||||
* \brief Output record line into file
|
||||
*/
|
||||
function write_record($array_alias,$array_selected_sorted,$objp)
|
||||
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
@ -167,7 +166,7 @@ class ExportTsv extends ModeleExports
|
||||
// Translation newvalue
|
||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$langs->transnoentities($reg[1]);
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
$newvalue=$this->tsv_clean($newvalue);
|
||||
@ -181,11 +180,11 @@ class ExportTsv extends ModeleExports
|
||||
|
||||
/**
|
||||
* \brief Output footer into file
|
||||
* \param langs Output language
|
||||
* \param outputlangs Output language
|
||||
*/
|
||||
function write_footer($langs)
|
||||
function write_footer($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user