PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/modules/modBanque.class.php

https://github.com/asterix14/dolibarr
PHP | 200 lines | 105 code | 34 blank | 61 comment | 1 complexity | 142a25a1c22d6a28191940b95f558a1d MD5 | raw file
Possible License(s): LGPL-2.0
  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@dolibarr.fr>
  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 2 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. /**
  22. * \defgroup banque Module bank
  23. * \brief Module pour gerer la tenue d'un compte bancaire et rapprochements
  24. * \file htdocs/core/modules/modBanque.class.php
  25. * \ingroup banque
  26. * \brief Fichier de description et activation du module Banque
  27. */
  28. include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
  29. /**
  30. * \class modBanque
  31. * \brief Classe de description et activation du module Banque
  32. */
  33. class modBanque extends DolibarrModules
  34. {
  35. /**
  36. * Constructor.
  37. *
  38. * @param DoliDB $DB Database handler
  39. */
  40. function modBanque($DB)
  41. {
  42. global $conf;
  43. $this->db = $DB ;
  44. $this->numero = 85 ;
  45. $this->family = "financial";
  46. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  47. $this->name = preg_replace('/^mod/i','',get_class($this));
  48. $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux";
  49. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  50. $this->version = 'dolibarr';
  51. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  52. $this->special = 0;
  53. $this->picto='account';
  54. // Data directories to create when module is enabled
  55. $this->dirs = array("/banque/temp");
  56. // Config pages
  57. //-------------
  58. $this->config_page_url = array("bank.php@compta/bank");
  59. // Dependancies
  60. $this->depends = array();
  61. $this->requiredby = array("modComptabilite","modAccounting");
  62. $this->conflictwith = array();
  63. $this->langfiles = array("banks","compta","bills","companies");
  64. // Constants
  65. $this->const = array();
  66. // Boites
  67. $this->boxes = array();
  68. $this->boxes[0][1] = "box_comptes.php";
  69. // Permissions
  70. $this->rights = array();
  71. $this->rights_class = 'banque';
  72. $r=0;
  73. $r++;
  74. $this->rights[$r][0] = 111; // id de la permission
  75. $this->rights[$r][1] = 'Lire les comptes bancaires'; // libelle de la permission
  76. $this->rights[$r][2] = 'r';
  77. $this->rights[$r][3] = 1;
  78. $this->rights[$r][4] = 'lire';
  79. $r++;
  80. $this->rights[$r][0] = 112; // id de la permission
  81. $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire'; // libelle de la permission
  82. $this->rights[$r][2] = 'w';
  83. $this->rights[$r][3] = 0;
  84. $this->rights[$r][4] = 'modifier';
  85. $r++;
  86. $this->rights[$r][0] = 113; // id de la permission
  87. $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)'; // libelle de la permission
  88. $this->rights[$r][2] = 'a';
  89. $this->rights[$r][3] = 0;
  90. $this->rights[$r][4] = 'configurer';
  91. $r++;
  92. $this->rights[$r][0] = 114; // id de la permission
  93. $this->rights[$r][1] = 'Rapprocher les ecritures bancaires'; // libelle de la permission
  94. $this->rights[$r][2] = 'w';
  95. $this->rights[$r][3] = 0;
  96. $this->rights[$r][4] = 'consolidate';
  97. $r++;
  98. $this->rights[$r][0] = 115; // id de la permission
  99. $this->rights[$r][1] = 'Exporter transactions et releves'; // libelle de la permission
  100. $this->rights[$r][2] = 'r';
  101. $this->rights[$r][3] = 0;
  102. $this->rights[$r][4] = 'export';
  103. $r++;
  104. $this->rights[$r][0] = 116; // id de la permission
  105. $this->rights[$r][1] = 'Virements entre comptes'; // libelle de la permission
  106. $this->rights[$r][2] = 'w';
  107. $this->rights[$r][3] = 0;
  108. $this->rights[$r][4] = 'transfer';
  109. $r++;
  110. $this->rights[$r][0] = 117; // id de la permission
  111. $this->rights[$r][1] = 'Gerer les envois de cheques'; // libelle de la permission
  112. $this->rights[$r][2] = 'w';
  113. $this->rights[$r][3] = 0;
  114. $this->rights[$r][4] = 'cheque';
  115. // Exports
  116. //--------
  117. $r=0;
  118. $r++;
  119. $this->export_code[$r]=$this->rights_class.'_'.$r;
  120. $this->export_label[$r]='Ecritures bancaires et releves';
  121. $this->export_permission[$r]=array(array("banque","export"));
  122. $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.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");
  123. $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","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company");
  124. $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG');
  125. if (empty($conf->fournisseur->enabled))
  126. {
  127. unset($this->export_fields_array[$r]['s.code_compta_fournisseur']);
  128. unset($this->export_entities_array[$r]['s.code_compta_fournisseur']);
  129. }
  130. $this->export_sql_start[$r]='SELECT DISTINCT ';
  131. $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
  132. $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
  133. $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid';
  134. $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account';
  135. $this->export_sql_end[$r] .=' AND ba.entity = '.$conf->entity;
  136. $this->export_sql_end[$r] .=' ORDER BY b.datev, b.num_releve';
  137. }
  138. /**
  139. * Function called when module is enabled.
  140. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  141. * It also creates data directories.
  142. *
  143. * @return int 1 if OK, 0 if KO
  144. */
  145. function init()
  146. {
  147. global $conf;
  148. // Permissions
  149. $this->remove();
  150. $sql = array();
  151. return $this->_init($sql);
  152. }
  153. /**
  154. * Function called when module is disabled.
  155. * Remove from database constants, boxes and permissions from Dolibarr database.
  156. * Data directories are not deleted.
  157. *
  158. * @return int 1 if OK, 0 if KO
  159. */
  160. function remove()
  161. {
  162. $sql = array();
  163. return $this->_remove($sql);
  164. }
  165. }
  166. ?>