diff --git a/htdocs/exports/export.class.php b/htdocs/exports/export.class.php index c744da1d99c..1e159492e37 100644 --- a/htdocs/exports/export.class.php +++ b/htdocs/exports/export.class.php @@ -174,6 +174,8 @@ class Export // Execute requete export $sql=$this->array_export_sql[$indice]; + + dolibarr_syslog("Export::build_file sql=".$sql); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index e1539cd0b26..cb06ff6112c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -43,6 +43,7 @@ $entitytoicon=array( 'order'=>'order' ,'order_line'=>'order', 'member'=>'user' ,'member_type'=>'group','subscription'=>'payment', 'tax'=>'generic' ,'tax_type'=>'generic', + 'account'=>'account', 'payment'=>'payment'); $entitytolang=array( 'user'=>'User', @@ -51,6 +52,7 @@ $entitytolang=array( 'order'=>'Order','order_line'=>'OrderLine', 'member'=>'Member','member_type'=>'MemberType','subscription'=>'Subscription', 'tax'=>'SocialContribution','tax_type'=>'DictionnarySocialContributions', + 'account'=>'BankTransactions', 'payment'=>'Payment'); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); diff --git a/htdocs/includes/modules/export/export_csv.modules.php b/htdocs/includes/modules/export/export_csv.modules.php index 779c0303dd7..c7513fca06a 100644 --- a/htdocs/includes/modules/export/export_csv.modules.php +++ b/htdocs/includes/modules/export/export_csv.modules.php @@ -127,15 +127,26 @@ class ExportCsv extends ModeleExports function write_record($array_alias,$array_selected_sorted,$objp) { - foreach($array_selected_sorted as $code => $value) + global $langs; + + $this->col=0; + foreach($array_selected_sorted as $code => $value) { $alias=$array_alias[$code]; - //print "dd".$alias; - $newvalue=ereg_replace(';',',',clean_html($objp->$alias)); + $newvalue=$objp->$alias; + // Nettoyage newvalue + $newvalue=ereg_replace(';',',',clean_html($newvalue)); $newvalue=ereg_replace("\r",'',$newvalue); $newvalue=ereg_replace("\n",'\n',$newvalue); - fwrite($this->handle,$newvalue.";"); - } + // Traduction newvalue + if (eregi('^\((.*)\)$',$newvalue,$reg)) + { + $newvalue=$langs->transnoentities($reg[1]); + } + + fwrite($this->handle,$newvalue.";"); + $this->col++; + } fwrite($this->handle,"\n"); return 0; } diff --git a/htdocs/includes/modules/export/export_excel.modules.php b/htdocs/includes/modules/export/export_excel.modules.php index 78ff0c8396e..61a06cabcfc 100644 --- a/htdocs/includes/modules/export/export_excel.modules.php +++ b/htdocs/includes/modules/export/export_excel.modules.php @@ -143,12 +143,22 @@ class ExportExcel extends ModeleExports function write_record($array_alias,$array_selected_sorted,$objp) { + global $langs; + $this->col=0; foreach($array_selected_sorted as $code => $value) { $alias=$array_alias[$code]; - //print "dd".$alias; - $this->worksheet->write($this->row, $this->col, clean_html($objp->$alias)); + $newvalue=$objp->$alias; + // Nettoyage newvalue + $newvalue=clean_html($newvalue); + // Traduction newvalue + if (eregi('^\((.*)\)$',$newvalue,$reg)) + { + $newvalue=$langs->transnoentities($reg[1]); + } + + $this->worksheet->write($this->row, $this->col, $newvalue); $this->col++; } $this->row++; diff --git a/htdocs/includes/modules/modBanque.class.php b/htdocs/includes/modules/modBanque.class.php index 7ae6470d955..c83797ba067 100644 --- a/htdocs/includes/modules/modBanque.class.php +++ b/htdocs/includes/modules/modBanque.class.php @@ -111,6 +111,46 @@ class modBanque extends DolibarrModules $this->rights[$r][2] = 'w'; // type de la permission (déprécié à ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par défaut $this->rights[$r][4] = 'consolidate'; + + $r++; + $this->rights[$r][0] = 115; // id de la permission + $this->rights[$r][1] = 'Exporter transactions et relevés'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (déprécié à ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par défaut + $this->rights[$r][4] = 'export'; + + + // Exports + //-------- + $r=0; + + $r++; + $this->export_code[$r]=$this->id.'_'.$r; + $this->export_label[$r]='Ecritures bancaires et relevés'; + $this->export_fields_array[$r]=array('b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label','-b.amount'=>'Debit','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation"); + $this->export_entities_array[$r]=array('b.datev'=>'account','b.dateo'=>'account','b.label'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account"); + $this->export_alias_array[$r]=array('b.datev'=>'datev','b.dateo'=>'dateo','b.label'=>'label','-b.amount'=>'debit','b.amount'=>'credit','b.num_releve'=>'numrel','b.datec'=>"datec"); + $this->export_sql[$r]="select distinct "; + $i=0; + foreach ($this->export_alias_array[$r] as $key => $value) + { + if ($i > 0) $this->export_sql[$r].=', '; + else $i++; + // Cas special du debit et credit + if ($value=='credit' || $value=='debit') + { + $this->export_sql[$r].='IF('.$key.'>0,'.$key.',NULL) as '.$value; + } + else + { + $this->export_sql[$r].=$key.' as '.$value; + } + } + $this->export_sql[$r].=' from '.MAIN_DB_PREFIX.'bank as b'; + //$this->export_sql[$r].=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_url as but ON but.fk_bank = b.rowid'; + $this->export_sql[$r].=' ORDER BY b.datev'; + $this->export_permission[$r]=array(array("banque","export")); + } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index a3ba6642975..4fcab136537 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -64,6 +64,7 @@ DeleteAccount=Delete account ConfirmDeleteAccount=Are you sure you want to delete this account ? Account=Account ByCategories=By categories +BankTransactions=Bank transactions SearchTransaction=Search transaction TransactionsToConciliate=Transactions to conciliate Conciliable=Conciliable diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 1b7da7c1114..340303be598 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -64,6 +64,7 @@ DeleteAccount=Suppression de compte ConfirmDeleteAccount=Etes-vous sur de vouloir supprimer ce compte ? Account=Compte ByCategories=Par catégories +BankTransactions=Transactions bancaires SearchTransaction=Recherche écriture TransactionsToConciliate=Ecritures à rapprocher Conciliable=Rapprochable