modCashDesk.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  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. */
  17. /**
  18. * \defgroup pos Module points of sale
  19. * \brief Module to manage points of sale
  20. * \file htdocs/core/modules/modCashDesk.class.php
  21. * \ingroup pos
  22. * \brief Description and activation file for the module Point Of Sales
  23. */
  24. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  25. /**
  26. * Class to describe and enable module Point Of Sales
  27. */
  28. class modCashDesk extends DolibarrModules
  29. {
  30. /**
  31. * Constructor. Define names, constants, directories, boxes, permissions
  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 module id).
  40. $this->numero = 50100;
  41. // Key text used to identify module (for permission, menus, etc...)
  42. $this->rights_class = 'cashdesk';
  43. $this->family = "portal";
  44. $this->module_position = '59';
  45. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  46. $this->name = preg_replace('/^mod/i', '', get_class($this));
  47. $this->description = "CashDesk module";
  48. $this->version = 'deprecated';
  49. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  50. $this->picto = 'cash-register';
  51. // Data directories to create when module is enabled
  52. $this->dirs = array();
  53. // Config pages. Put here list of php page names stored in admmin directory used to setup module.
  54. $this->config_page_url = array("cashdesk.php@cashdesk");
  55. // Dependencies
  56. $this->hidden = false; // A condition to hide module
  57. $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled
  58. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  59. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  60. $this->need_dolibarr_version = array(2, 4); // Minimum version of Dolibarr required by module
  61. $this->langfiles = array("cashdesk");
  62. $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
  63. //$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
  64. // Constants
  65. $this->const = array();
  66. // Boxes
  67. $this->boxes = array();
  68. // Permissions
  69. $this->rights = array();
  70. $r = 0;
  71. $r++;
  72. $this->rights[$r][0] = 50101;
  73. $this->rights[$r][1] = 'Use Point of sale';
  74. $this->rights[$r][2] = 'a';
  75. $this->rights[$r][3] = 0;
  76. $this->rights[$r][4] = 'run';
  77. // Main menu entries
  78. $this->menus = array(); // List of menus to add
  79. $r = 0;
  80. // This is to declare the Top Menu entry:
  81. $this->menu[$r] = array('fk_menu'=>0, // Put 0 if this is a top menu
  82. 'type'=>'top', // This is a Top menu entry
  83. 'titre'=>'PointOfSaleShort',
  84. 'mainmenu'=>'cashdesk',
  85. 'leftmenu'=>'',
  86. 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
  87. 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__',
  88. 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  89. 'position'=>900,
  90. 'enabled'=>'$conf->cashdesk->enabled',
  91. 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules
  92. 'target'=>'pointofsale',
  93. 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
  94. $r++;
  95. // This is to declare a Left Menu entry:
  96. // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the top menu entry
  97. // 'type'=>'left', // This is a Left menu entry
  98. // 'titre'=>'Title left menu',
  99. // 'mainmenu'=>'mymodule',
  100. // 'url'=>'/comm/action/index2.php',
  101. // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  102. // 'position'=>100,
  103. // 'perms'=>'$user->rights->mymodule->level1->level2', // Use 'perms'=>'1' if you want your menu with no permission rules
  104. // 'target'=>'',
  105. // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
  106. // $r++;
  107. }
  108. /**
  109. * Function called when module is enabled.
  110. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  111. * It also creates data directories
  112. *
  113. * @param string $options Options when enabling module ('', 'noboxes')
  114. * @return int 1 if OK, 0 if KO
  115. */
  116. public function init($options = '')
  117. {
  118. $sql = array();
  119. // Remove permissions and default values
  120. $this->remove($options);
  121. return $this->_init($sql, $options);
  122. }
  123. }