modHRM.class.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  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. */
  17. /**
  18. * \file htdocs/core/modules/modHRM.class.php
  19. * \ingroup HRM
  20. * \brief Description and activation file for module HRM
  21. */
  22. include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
  23. /**
  24. * Class to describe and activate the HRM module
  25. */
  26. class modHRM extends DolibarrModules
  27. {
  28. /**
  29. * Constructor.
  30. * Define names, constants, directories, boxes, permissions
  31. *
  32. * @param DoliDB $db Database handler
  33. */
  34. public function __construct($db)
  35. {
  36. global $langs, $conf;
  37. $this->db = $db;
  38. $this->numero = 4000;
  39. $this->rights_class = 'hrm';
  40. $this->family = "hr";
  41. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  42. $this->name = preg_replace( '/^mod/i', '', get_class($this));
  43. $this->description = "Management of employees carrier and feelings (department, employment contract)";
  44. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  45. $this->version = 'development';
  46. $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
  47. // Name of image file used for this module.
  48. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
  49. // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
  50. $this->picto='generic';
  51. // define triggers
  52. $this->module_parts = array();
  53. // Data directories to create when module is enabled
  54. $this->dirs = array();
  55. // Config pages
  56. $this->config_page_url = array('admin_hrm.php@hrm');
  57. // Dependencies
  58. $this->hidden = false; // A condition to hide module
  59. $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
  60. $this->requiredby = array(/*"modSalaries, modExpenseReport, modHoliday"*/); // List of module ids to disable if this one is disabled
  61. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  62. $this->phpmin = array(5,4); // Minimum version of PHP required by module
  63. $this->need_dolibarr_version = array (3,9); // Minimum version of Dolibarr required by module
  64. $this->langfiles = array ("hrm");
  65. // Dictionaries
  66. $this->dictionaries=array();
  67. // Constantes
  68. $this->const = array ();
  69. $r = 0;
  70. // Boxes
  71. $this->boxes = array ();
  72. // Permissions
  73. $this->rights = array(); // Permission array used by this module
  74. $r = 0;
  75. $this->rights[$r][0] = 4001;
  76. $this->rights[$r][1] = 'See employees';
  77. $this->rights[$r][3] = 0;
  78. $this->rights[$r][4] = 'employee';
  79. $this->rights[$r][5] = 'read';
  80. $r ++;
  81. $this->rights[$r][0] = 4002;
  82. $this->rights[$r][1] = 'Create employees';
  83. $this->rights[$r][3] = 0;
  84. $this->rights[$r][4] = 'employee';
  85. $this->rights[$r][5] = 'write';
  86. $r ++;
  87. $this->rights[$r][0] = 4003;
  88. $this->rights[$r][1] = 'Delete employees';
  89. $this->rights[$r][3] = 0;
  90. $this->rights[$r][4] = 'employee';
  91. $this->rights[$r][5] = 'delete';
  92. $r ++;
  93. $this->rights[$r][0] = 4004;
  94. $this->rights[$r][1] = 'Export employees';
  95. $this->rights[$r][3] = 0;
  96. $this->rights[$r][4] = 'employee';
  97. $this->rights[$r][5] = 'export';
  98. $r ++;
  99. // Menus
  100. //-------
  101. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
  102. }
  103. /**
  104. * Function called when module is enabled.
  105. * The init function add constants, boxes, permissions and menus
  106. * (defined in constructor) into Dolibarr database.
  107. * It also creates data directories
  108. *
  109. * @param string $options Enabling module ('', 'noboxes')
  110. * @return int if OK, 0 if KO
  111. */
  112. function init($options='')
  113. {
  114. // Permissions
  115. $this->remove($options);
  116. $sql = array();
  117. return $this->_init($sql,$options);
  118. }
  119. }