modMargin.class.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
  3. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /** \defgroup margin Module margin
  19. * \brief Module to manage margins
  20. * \file htdocs/core/modules/modMargin.class.php
  21. * \ingroup margin
  22. * \brief Description and activation file for the module Margin
  23. */
  24. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  25. /**
  26. * Class to describe module Margin
  27. */
  28. class modMargin extends DolibarrModules
  29. {
  30. /**
  31. * Constructor
  32. *
  33. * @param DoliDB $db Database handler
  34. */
  35. public function __construct($db)
  36. {
  37. $this->db = $db;
  38. // Id for module (must be unique).
  39. // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
  40. $this->numero = 59000;
  41. // Key text used to identify module (for permissions, menus, etc...)
  42. $this->rights_class = 'margins';
  43. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  44. // It is used to group modules in module setup page
  45. $this->family = "financial";
  46. $this->module_position = '55';
  47. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  48. $this->name = preg_replace('/^mod/i', '', get_class($this));
  49. // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  50. $this->description = "Margin management";
  51. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  52. $this->version = 'dolibarr';
  53. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  54. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  55. // Name of png file (without png) used for this module.
  56. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
  57. $this->picto = 'margin';
  58. // Data directories to create when module is enabled.
  59. $this->dirs = array('/margin/temp');
  60. // Config pages. Put here list of php page names stored in admmin directory used to setup module.
  61. $this->config_page_url = array("margin.php@margin");
  62. // Dependencies
  63. $this->hidden = false; // A condition to hide module
  64. $this->depends = array("modPropale", "modProduct"); // List of module class names as string that must be enabled if this module is enabled
  65. $this->requiredby = array(); // List of module ids to disable if this one is disabled
  66. $this->conflictwith = array(); // List of module class names as string this module is in conflict with
  67. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  68. $this->need_dolibarr_version = array(3, 2); // Minimum version of Dolibarr required by module
  69. $this->langfiles = array("margins");
  70. // Constants
  71. // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
  72. // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
  73. // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
  74. // );
  75. $this->const = array(0=>array('MARGIN_TYPE', 'chaine', 'costprice', 'Rule for margin calculation by default', 0, 'current', 0)); // List of particular constants to add when module is enabled
  76. // New pages on tabs
  77. $this->tabs = array(
  78. 'product:+margin:Margins:margins:$user->rights->margins->liretous:/margin/tabs/productMargins.php?id=__ID__',
  79. 'thirdparty:+margin:Margins:margins:empty($user->socid) && $user->rights->margins->liretous && ($object->client > 0):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
  80. );
  81. // Boxes
  82. $this->boxes = array(); // List of boxes
  83. $r = 0;
  84. // Permissions
  85. $this->rights = array(); // Permission array used by this module
  86. $r = 0;
  87. // Main menu entries
  88. $this->menu = array(); // List of menus to add
  89. $r = 0;
  90. // left menu entry
  91. $this->menu[$r] = array(
  92. 'fk_menu'=>'fk_mainmenu=billing', // Put 0 if this is a top menu
  93. 'type'=>'left', // This is a Top menu entry
  94. 'titre'=>'Margins',
  95. 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
  96. 'mainmenu'=>'billing',
  97. 'leftmenu'=>'margins',
  98. 'url'=>'/margin/index.php',
  99. 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  100. 'position'=>100,
  101. 'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
  102. 'perms'=>'$user->rights->margins->liretous', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
  103. 'target'=>'',
  104. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  105. );
  106. $r++;
  107. // Permissions
  108. $this->rights = array();
  109. $r = 0;
  110. $r++;
  111. $this->rights[$r][0] = 59001; // id de la permission
  112. $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
  113. $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
  114. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  115. $this->rights[$r][4] = 'liretous';
  116. $r++;
  117. $this->rights[$r][0] = 59002; // id de la permission
  118. $this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
  119. $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
  120. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  121. $this->rights[$r][4] = 'creer';
  122. $r++;
  123. $this->rights[$r][0] = 59003; // id de la permission
  124. $this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
  125. $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
  126. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  127. $this->rights[$r][4] = 'read';
  128. $this->rights[$r][5] = 'all';
  129. }
  130. }