PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/core/modules/modCommissions.class.php

https://bitbucket.org/speedealing/speedealing
PHP | 167 lines | 61 code | 24 blank | 82 comment | 0 complexity | f8d4e26f6b4768d7f4b49fb7d1c57aa1 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.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 <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \defgroup commissions Module commissions
  20. * \brief Module commissions
  21. * \file htdocs/core/modules/modCommissions.class.php
  22. * \ingroup commissions
  23. * \brief Description and activation file for module Commissions
  24. */
  25. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Class to describe modude Commisions
  28. */
  29. class modCommissions extends DolibarrModules
  30. {
  31. /**
  32. * Constructor
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. function __construct($db = '')
  37. {
  38. $this->db = $db;
  39. parent::__construct($db);
  40. // Id for module (must be unique).
  41. // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
  42. $this->numero = 60000;
  43. // Key text used to identify module (for permissions, menus, etc...)
  44. $this->rights_class = 'Commissions';
  45. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  46. // It is used to group modules in module setup page
  47. $this->family = "financial";
  48. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  49. $this->name = preg_replace('/^mod/i','',get_class($this));
  50. // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  51. $this->description = "Commissions management";
  52. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  53. $this->version = 'experimental';
  54. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  55. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  56. // Where to store the module in setup page (0=common,1=interface,2=other)
  57. $this->special = 2;
  58. // Name of png file (without png) used for this module.
  59. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
  60. $this->picto='commissions';
  61. // Data directories to create when module is enabled.
  62. $this->dirs = array();
  63. // Config pages. Put here list of php page names stored in admmin directory used to setup module.
  64. $this->config_page_url = array("commissions.php@commissions");
  65. // Dependencies
  66. $this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled
  67. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  68. $this->phpmin = array(5,1); // Minimum version of PHP required by module
  69. $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module
  70. $this->langfiles = array("commissions");
  71. // Constants
  72. $this->const = array(0=>array('COMMISSION_BASE',"chaine","TURNOVER",'Default commission base',0)); // List of particular constants to add when module is enabled
  73. // New pages on tabs
  74. $this->tabs = array();
  75. // Boxes
  76. $this->boxes = array(); // List of boxes
  77. $r=0;
  78. // Permissions
  79. $this->rights = array(); // Permission array used by this module
  80. $r=0;
  81. // Add here list of permission defined by an id, a label, a boolean and two constant strings.
  82. // Example:
  83. // $this->rights[$r][0] = 2000; // Permission id (must not be already used)
  84. // $this->rights[$r][1] = 'Permision label'; // Permission label
  85. // $this->rights[$r][3] = 1; // Permission by default for new user (0/1)
  86. // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
  87. // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
  88. // $r++;
  89. // Main menu entries
  90. $this->menu = array(); // List of menus to add
  91. $r = 0;
  92. // left menu entry
  93. $r = 0;
  94. $this->menus[$r] = new stdClass();
  95. $this->menus[$r]->_id = "menu:commission";
  96. $this->menus[$r]->type = "left";
  97. $this->menus[$r]->position = 200;
  98. $this->menus[$r]->url = "/commissions/index.php";
  99. $this->menus[$r]->enabled = '$conf->commissions->enabled';
  100. $this->menus[$r]->usertype = 2;
  101. $this->menus[$r]->title = "Commissions";
  102. $this->menus[$r]->fk_menu = "menu:accountancy";
  103. $r++;
  104. }
  105. /**
  106. * Function called when module is enabled.
  107. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  108. * It also creates data directories.
  109. *
  110. * @return int 1 if OK, 0 if KO
  111. */
  112. function init()
  113. {
  114. $sql = array();
  115. $result=$this->load_tables();
  116. return $this->_init($sql);
  117. }
  118. /**
  119. * Function called when module is disabled.
  120. * Remove from database constants, boxes and permissions from Dolibarr database.
  121. * Data directories are not deleted.
  122. *
  123. * @return int 1 if OK, 0 if KO
  124. */
  125. function remove()
  126. {
  127. $sql = array();
  128. return $this->_remove($sql);
  129. }
  130. /**
  131. * Create tables and keys required by module
  132. * Files mymodule.sql and mymodule.key.sql with create table and create keys
  133. * commands must be stored in directory /mymodule/sql/
  134. * This function is called by this->init.
  135. *
  136. * @return int <=0 if KO, >0 if OK
  137. */
  138. function load_tables()
  139. {
  140. return;
  141. }
  142. }
  143. ?>