New: Type of fields are received by export format handlers
This commit is contained in:
parent
e74b07cbff
commit
6c2841d4d6
@ -35,6 +35,7 @@ For developers:
|
|||||||
into conf->liste_limit).
|
into conf->liste_limit).
|
||||||
- New: Add option dol_hide_topmenu and dol_hide_leftmenu onto login page.
|
- New: Add option dol_hide_topmenu and dol_hide_leftmenu onto login page.
|
||||||
- New: dol_syslog method accept a suffix to use different log files for log.
|
- New: dol_syslog method accept a suffix to use different log files for log.
|
||||||
|
- New: Type of fields are received by export format handlers
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- Update language files.
|
- Update language files.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -220,9 +220,10 @@ class ExportCsv extends ModeleExports
|
|||||||
* @param array $array_selected_sorted Array with list of field to export
|
* @param array $array_selected_sorted Array with list of field to export
|
||||||
* @param resource $objp A record from a fetch with all fields from select
|
* @param resource $objp A record from a fetch with all fields from select
|
||||||
* @param Translate $outputlangs Object lang to translate values
|
* @param Translate $outputlangs Object lang to translate values
|
||||||
|
* @param array $array_types Array with types of fields
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function write_record($array_selected_sorted,$objp,$outputlangs)
|
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -241,7 +242,9 @@ class ExportCsv extends ModeleExports
|
|||||||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||||
else $alias=substr($code, strpos($code, ' as ') + 4);
|
else $alias=substr($code, strpos($code, ' as ') + 4);
|
||||||
if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
|
if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
|
||||||
|
|
||||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||||
|
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||||
|
|
||||||
// Translation newvalue
|
// Translation newvalue
|
||||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||||
|
|||||||
@ -260,9 +260,10 @@ class ExportExcel extends ModeleExports
|
|||||||
* @param array $array_selected_sorted Array with list of field to export
|
* @param array $array_selected_sorted Array with list of field to export
|
||||||
* @param resource $objp A record from a fetch with all fields from select
|
* @param resource $objp A record from a fetch with all fields from select
|
||||||
* @param Translate $outputlangs Object lang to translate values
|
* @param Translate $outputlangs Object lang to translate values
|
||||||
|
* @param array $array_types Array with types of fields
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function write_record($array_selected_sorted,$objp,$outputlangs)
|
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
|
||||||
{
|
{
|
||||||
// Create a format for the column headings
|
// Create a format for the column headings
|
||||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||||
@ -281,6 +282,7 @@ class ExportExcel extends ModeleExports
|
|||||||
$newvalue=$objp->$alias;
|
$newvalue=$objp->$alias;
|
||||||
|
|
||||||
$newvalue=$this->excel_clean($newvalue);
|
$newvalue=$this->excel_clean($newvalue);
|
||||||
|
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||||
|
|
||||||
// Traduction newvalue
|
// Traduction newvalue
|
||||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||||
|
|||||||
@ -350,8 +350,8 @@ class ExportExcel2007 extends ExportExcel
|
|||||||
//$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
//$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
||||||
if ($typefield == 'Text')
|
if ($typefield == 'Text')
|
||||||
{
|
{
|
||||||
var_dump($code.' '.$alias.' '.$newvalue.' '.$typefield);
|
//var_dump($code.' '.$alias.' '.$newvalue.' '.$typefield);
|
||||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
//$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
|
||||||
$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
|
$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -204,17 +204,22 @@ class ExportTsv extends ModeleExports
|
|||||||
* @param array $array_selected_sorted Array with list of field to export
|
* @param array $array_selected_sorted Array with list of field to export
|
||||||
* @param resource $objp A record from a fetch with all fields from select
|
* @param resource $objp A record from a fetch with all fields from select
|
||||||
* @param Translate $outputlangs Object lang to translate values
|
* @param Translate $outputlangs Object lang to translate values
|
||||||
|
* @param array $array_types Array with types of fields
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function write_record($array_selected_sorted,$objp,$outputlangs)
|
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$this->col=0;
|
$this->col=0;
|
||||||
foreach($array_selected_sorted as $code => $value)
|
foreach($array_selected_sorted as $code => $value)
|
||||||
{
|
{
|
||||||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||||
else $alias=substr($code, strpos($code, ' as ') + 4);
|
else $alias=substr($code, strpos($code, ' as ') + 4);
|
||||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||||
$newvalue=$objp->$alias;
|
|
||||||
|
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||||
|
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||||
|
|
||||||
// Translation newvalue
|
// Translation newvalue
|
||||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||||
@ -222,7 +227,7 @@ class ExportTsv extends ModeleExports
|
|||||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newvalue=$this->tsv_clean($newvalue);
|
$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
|
||||||
|
|
||||||
fwrite($this->handle,$newvalue.$this->separator);
|
fwrite($this->handle,$newvalue.$this->separator);
|
||||||
$this->col++;
|
$this->col++;
|
||||||
@ -257,12 +262,13 @@ class ExportTsv extends ModeleExports
|
|||||||
* Clean a cell to respect rules of TSV file cells
|
* Clean a cell to respect rules of TSV file cells
|
||||||
*
|
*
|
||||||
* @param string $newvalue String to clean
|
* @param string $newvalue String to clean
|
||||||
|
* @param string $charset Output character set
|
||||||
* @return string Value cleaned
|
* @return string Value cleaned
|
||||||
*/
|
*/
|
||||||
function tsv_clean($newvalue)
|
function tsv_clean($newvalue, $charset)
|
||||||
{
|
{
|
||||||
// Rule Dolibarr: No HTML
|
// Rule Dolibarr: No HTML
|
||||||
$newvalue=dol_string_nohtmltag($newvalue);
|
$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
|
||||||
|
|
||||||
// Rule 1 TSV: No CR, LF in cells
|
// Rule 1 TSV: No CR, LF in cells
|
||||||
$newvalue=str_replace("\r",'',$newvalue);
|
$newvalue=str_replace("\r",'',$newvalue);
|
||||||
|
|||||||
@ -284,6 +284,7 @@ class modSociete extends DolibarrModules
|
|||||||
$this->export_icon[$r]='contact';
|
$this->export_icon[$r]='contact';
|
||||||
$this->export_permission[$r]=array(array("societe","contact","export"));
|
$this->export_permission[$r]=array(array("societe","contact","export"));
|
||||||
$this->export_fields_array[$r]=array('c.rowid'=>"IdContact",'c.civilite'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.email'=>"EMail",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode");
|
$this->export_fields_array[$r]=array('c.rowid'=>"IdContact",'c.civilite'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.email'=>"EMail",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode");
|
||||||
|
$this->export_TypeFields_array[$r]=array('c.lastname'=>"Text",'c.firstname'=>"Text",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text");
|
||||||
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company"); // We define here only fields that use another picto
|
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company"); // We define here only fields that use another picto
|
||||||
if (empty($conf->fournisseur->enabled))
|
if (empty($conf->fournisseur->enabled))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user