diff --git a/htdocs/exports/export.class.php b/htdocs/exports/export.class.php index 88e198f5d1f..cfd28b86c91 100644 --- a/htdocs/exports/export.class.php +++ b/htdocs/exports/export.class.php @@ -38,8 +38,9 @@ class Export var $array_export_module=array(); // Tableau de "nom de modules" var $array_export_label=array(); // Tableau de "libellé de lots" var $array_export_sql=array(); // Tableau des "requetes sql" - var $array_export_fields=array(); // Tableau des liste de champ+libellé à exporter - var $array_export_alias=array(); // Tableau des liste de champ+alias à exporter + 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_special=array(); // Tableau des operations speciales sur champ // Création des modéles d'export var $hexa; @@ -131,13 +132,15 @@ class Export $this->array_export_entities[$i]=$module->export_entities_array[$r]; // Tableau des alias à exporter (clé=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]; // Requete sql du dataset $this->array_export_sql_start[$i]=$module->export_sql_start[$r]; $this->array_export_sql_end[$i]=$module->export_sql_end[$r]; //$this->array_export_sql[$i]=$module->export_sql[$r]; - dolibarr_syslog("Export chargé pour le module ".$modulename." en index ".$i.", dataset=".$module->export_code[$r].", nbre de champs=".sizeof($module->export_fields_code[$r])); + dolibarr_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r])); $i++; } } @@ -185,7 +188,7 @@ class Export $newfield=$key.' as '.$value; // Cas particulier - if ($this->array_export_module[$indice]->id == 'banque') +/* if ($this->array_export_module[$indice]->name == 'Banque') { // Cas special du debit et credit if ($value=='credit' || $value=='debit') @@ -193,7 +196,7 @@ class Export $newfield='IF('.$key.'>0,'.$key.',NULL) as '.$value; } } - +*/ $sql.=$newfield; } $sql.=$this->array_export_sql_end[$indice]; @@ -221,7 +224,30 @@ class Export while ($objp = $this->db->fetch_object($resql)) { $var=!$var; - $objmodel->write_record($this->array_export_alias[$indice],$array_selected,$objp); + + // Process special operations + if (! empty($this->array_export_special[$indice])) + { + foreach ($this->array_export_special[$indice] as $key => $value) + { + if (! array_key_exists($key, $array_selected)) continue; // Field not selected + // Operation NULLIFNEG + if ($this->array_export_special[$indice][$key]=='NULLIFNEG') + { + $alias=$this->array_export_alias[$indice][$key]; + if ($objp->$alias < 0) $objp->$alias=''; + } + // Operation ZEROIFNEG + if ($this->array_export_special[$indice][$key]=='ZEROIFNEG') + { + $alias=$this->array_export_alias[$indice][$key]; + if ($objp->$alias < 0) $objp->$alias='0'; + } + } + } + // end of special operation processing + + $objmodel->write_record($this->array_export_alias[$indice],$array_selected,$objp); } // Genere en-tete diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index d24948f1a54..c6c378e55c7 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -127,7 +127,7 @@ if ($step == 1 || $action == 'cleanselect') if ($action == 'builddoc') { - // Gen�re le fichier + // Build export file $result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected); if ($result < 0) { diff --git a/htdocs/includes/modules/export/export_csv.modules.php b/htdocs/includes/modules/export/export_csv.modules.php index c7513fca06a..b81b3edcbe7 100644 --- a/htdocs/includes/modules/export/export_csv.modules.php +++ b/htdocs/includes/modules/export/export_csv.modules.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2008 Laurent Destailleur * * 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 @@ -15,9 +15,6 @@ * 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/ -* -* $Id$ -* $Source$ */ /** @@ -25,7 +22,7 @@ \ingroup export \brief Fichier de la classe permettant de générer les export au format CSV \author Laurent Destailleur - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/export/modules_export.php"); diff --git a/htdocs/includes/modules/export/export_excel.modules.php b/htdocs/includes/modules/export/export_excel.modules.php index 49e4961c0bc..152635f3b00 100644 --- a/htdocs/includes/modules/export/export_excel.modules.php +++ b/htdocs/includes/modules/export/export_excel.modules.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2008 Laurent Destailleur * * 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 @@ -15,9 +15,6 @@ * 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/ -* -* $Id$ -* $Source$ */ /** @@ -25,7 +22,7 @@ \ingroup export \brief Fichier de la classe permettant de générer les export au format Excel \author Laurent Destailleur - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php"); diff --git a/htdocs/includes/modules/modBanque.class.php b/htdocs/includes/modules/modBanque.class.php index ec5f78ad55a..0bd014c2b79 100644 --- a/htdocs/includes/modules/modBanque.class.php +++ b/htdocs/includes/modules/modBanque.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * @@ -135,7 +135,8 @@ class modBanque extends DolibarrModules $this->export_fields_array[$r]=array('b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label','b.num_chq'=>'CheckNumber','-b.amount'=>'Debit','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","but.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode"); $this->export_entities_array[$r]=array('b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account','b.num_chq'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account","but.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company"); $this->export_alias_array[$r]=array('b.rowid'=>'tran_id','ba.ref'=>'account_ref','ba.label'=>'account_label','b.datev'=>'datev','b.dateo'=>'dateo','b.label'=>'label','b.num_chq'=>'num','-b.amount'=>'debit','b.amount'=>'credit','b.num_releve'=>'numrel','b.datec'=>"datec","but.url_id"=>"soc_id","s.nom"=>"thirdparty","s.code_compta"=>"customeracccode","s.code_compta_fournisseur"=>"supplieracccode"); - + $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); + $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_url as but ON but.fk_bank = b.rowid';