mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
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).
|
||||
- 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: Type of fields are received by export format handlers
|
||||
|
||||
For translators:
|
||||
- Update language files.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?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
|
||||
* 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 resource $objp A record from a fetch with all fields from select
|
||||
* @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
|
||||
*/
|
||||
function write_record($array_selected_sorted,$objp,$outputlangs)
|
||||
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
|
@ -241,8 +242,10 @@ class ExportCsv extends ModeleExports
|
|||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||
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.');
|
||||
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
// Translation newvalue
|
||||
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 resource $objp A record from a fetch with all fields from select
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
|
|
@ -281,7 +282,8 @@ class ExportExcel extends ModeleExports
|
|||
$newvalue=$objp->$alias;
|
||||
|
||||
$newvalue=$this->excel_clean($newvalue);
|
||||
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
// Traduction newvalue
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -350,8 +350,8 @@ class ExportExcel2007 extends ExportExcel
|
|||
//$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
||||
if ($typefield == 'Text')
|
||||
{
|
||||
var_dump($code.' '.$alias.' '.$newvalue.' '.$typefield);
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
||||
//var_dump($code.' '.$alias.' '.$newvalue.' '.$typefield);
|
||||
//$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);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -204,25 +204,30 @@ class ExportTsv extends ModeleExports
|
|||
* @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 Translate $outputlangs Object lang to translate values
|
||||
* @param array $array_types Array with types of fields
|
||||
* @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;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||
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.');
|
||||
$newvalue=$objp->$alias;
|
||||
|
||||
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
// Translation newvalue
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
$newvalue=$this->tsv_clean($newvalue);
|
||||
$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
$this->col++;
|
||||
|
|
@ -257,12 +262,13 @@ class ExportTsv extends ModeleExports
|
|||
* Clean a cell to respect rules of TSV file cells
|
||||
*
|
||||
* @param string $newvalue String to clean
|
||||
* @param string $charset Output character set
|
||||
* @return string Value cleaned
|
||||
*/
|
||||
function tsv_clean($newvalue)
|
||||
function tsv_clean($newvalue, $charset)
|
||||
{
|
||||
// Rule Dolibarr: No HTML
|
||||
$newvalue=dol_string_nohtmltag($newvalue);
|
||||
$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
|
||||
|
||||
// Rule 1 TSV: No CR, LF in cells
|
||||
$newvalue=str_replace("\r",'',$newvalue);
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ class modSociete extends DolibarrModules
|
|||
$this->export_icon[$r]='contact';
|
||||
$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_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
|
||||
if (empty($conf->fournisseur->enabled))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user