stocktransfer.tpl.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /* Copyright (C) 2010-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  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. * $object must be defined
  19. * $backtopage
  20. */
  21. // Protection to avoid direct call of template
  22. if (empty($conf) || !is_object($conf)) {
  23. print "Error, template page can't be called as URL";
  24. exit;
  25. }
  26. ?>
  27. <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP -->
  28. <?php
  29. $productref = '';
  30. if ($object->element == 'product') {
  31. $productref = $object->ref;
  32. }
  33. $langs->load("productbatch");
  34. if (empty($id)) {
  35. $id = $object->id;
  36. }
  37. $pdluoid = GETPOST('pdluoid', 'int');
  38. $pdluo = new Productbatch($db);
  39. if ($pdluoid > 0) {
  40. $result = $pdluo->fetch($pdluoid);
  41. if ($result > 0) {
  42. $pdluoid = $pdluo->id;
  43. } else {
  44. dol_print_error($db, $pdluo->error, $pdluo->errors);
  45. }
  46. }
  47. print load_fiche_titre($langs->trans("StockTransfer"), '', 'generic');
  48. print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
  49. print dol_get_fiche_head();
  50. print '<input type="hidden" name="token" value="'.newToken().'">';
  51. print '<input type="hidden" name="action" value="transfert_stock">';
  52. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  53. if ($pdluoid) {
  54. print '<input type="hidden" name="pdluoid" value="'.$pdluoid.'">';
  55. }
  56. print '<table class="border centpercent">';
  57. // Source warehouse or product
  58. print '<tr>';
  59. if ($object->element == 'product') {
  60. print '<td class="fieldrequired">'.$langs->trans("WarehouseSource").'</td>';
  61. print '<td>';
  62. print img_picto('', 'stock');
  63. $selected = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone')));
  64. $warehousestatus = 'warehouseopen,warehouseinternal';
  65. print $formproduct->selectWarehouses($selected, 'id_entrepot', $warehousestatus, 1, 0, 0, '', 0, 0, array(), 'minwidth75 maxwidth300 widthcentpercentminusx');
  66. print '</td>';
  67. }
  68. if ($object->element == 'stock') {
  69. print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
  70. print '<td>';
  71. print img_picto('', 'product');
  72. $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
  73. print '</td>';
  74. }
  75. print '<td class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td>';
  76. print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth75 maxwidth300 widthcentpercentminusx');
  77. print '</td></tr>';
  78. print '<tr><td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td colspan="3"><input type="text" name="nbpiece" class="center maxwidth75" value="'.dol_escape_htmltag(GETPOST("nbpiece")).'"></td>';
  79. print '</tr>';
  80. // Serial / Eat-by date
  81. if (isModEnabled('productbatch') &&
  82. (($object->element == 'product' && $object->hasbatch())
  83. || ($object->element == 'stock'))
  84. ) {
  85. print '<tr>';
  86. print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
  87. if ($pdluoid > 0) {
  88. // If form was opened for a specific pdluoid, field is disabled
  89. print '<input type="text" name="batch_number_bis" size="40" disabled="disabled" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
  90. print '<input type="hidden" name="batch_number" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
  91. } else {
  92. print img_picto('', 'barcode', 'class="pictofixedwidth"').'<input type="text" name="batch_number" class="minwidth300 widthcentpercentminusx maxwidth300" value="'.(GETPOST('batch_number') ? GETPOST('batch_number') : $pdluo->batch).'">';
  93. }
  94. print '</td>';
  95. print '</tr>';
  96. print '<tr>';
  97. if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
  98. print '<td>'.$langs->trans("SellByDate").'</td><td>';
  99. print $form->selectDate((!empty($d_sellby) ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
  100. print '</td>';
  101. }
  102. if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
  103. print '<td>'.$langs->trans("EatByDate").'</td><td>';
  104. print $form->selectDate((!empty($d_eatby) ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
  105. print '</td>';
  106. }
  107. print '</tr>';
  108. }
  109. // Label
  110. $valformovementlabel = (GETPOST("label") ? GETPOST("label") : $langs->trans("MovementTransferStock", $productref));
  111. print '<tr>';
  112. print '<td>'.$langs->trans("MovementLabel").'</td>';
  113. print '<td>';
  114. print '<input type="text" name="label" class="minwidth300" value="'.dol_escape_htmltag($valformovementlabel).'">';
  115. print '</td>';
  116. print '<td>'.$langs->trans("InventoryCode").'</td>';
  117. print '<td>';
  118. print '<input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(GETPOSTISSET("inventorycode") ? GETPOST("inventorycode", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')).'">';
  119. print '</td>';
  120. print '</tr>';
  121. print '</table>';
  122. print dol_get_fiche_end();
  123. print '<div class="center">';
  124. print '<input type="submit" class="button button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
  125. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  126. print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
  127. print '</div>';
  128. print '</form>';
  129. ?>
  130. <!-- END PHP STOCKCORRECTION.TPL.PHP -->