dolibarr  7.0.0-beta
modBanque.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6  * Copyright (C) 2008-2011 Regis Houssin <regis.houssin@capnetworks.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
30 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
31 
32 
37 {
38 
44  function __construct($db)
45  {
46  global $conf;
47 
48  $this->db = $db;
49  $this->numero = 85;
50 
51  $this->family = "financial";
52  $this->module_position = 510;
53  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54  $this->name = preg_replace('/^mod/i','',get_class($this));
55  $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux";
56 
57  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
58  $this->version = 'dolibarr';
59 
60  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
61  $this->special = 0;
62  $this->picto='account';
63 
64  // Data directories to create when module is enabled
65  $this->dirs = array("/banque/temp");
66 
67  // Config pages
68  //-------------
69  $this->config_page_url = array("bank.php");
70 
71  // Dependancies
72  $this->depends = array();
73  $this->requiredby = array("modComptabilite","modAccounting","modPrelevement");
74  $this->conflictwith = array();
75  $this->langfiles = array("banks","compta","bills","companies");
76 
77  // Constants
78  $this->const = array();
79 
80  // Boxes
81  $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home'));
82 
83  // Permissions
84  $this->rights = array();
85  $this->rights_class = 'banque';
86  $r=0;
87 
88  $r++;
89  $this->rights[$r][0] = 111; // id de la permission
90  $this->rights[$r][1] = 'Lire les comptes bancaires'; // libelle de la permission
91  $this->rights[$r][2] = 'r';
92  $this->rights[$r][3] = 0;
93  $this->rights[$r][4] = 'lire';
94 
95  $r++;
96  $this->rights[$r][0] = 112; // id de la permission
97  $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire'; // libelle de la permission
98  $this->rights[$r][2] = 'w';
99  $this->rights[$r][3] = 0;
100  $this->rights[$r][4] = 'modifier';
101 
102  $r++;
103  $this->rights[$r][0] = 113; // id de la permission
104  $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)'; // libelle de la permission
105  $this->rights[$r][2] = 'a';
106  $this->rights[$r][3] = 0;
107  $this->rights[$r][4] = 'configurer';
108 
109  $r++;
110  $this->rights[$r][0] = 114; // id de la permission
111  $this->rights[$r][1] = 'Rapprocher les ecritures bancaires'; // libelle de la permission
112  $this->rights[$r][2] = 'w';
113  $this->rights[$r][3] = 0;
114  $this->rights[$r][4] = 'consolidate';
115 
116  $r++;
117  $this->rights[$r][0] = 115; // id de la permission
118  $this->rights[$r][1] = 'Exporter transactions et releves'; // libelle de la permission
119  $this->rights[$r][2] = 'r';
120  $this->rights[$r][3] = 0;
121  $this->rights[$r][4] = 'export';
122 
123  $r++;
124  $this->rights[$r][0] = 116; // id de la permission
125  $this->rights[$r][1] = 'Virements entre comptes'; // libelle de la permission
126  $this->rights[$r][2] = 'w';
127  $this->rights[$r][3] = 0;
128  $this->rights[$r][4] = 'transfer';
129 
130  $r++;
131  $this->rights[$r][0] = 117; // id de la permission
132  $this->rights[$r][1] = 'Gerer les envois de cheques'; // libelle de la permission
133  $this->rights[$r][2] = 'w';
134  $this->rights[$r][3] = 0;
135  $this->rights[$r][4] = 'cheque';
136 
137 
138  // Menus
139  //-------
140  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
141 
142 
143  // Exports
144  //--------
145  $r=0;
146 
147  $r++;
148  $this->export_code[$r]=$this->rights_class.'_'.$r;
149  $this->export_label[$r]='Ecritures bancaires et releves';
150  $this->export_permission[$r]=array(array("banque","export"));
151  $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'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode");
152  $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text");
153  $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.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company");
154  $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG');
155  if (empty($conf->fournisseur->enabled))
156  {
157  unset($this->export_fields_array[$r]['s.code_compta_fournisseur']);
158  unset($this->export_entities_array[$r]['s.code_compta_fournisseur']);
159  }
160  $this->export_sql_start[$r]='SELECT DISTINCT ';
161  $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
162  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
163  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid';
164  $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account';
165  $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')';
166  $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
167 
168  $r++;
169  $this->export_code[$r]=$this->rights_class.'_'.$r;
170  $this->export_label[$r]='Bordereaux remise Chq/Fact';
171  $this->export_permission[$r]=array(array("banque","export"));
172  $this->export_fields_array[$r]=array("bch.rowid"=>"DepositId","bch.ref"=>"Numero","bch.ref_ext"=>"RefExt",'ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.num_chq'=>'ChequeOrTransferNumber','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation",
173  "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","f.facnumber"=>"InvoiceRef"
174  );
175  $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.num_chq'=>'Text','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date",
176  "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","f.facnumber"=>"Text"
177  );
178  $this->export_entities_array[$r]=array('ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.num_chq'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account",
179  "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.facnumber"=>"invoice");
180  $this->export_special_array[$r]=array('b.amount'=>'NULLIFNEG');
181 
182  $this->export_sql_start[$r]='SELECT DISTINCT ';
183  $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
184  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
185  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank';
186  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement';
187  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture';
188  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid';
189  $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid';
190  $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'";
191  $this->export_sql_end[$r] .=' AND p.fk_paiement = 7';
192  $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')';
193  $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
194 
195  }
196 
197 
206  function init($options='')
207  {
208  global $conf;
209 
210  // Permissions
211  $this->remove($options);
212 
213  $sql = array();
214 
215  return $this->_init($sql,$options);
216  }
217 }
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
Class to describe and enable module Banque.
__construct($db)
Constructor.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
_init($array_sql, $options='')
Enables a module.
init($options='')
Function called when module is enabled.