dolibarr  16.0.5
stocktransfer.tpl.php
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 
22 // Protection to avoid direct call of template
23 if (empty($conf) || !is_object($conf)) {
24  print "Error, template page can't be called as URL";
25  exit;
26 }
27 
28 ?>
29 
30 <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP -->
31 <?php
32 $productref = '';
33 if ($object->element == 'product') {
34  $productref = $object->ref;
35 }
36 
37 $langs->load("productbatch");
38 
39 if (empty($id)) {
40  $id = $object->id;
41 }
42 
43 $pdluoid = GETPOST('pdluoid', 'int');
44 
45 $pdluo = new Productbatch($db);
46 
47 if ($pdluoid > 0) {
48  $result = $pdluo->fetch($pdluoid);
49  if ($result > 0) {
50  $pdluoid = $pdluo->id;
51  } else {
52  dol_print_error($db, $pdluo->error, $pdluo->errors);
53  }
54 }
55 
56 print load_fiche_titre($langs->trans("StockTransfer"), '', 'generic');
57 
58 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
59 
60 print dol_get_fiche_head();
61 
62 print '<input type="hidden" name="token" value="'.newToken().'">';
63 print '<input type="hidden" name="action" value="transfert_stock">';
64 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
65 if ($pdluoid) {
66  print '<input type="hidden" name="pdluoid" value="'.$pdluoid.'">';
67 }
68 print '<table class="border centpercent">';
69 
70 // Source warehouse or product
71 print '<tr>';
72 if ($object->element == 'product') {
73  print '<td class="fieldrequired">'.$langs->trans("WarehouseSource").'</td>';
74  print '<td>';
75  print img_picto('', 'stock');
76  $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')));
77  $warehousestatus = 'warehouseopen,warehouseinternal';
78  print $formproduct->selectWarehouses($selected, 'id_entrepot', $warehousestatus, 1, 0, 0, '', 0, 0, array(), 'minwidth75 maxwidth300 widthcentpercentminusx');
79  print '</td>';
80 }
81 if ($object->element == 'stock') {
82  print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
83  print '<td>';
84  print img_picto('', 'product');
85  $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');
86  print '</td>';
87 }
88 
89 print '<td class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td>';
90 print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth75 maxwidth300 widthcentpercentminusx');
91 print '</td></tr>';
92 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>';
93 print '</tr>';
94 
95 // Serial / Eat-by date
96 if (!empty($conf->productbatch->enabled) &&
97 (($object->element == 'product' && $object->hasbatch())
98 || ($object->element == 'stock'))
99 ) {
100  print '<tr>';
101  print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
102  if ($pdluoid > 0) {
103  // If form was opened for a specific pdluoid, field is disabled
104  print '<input type="text" name="batch_number_bis" size="40" disabled="disabled" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
105  print '<input type="hidden" name="batch_number" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
106  } else {
107  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).'">';
108  }
109  print '</td>';
110  print '</tr>';
111 
112  print '<tr>';
113  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
114  print '<td>'.$langs->trans("SellByDate").'</td><td>';
115  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
116  print '</td>';
117  }
118  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
119  print '<td>'.$langs->trans("EatByDate").'</td><td>';
120  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
121  print '</td>';
122  }
123  print '</tr>';
124 }
125 
126 // Label
127 $valformovementlabel = (GETPOST("label") ? GETPOST("label") : $langs->trans("MovementTransferStock", $productref));
128 print '<tr>';
129 print '<td>'.$langs->trans("MovementLabel").'</td>';
130 print '<td>';
131 print '<input type="text" name="label" class="minwidth300" value="'.dol_escape_htmltag($valformovementlabel).'">';
132 print '</td>';
133 print '<td>'.$langs->trans("InventoryCode").'</td>';
134 print '<td>';
135 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')).'">';
136 print '</td>';
137 print '</tr>';
138 
139 print '</table>';
140 
141 print dol_get_fiche_end();
142 
143 print '<div class="center">';
144 print '<input type="submit" class="button button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
145 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
146 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
147 print '</div>';
148 
149 print '</form>';
150 ?>
151 <!-- END PHP STOCKCORRECTION.TPL.PHP -->
Productbatch
Manage record for batch number management.
Definition: productbatch.class.php:31
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845