dolibarr  13.0.2
stockcorrection.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') $productref = $object->ref;
34 
35 $langs->load("productbatch");
36 
37 
38 if (empty($id)) $id = $object->id;
39 
40 print '<script type="text/javascript" language="javascript">
41  jQuery(document).ready(function() {
42  function init_price()
43  {
44  if (jQuery("#mouvement").val() == \'0\') jQuery("#unitprice").removeAttr("disabled");
45  else jQuery("#unitprice").prop("disabled", true);
46  }
47  init_price();
48  jQuery("#mouvement").change(function() {
49  init_price();
50  });
51  });
52  </script>';
53 
54 
55 print load_fiche_titre($langs->trans("StockCorrection"), '', 'generic');
56 
57 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
58 
60 
61 print '<input type="hidden" name="token" value="'.newToken().'">';
62 print '<input type="hidden" name="action" value="correct_stock">';
63 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
64 print '<table class="border centpercent">';
65 
66 // Warehouse or product
67 print '<tr>';
68 if ($object->element == 'product') {
69  print '<td class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
70  print '<td>';
71  $ident = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ? GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone')));
72  if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE;
73  print img_picto('', 'stock').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
74  print ' &nbsp; <select class="button buttongen" name="mouvement" id="mouvement">';
75  print '<option value="0">'.$langs->trans("Add").'</option>';
76  print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
77  print '</select>';
78  print '</td>';
79 }
80 if ($object->element == 'stock') {
81  print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
82  print '<td>';
83  print img_picto('', 'product');
84  $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');
85  print ' &nbsp; <select class="button buttongen" name="mouvement" id="mouvement">';
86  print '<option value="0">'.$langs->trans("Add").'</option>';
87  print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
88  print '</select>';
89  print '</td>';
90 }
91 print '<td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td>';
92 print '<td><input name="nbpiece" id="nbpiece" class="maxwidth75" value="'.GETPOST("nbpiece").'"></td>';
93 print '</tr>';
94 
95 // If product is a Kit, we ask if we must disable stock change of subproducts
96 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $object->element == 'product' && $object->hasFatherOrChild(1)) {
97  print '<tr>';
98  print '<td></td>';
99  print '<td colspan="3">';
100  print '<input type="checkbox" name="disablesubproductstockchange" id="disablesubproductstockchange" value="1"'.(GETPOST('disablesubproductstockchange') ? ' checked="checked"' : '').'">';
101  print ' <label for="disablesubproductstockchange">'.$langs->trans("DisableStockChangeOfSubProduct").'</label>';
102  print '</td>';
103  print '</tr>';
104 }
105 
106 // Serial / Eat-by date
107 if (!empty($conf->productbatch->enabled) &&
108 (($object->element == 'product' && $object->hasbatch())
109 || ($object->element == 'stock'))
110 )
111 {
112  print '<tr>';
113  print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
114  print '<input type="text" name="batch_number" size="40" value="'.GETPOST("batch_number").'">';
115  print '</td>';
116  print '</tr>';
117  print '<tr>';
118  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
119  print '<td>'.$langs->trans("EatByDate").'</td><td>';
120  $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
121  print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
122  print '</td>';
123  }
124  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
125  print '<td>'.$langs->trans("SellByDate").'</td><td>';
126  $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
127  print $form->selectDate($sellbyselected, 'sellby', '', '', 1, "");
128  print '</td>';
129  }
130  print '</tr>';
131 }
132 
133 // Purchase price and project
134 print '<tr>';
135 print '<td>'.$langs->trans("UnitPurchaseValue").'</td>';
136 print '<td colspan="'.(!empty($conf->projet->enabled) ? '1' : '3').'"><input name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
137 if (!empty($conf->projet->enabled))
138 {
139  print '<td>'.$langs->trans('Project').'</td>';
140  print '<td>';
141  print img_picto('', 'project');
142  $formproject->select_projects(-1, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300');
143  print '</td>';
144 }
145 print '</tr>';
146 
147 // Label of mouvement of id of inventory
148 $valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref));
149 print '<tr>';
150 print '<td>'.$langs->trans("MovementLabel").'</td>';
151 print '<td>';
152 print '<input type="text" name="label" class="minwidth300" value="'.$valformovementlabel.'">';
153 print '</td>';
154 print '<td>'.$langs->trans("InventoryCode").'</td><td><input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(GETPOSTISSET("inventorycode") ? GETPOST("inventorycode", 'alpha') : dol_print_date(dol_now(), '%y%m%d%H%M%S')).'"></td>';
155 print '</tr>';
156 
157 print '</table>';
158 
160 
161 print '<div class="center">';
162 print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
163 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
164 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
165 print '</div>';
166 
167 print '</form>';
168 ?>
169 <!-- END PHP STOCKCORRECTION.TPL.PHP -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_fiche_end($notab=0)
Return tab footer of a card.