stock.lib.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 ($user->hasRight('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. $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id;
  66. $head[$h][1] = $langs->trans("Info");
  67. $head[$h][2] = 'info';
  68. $h++;
  69. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'external');
  70. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove');
  71. return $head;
  72. }
  73. /**
  74. * Return array head with list of tabs to view object informations.
  75. *
  76. * @return array head array with tabs
  77. */
  78. function stock_admin_prepare_head()
  79. {
  80. global $langs, $conf, $user, $db;
  81. $extrafields = new ExtraFields($db);
  82. $extrafields->fetch_name_optionals_label('entrepot');
  83. $extrafields->fetch_name_optionals_label('stock_mouvement');
  84. $extrafields->fetch_name_optionals_label('inventory');
  85. $h = 0;
  86. $head = array();
  87. $head[$h][0] = DOL_URL_ROOT.'/admin/stock.php';
  88. $head[$h][1] = $langs->trans("Miscellaneous");
  89. $head[$h][2] = 'general';
  90. $h++;
  91. // Show more tabs from modules
  92. // Entries must be declared in modules descriptor with line
  93. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  94. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  95. complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin');
  96. $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php';
  97. $head[$h][1] = $langs->trans("ExtraFields");
  98. $nbExtrafields = $extrafields->attributes['entrepot']['count'];
  99. if ($nbExtrafields > 0) {
  100. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
  101. }
  102. $head[$h][2] = 'attributes';
  103. $h++;
  104. $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php';
  105. $head[$h][1] = $langs->trans("StockMouvementExtraFields");
  106. $nbExtrafields = $extrafields->attributes['stock_mouvement']['count'];
  107. if ($nbExtrafields > 0) {
  108. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
  109. }
  110. $head[$h][2] = 'stockMouvementAttributes';
  111. $h++;
  112. $head[$h][0] = DOL_URL_ROOT.'/product/admin/inventory_extrafields.php';
  113. $head[$h][1] = $langs->trans("InventoryExtraFields");
  114. $nbExtrafields = $extrafields->attributes['inventory']['count'];
  115. if ($nbExtrafields > 0) {
  116. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
  117. }
  118. $head[$h][2] = 'inventoryAttributes';
  119. $h++;
  120. complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
  121. return $head;
  122. }