modProductBatch.class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \defgroup productbatch Module batch number management
  22. * \brief Management module for batch number, eat-by and sell-by date for product
  23. * \file htdocs/core/modules/modProductBatch.class.php
  24. * \ingroup productbatch
  25. * \brief Description and activation file for module productbatch
  26. */
  27. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  28. /**
  29. * Description and activation class for module productdluo
  30. */
  31. class modProductBatch extends DolibarrModules
  32. {
  33. /**
  34. * Constructor. Define names, constants, directories, boxes, permissions
  35. *
  36. * @param DoliDB $db Database handler
  37. */
  38. function __construct($db)
  39. {
  40. global $langs,$conf;
  41. $this->db = $db;
  42. $this->numero = 39000;
  43. $this->family = "products";
  44. $this->name = preg_replace('/^mod/i','',get_class($this));
  45. $this->description = "Batch number, eat-by and sell-by date management module";
  46. $this->rights_class = 'productbatch';
  47. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  48. $this->version = 'dolibarr';
  49. // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase)
  50. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  51. $this->special = 0;
  52. $this->picto='stock';
  53. $this->module_parts = array();
  54. // Data directories to create when module is enabled.
  55. $this->dirs = array();
  56. // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module.
  57. $this->config_page_url = array();
  58. // Dependencies
  59. $this->depends = array("modProduct","modStock","modExpedition","modSupplier"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order).
  60. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  61. $this->phpmin = array(5,0); // Minimum version of PHP required by module
  62. $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
  63. $this->langfiles = array("productbatch");
  64. // Constants
  65. $this->const = array();
  66. $this->tabs = array();
  67. // Dictionaries
  68. if (! isset($conf->productbatch->enabled))
  69. {
  70. $conf->productbatch=new stdClass();
  71. $conf->productbatch->enabled=0;
  72. }
  73. $this->dictionaries=array();
  74. // Boxes
  75. $this->boxes = array(); // List of boxes
  76. // Permissions
  77. $this->rights = array(); // Permission array used by this module
  78. $r=0;
  79. // Main menu entries
  80. $this->menu = array(); // List of menus to add
  81. $r=0;
  82. // Exports
  83. $r=0;
  84. }
  85. /**
  86. * Function called when module is enabled.
  87. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  88. * It also creates data directories
  89. *
  90. * @param string $options Options when enabling module ('', 'noboxes')
  91. * @return int 1 if OK, 0 if KO
  92. */
  93. function init($options='')
  94. {
  95. global $db,$conf;
  96. $sql = array();
  97. if(! empty($conf->cashdesk->enabled)) {
  98. if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
  99. $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
  100. }
  101. }
  102. return $this->_init($sql, $options);
  103. }
  104. }