Fix: Export for bank module always export credit and devit instead of debit or credit

This commit is contained in:
Laurent Destailleur 2008-03-30 15:36:19 +00:00
parent 2445114bd4
commit f4ecf33e20
5 changed files with 40 additions and 19 deletions

View File

@ -38,8 +38,9 @@ class Export
var $array_export_module=array(); // Tableau de "nom de modules" 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 "libellé de lots"
var $array_export_sql=array(); // Tableau des "requetes sql" var $array_export_sql=array(); // Tableau des "requetes sql"
var $array_export_fields=array(); // Tableau des liste de champ+libellé à exporter var $array_export_fields=array(); // Tableau des listes de champ+libellé à exporter
var $array_export_alias=array(); // Tableau des liste de champ+alias à 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 // Création des modéles d'export
var $hexa; var $hexa;
@ -131,13 +132,15 @@ class Export
$this->array_export_entities[$i]=$module->export_entities_array[$r]; $this->array_export_entities[$i]=$module->export_entities_array[$r];
// Tableau des alias à exporter (clé=champ, valeur=alias) // Tableau des alias à exporter (clé=champ, valeur=alias)
$this->array_export_alias[$i]=$module->export_alias_array[$r]; $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 // Requete sql du dataset
$this->array_export_sql_start[$i]=$module->export_sql_start[$r]; $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_end[$i]=$module->export_sql_end[$r];
//$this->array_export_sql[$i]=$module->export_sql[$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++; $i++;
} }
} }
@ -185,7 +188,7 @@ class Export
$newfield=$key.' as '.$value; $newfield=$key.' as '.$value;
// Cas particulier // Cas particulier
if ($this->array_export_module[$indice]->id == 'banque') /* if ($this->array_export_module[$indice]->name == 'Banque')
{ {
// Cas special du debit et credit // Cas special du debit et credit
if ($value=='credit' || $value=='debit') if ($value=='credit' || $value=='debit')
@ -193,7 +196,7 @@ class Export
$newfield='IF('.$key.'>0,'.$key.',NULL) as '.$value; $newfield='IF('.$key.'>0,'.$key.',NULL) as '.$value;
} }
} }
*/
$sql.=$newfield; $sql.=$newfield;
} }
$sql.=$this->array_export_sql_end[$indice]; $sql.=$this->array_export_sql_end[$indice];
@ -221,7 +224,30 @@ class Export
while ($objp = $this->db->fetch_object($resql)) while ($objp = $this->db->fetch_object($resql))
{ {
$var=!$var; $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 // Genere en-tete

View File

@ -127,7 +127,7 @@ if ($step == 1 || $action == 'cleanselect')
if ($action == 'builddoc') if ($action == 'builddoc')
{ {
// Gen<EFBFBD>re le fichier // Build export file
$result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected); $result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected);
if ($result < 0) if ($result < 0)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2008 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
@ -15,9 +15,6 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
@ -25,7 +22,7 @@
\ingroup export \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énérer les export au format CSV
\author Laurent Destailleur \author Laurent Destailleur
\version $Revision$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/export/modules_export.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/export/modules_export.php");

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2008 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
@ -15,9 +15,6 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
@ -25,7 +22,7 @@
\ingroup export \ingroup export
\brief Fichier de la classe permettant de générer les export au format Excel \brief Fichier de la classe permettant de générer les export au format Excel
\author Laurent Destailleur \author Laurent Destailleur
\version $Revision$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php");

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* *
@ -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_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_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_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_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] =' 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'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_url as but ON but.fk_bank = b.rowid';