stock.lib.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /* Copyright (C) 2009 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. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/lib/stock.lib.php
  20. * \brief Library file with function for stock module
  21. */
  22. /**
  23. * Prepare array with list of tabs
  24. *
  25. * @param Object $object Object related to tabs
  26. * @return array Array of tabs to show
  27. */
  28. function stock_prepare_head($object)
  29. {
  30. global $langs, $conf, $user;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = DOL_URL_ROOT . '/product/stock/card.php?id=' . $object->id;
  34. $head[$h][1] = $langs->trans("Warehouse");
  35. $head[$h][2] = 'card';
  36. $h++;
  37. if (!empty($user->rights->stock->mouvement->lire)) {
  38. $head[$h][0] = DOL_URL_ROOT . '/product/stock/movement_list.php?id=' . $object->id;
  39. $head[$h][1] = $langs->trans("StockMovements");
  40. $head[$h][2] = 'movements';
  41. $h++;
  42. }
  43. /*
  44. $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id;
  45. $head[$h][1] = $langs->trans("EnhancedValue");
  46. $head[$h][2] = 'value';
  47. $h++;
  48. */
  49. /* Disabled because will never be implemented. Table always empty.
  50. if (!empty($conf->global->STOCK_USE_WAREHOUSE_BY_USER))
  51. {
  52. // Should not be enabled by defaut because does not work yet correctly because
  53. // personnal stocks are not tagged into table llx_entrepot
  54. $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$object->id;
  55. $head[$h][1] = $langs->trans("Users");
  56. $head[$h][2] = 'user';
  57. $h++;
  58. }
  59. */
  60. // Show more tabs from modules
  61. // Entries must be declared in modules descriptor with line
  62. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  63. // $this->tabs = array('entity:-tabname); to remove a tab
  64. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'core');
  65. if (!empty($user->rights->stock->mouvement->lire)) {
  66. $head[$h][0] = DOL_URL_ROOT . '/product/stock/info.php?id=' . $object->id;
  67. $head[$h][1] = $langs->trans("Info");
  68. $head[$h][2] = 'info';
  69. $h++;
  70. }
  71. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'external');
  72. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove');
  73. return $head;
  74. }
  75. /**
  76. * Return array head with list of tabs to view object informations.
  77. *
  78. * @return array head array with tabs
  79. */
  80. function stock_admin_prepare_head()
  81. {
  82. global $langs, $conf, $user, $db;
  83. $extrafields = new ExtraFields($db);
  84. $extrafields->fetch_name_optionals_label('entrepot');
  85. $extrafields->fetch_name_optionals_label('stock_mouvement');
  86. $extrafields->fetch_name_optionals_label('inventory');
  87. $h = 0;
  88. $head = array();
  89. $head[$h][0] = DOL_URL_ROOT . '/admin/stock.php';
  90. $head[$h][1] = $langs->trans("Miscellaneous");
  91. $head[$h][2] = 'general';
  92. $h++;
  93. // Show more tabs from modules
  94. // Entries must be declared in modules descriptor with line
  95. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  96. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  97. complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin');
  98. $head[$h][0] = DOL_URL_ROOT . '/product/admin/stock_extrafields.php';
  99. $head[$h][1] = $langs->trans("ExtraFields");
  100. $nbExtrafields = $extrafields->attributes['entrepot']['count'];
  101. if ($nbExtrafields > 0) {
  102. $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
  103. }
  104. $head[$h][2] = 'attributes';
  105. $h++;
  106. $head[$h][0] = DOL_URL_ROOT . '/product/admin/stock_mouvement_extrafields.php';
  107. $head[$h][1] = $langs->trans("StockMouvementExtraFields");
  108. $nbExtrafields = $extrafields->attributes['stock_mouvement']['count'];
  109. if ($nbExtrafields > 0) {
  110. $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
  111. }
  112. $head[$h][2] = 'stockMouvementAttributes';
  113. $h++;
  114. $head[$h][0] = DOL_URL_ROOT . '/product/admin/inventory_extrafields.php';
  115. $head[$h][1] = $langs->trans("InventoryExtraFields");
  116. $nbExtrafields = $extrafields->attributes['inventory']['count'];
  117. if ($nbExtrafields > 0) {
  118. $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
  119. }
  120. $head[$h][2] = 'inventoryAttributes';
  121. $h++;
  122. complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
  123. return $head;
  124. }