dolibarr  9.0.0
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@inodbox.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 = '51';
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->picto='account';
62 
63  // Data directories to create when module is enabled
64  $this->dirs = array("/banque/temp");
65 
66  // Config pages
67  //-------------
68  $this->config_page_url = array("bank.php");
69 
70  // Dependancies
71  $this->depends = array();
72  $this->requiredby = array("modComptabilite","modAccounting","modPrelevement");
73  $this->conflictwith = array();
74  $this->langfiles = array("banks","compta","bills","companies");
75 
76  // Constants
77  $this->const = array();
78 
79  // Boxes
80  $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home'));
81 
82  // Permissions
83  $this->rights = array();
84  $this->rights_class = 'banque';
85  $r=0;
86 
87  $r++;
88  $this->rights[$r][0] = 111; // id de la permission
89  $this->rights[$r][1] = 'Read bank account and transactions';
90  $this->rights[$r][2] = 'r';
91  $this->rights[$r][3] = 0;
92  $this->rights[$r][4] = 'lire';
93 
94  $r++;
95  $this->rights[$r][0] = 112; // id de la permission
96  $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire';
97  $this->rights[$r][2] = 'w';
98  $this->rights[$r][3] = 0;
99  $this->rights[$r][4] = 'modifier';
100 
101  $r++;
102  $this->rights[$r][0] = 113; // id de la permission
103  $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)';
104  $this->rights[$r][2] = 'a';
105  $this->rights[$r][3] = 0;
106  $this->rights[$r][4] = 'configurer';
107 
108  $r++;
109  $this->rights[$r][0] = 114; // id de la permission
110  $this->rights[$r][1] = 'Rapprocher les ecritures bancaires';
111  $this->rights[$r][2] = 'w';
112  $this->rights[$r][3] = 0;
113  $this->rights[$r][4] = 'consolidate';
114 
115  $r++;
116  $this->rights[$r][0] = 115; // id de la permission
117  $this->rights[$r][1] = 'Exporter transactions et releves';
118  $this->rights[$r][2] = 'r';
119  $this->rights[$r][3] = 0;
120  $this->rights[$r][4] = 'export';
121 
122  $r++;
123  $this->rights[$r][0] = 116; // id de la permission
124  $this->rights[$r][1] = 'Virements entre comptes';
125  $this->rights[$r][2] = 'w';
126  $this->rights[$r][3] = 0;
127  $this->rights[$r][4] = 'transfer';
128 
129  $r++;
130  $this->rights[$r][0] = 117; // id de la permission
131  $this->rights[$r][1] = 'Gerer les envois de cheques';
132  $this->rights[$r][2] = 'w';
133  $this->rights[$r][3] = 0;
134  $this->rights[$r][4] = 'cheque';
135 
136 
137  // Menus
138  //-------
139  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
140 
141 
142  // Exports
143  //--------
144  $r=0;
145 
146  $r++;
147  $this->export_code[$r]=$this->rights_class.'_'.$r;
148  $this->export_label[$r]='Ecritures bancaires et releves';
149  $this->export_permission[$r]=array(array("banque","export"));
150  $this->export_fields_array[$r]=array(
151  'b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label',
152  'b.num_chq'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit',
153  'b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty",
154  "s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode"
155  );
156  $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");
157  $this->export_entities_array[$r]=array(
158  'b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account',
159  'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account',
160  'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company"
161  );
162  $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG');
163  if (empty($conf->fournisseur->enabled))
164  {
165  unset($this->export_fields_array[$r]['s.code_compta_fournisseur']);
166  unset($this->export_entities_array[$r]['s.code_compta_fournisseur']);
167  }
168  $this->export_sql_start[$r]='SELECT DISTINCT ';
169  $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
170  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
171  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid';
172  $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account';
173  $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')';
174  $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
175 
176  $r++;
177  $this->export_code[$r]=$this->rights_class.'_'.$r;
178  $this->export_label[$r]='Bordereaux remise Chq/Fact';
179  $this->export_permission[$r]=array(array("banque","export"));
180  $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",
181  "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","f.facnumber"=>"InvoiceRef"
182  );
183  $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",
184  "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","s.code_compta"=>"Text","f.facnumber"=>"Text"
185  );
186  $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",
187  "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.facnumber"=>"invoice");
188  $this->export_special_array[$r]=array('b.amount'=>'NULLIFNEG');
189 
190  $this->export_sql_start[$r]='SELECT DISTINCT ';
191  $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)';
192  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
193  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank';
194  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement';
195  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture';
196  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid';
197  $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid';
198  $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'";
199  $this->export_sql_end[$r] .=' AND p.fk_paiement = 7';
200  $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')';
201  $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
202  }
203 
204 
213  function init($options='')
214  {
215  global $conf;
216 
217  // Permissions
218  $this->remove($options);
219 
220  $sql = array();
221 
222  return $this->_init($sql,$options);
223  }
224 }
Class DolibarrModules.
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="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< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
Class to describe and enable module Banque.
__construct($db)
Constructor.
_init($array_sql, $options='')
Enables a module.
init($options='')
Function called when module is enabled.