modLoan.class.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \defgroup tax Module Loans
  20. * \brief Module to include loans management
  21. * \file htdocs/core/modules/modLoan.class.php
  22. * \ingroup loan
  23. * \brief Description and activation file for the module loan
  24. */
  25. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Class to manage loan module
  28. */
  29. class modLoan extends DolibarrModules
  30. {
  31. /**
  32. * Constructor. Define names, constants, directories, boxes, permissions
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. public function __construct($db)
  37. {
  38. global $conf;
  39. $this->db = $db;
  40. $this->numero = 520;
  41. $this->family = "financial";
  42. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  43. $this->name = preg_replace('/^mod/i', '', get_class($this));
  44. // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  45. $this->description = "Loans management";
  46. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  47. $this->version = 'dolibarr';
  48. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  49. $this->picto = 'money-bill-alt';
  50. // Data directories to create when module is enabled
  51. $this->dirs = array("/loan/temp");
  52. // Config pages
  53. $this->config_page_url = array('loan.php');
  54. // Dependencies
  55. $this->hidden = false; // A condition to hide module
  56. $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
  57. $this->requiredby = array(); // List of module ids to disable if this one is disabled
  58. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  59. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  60. $this->langfiles = array("loan");
  61. // Constants
  62. $this->const = array();
  63. $this->const[0] = array(
  64. "LOAN_ACCOUNTING_ACCOUNT_CAPITAL",
  65. "chaine",
  66. "164"
  67. );
  68. $this->const[1] = array(
  69. "LOAN_ACCOUNTING_ACCOUNT_INTEREST",
  70. "chaine",
  71. "6611"
  72. );
  73. $this->const[1] = array(
  74. "LOAN_ACCOUNTING_ACCOUNT_INSURANCE",
  75. "chaine",
  76. "6162"
  77. );
  78. // Boxes
  79. $this->boxes = array();
  80. // Permissions
  81. $this->rights = array();
  82. $this->rights_class = 'loan';
  83. $r = 0;
  84. $r++;
  85. $this->rights[$r][0] = 521;
  86. $this->rights[$r][1] = 'Read loans';
  87. $this->rights[$r][2] = 'r';
  88. $this->rights[$r][3] = 0;
  89. $this->rights[$r][4] = 'read';
  90. $this->rights[$r][5] = '';
  91. $r++;
  92. $this->rights[$r][0] = 522;
  93. $this->rights[$r][1] = 'Create/modify loans';
  94. $this->rights[$r][2] = 'w';
  95. $this->rights[$r][3] = 0;
  96. $this->rights[$r][4] = 'write';
  97. $this->rights[$r][5] = '';
  98. $r++;
  99. $this->rights[$r][0] = 524;
  100. $this->rights[$r][1] = 'Delete loans';
  101. $this->rights[$r][2] = 'd';
  102. $this->rights[$r][3] = 0;
  103. $this->rights[$r][4] = 'delete';
  104. $this->rights[$r][5] = '';
  105. $r++;
  106. $this->rights[$r][0] = 525;
  107. $this->rights[$r][1] = 'Access loan calculator';
  108. $this->rights[$r][2] = 'r';
  109. $this->rights[$r][3] = 0;
  110. $this->rights[$r][4] = 'calc';
  111. $this->rights[$r][5] = '';
  112. $r++;
  113. $this->rights[$r][0] = 527;
  114. $this->rights[$r][1] = 'Export loans';
  115. $this->rights[$r][2] = 'r';
  116. $this->rights[$r][3] = 0;
  117. $this->rights[$r][4] = 'export';
  118. $this->rights[$r][5] = '';
  119. // Menus
  120. //-------
  121. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
  122. // Exports
  123. //--------
  124. $r = 0;
  125. }
  126. /**
  127. * Function called when module is enabled.
  128. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  129. * It also creates data directories
  130. *
  131. * @param string $options Options when enabling module ('', 'noboxes')
  132. * @return int 1 if OK, 0 if KO
  133. */
  134. public function init($options = '')
  135. {
  136. global $conf;
  137. // Clean before activation
  138. $this->remove($options);
  139. $sql = array();
  140. return $this->_init($sql, $options);
  141. }
  142. }