forked from Wavyzz/dolibarr
Fix: bad accent in csv format
This commit is contained in:
@@ -107,16 +107,16 @@ class ExportCsv extends ModeleExports
|
|||||||
* \return int <0 if KO, >=0 if OK
|
* \return int <0 if KO, >=0 if OK
|
||||||
*/
|
*/
|
||||||
function open_file($file,$outputlangs)
|
function open_file($file,$outputlangs)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
dol_syslog("ExportCsv::open_file file=".$file);
|
dol_syslog("ExportCsv::open_file file=".$file);
|
||||||
|
|
||||||
$ret=1;
|
$ret=1;
|
||||||
|
|
||||||
$outputlangs->load("exports");
|
$outputlangs->load("exports");
|
||||||
$this->handle = fopen($file, "wt");
|
$this->handle = fopen($file, "wt");
|
||||||
if (! $this->handle)
|
if (! $this->handle)
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error=$langs->trans("ErrorFailToCreateFile",$file);
|
$this->error=$langs->trans("ErrorFailToCreateFile",$file);
|
||||||
@@ -124,7 +124,7 @@ class ExportCsv extends ModeleExports
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Output header into file
|
* \brief Output header into file
|
||||||
@@ -132,7 +132,7 @@ class ExportCsv extends ModeleExports
|
|||||||
*/
|
*/
|
||||||
function write_header($outputlangs)
|
function write_header($outputlangs)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,17 +143,25 @@ class ExportCsv extends ModeleExports
|
|||||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) $outputlangs->charset_output=$conf->global->EXPORT_CSV_FORCE_CHARSET;
|
|
||||||
|
|
||||||
foreach($array_selected_sorted as $code => $value)
|
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
|
||||||
{
|
{
|
||||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
|
||||||
$newvalue=$this->csv_clean($newvalue);
|
}
|
||||||
|
else
|
||||||
fwrite($this->handle,$newvalue.$this->separator);
|
{
|
||||||
}
|
$outputlangs->charset_output = 'ISO-8859-1';
|
||||||
fwrite($this->handle,"\n");
|
}
|
||||||
return 0;
|
|
||||||
|
foreach($array_selected_sorted as $code => $value)
|
||||||
|
{
|
||||||
|
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||||
|
$newvalue=$this->csv_clean($newvalue);
|
||||||
|
|
||||||
|
fwrite($this->handle,$newvalue.$this->separator);
|
||||||
|
}
|
||||||
|
fwrite($this->handle,"\n");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,28 +171,37 @@ class ExportCsv extends ModeleExports
|
|||||||
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) $outputlangs->charset_output=$conf->global->EXPORT_CSV_FORCE_CHARSET;
|
|
||||||
|
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
|
||||||
|
{
|
||||||
|
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$outputlangs->charset_output = 'ISO-8859-1';
|
||||||
|
}
|
||||||
|
|
||||||
$this->col=0;
|
$this->col=0;
|
||||||
foreach($array_selected_sorted as $code => $value)
|
foreach($array_selected_sorted as $code => $value)
|
||||||
|
{
|
||||||
|
$alias=$array_alias[$code];
|
||||||
|
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||||
|
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||||
|
|
||||||
|
// Translation newvalue
|
||||||
|
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||||
{
|
{
|
||||||
$alias=$array_alias[$code];
|
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
}
|
||||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
|
||||||
|
$newvalue=$this->csv_clean($newvalue);
|
||||||
// Translation newvalue
|
|
||||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
fwrite($this->handle,$newvalue.$this->separator);
|
||||||
{
|
$this->col++;
|
||||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
}
|
||||||
}
|
|
||||||
|
fwrite($this->handle,"\n");
|
||||||
$newvalue=$this->csv_clean($newvalue);
|
return 0;
|
||||||
|
|
||||||
fwrite($this->handle,$newvalue.$this->separator);
|
|
||||||
$this->col++;
|
|
||||||
}
|
|
||||||
fwrite($this->handle,"\n");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class modUser extends DolibarrModules
|
|||||||
|
|
||||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
|
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
|
||||||
$this->export_sql_end[$r] .=' WHERE u.entity = '.$conf->entity;
|
$this->export_sql_end[$r] .=' WHERE u.entity IN (0,'.$conf->entity.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user