dolibarr  16.0.1
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') {
34  $productref = $object->ref;
35 }
36 
37 $langs->load("productbatch");
38 
39 
40 if (empty($id)) {
41  $id = $object->id;
42 }
43 
44 print '<script type="text/javascript">
45  jQuery(document).ready(function() {
46  function init_price()
47  {
48  if (jQuery("#mouvement").val() == \'0\') jQuery("#unitprice").removeAttr("disabled");
49  else jQuery("#unitprice").prop("disabled", true);
50  }
51  init_price();
52  jQuery("#mouvement").change(function() {
53  console.log("We change the direction of movement");
54  init_price();
55  });
56  jQuery("#nbpiece").keyup(function(event) {
57  console.log("We enter a qty on "+event.which);
58  if ( event.which == 54 ) { /* char - */
59  console.log("We set direction to value 1");
60  jQuery("#nbpiece").val(jQuery("#nbpiece").val().replace("-", ""));
61 
62  jQuery("#mouvement option").removeAttr("selected").change();
63  jQuery("#mouvement option[value=1]").attr("selected","selected").trigger("change");
64  jQuery("#mouvement").trigger("change");
65  } else if ( event.which == 187 ) { /* char + */
66  console.log("We set direction to value 0");
67  jQuery("#mouvement option").removeAttr("selected").change();
68  jQuery("#mouvement option[value=0]").attr("selected","selected").trigger("change");
69  jQuery("#mouvement").trigger("change");
70  }
71  });
72  });
73  </script>';
74 
75 
76 print load_fiche_titre($langs->trans("StockCorrection"), '', 'generic');
77 
78 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
79 
80 print dol_get_fiche_head();
81 
82 print '<input type="hidden" name="token" value="'.newToken().'">';
83 print '<input type="hidden" name="action" value="correct_stock">';
84 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
85 print '<table class="border centpercent">';
86 
87 // Warehouse or product
88 print '<tr>';
89 if ($object->element == 'product') {
90  print '<td class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
91  print '<td>';
92  $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')));
93  if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) {
94  $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE;
95  }
96  print img_picto('', 'stock').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
97  print '</td>';
98 }
99 if ($object->element == 'stock') {
100  print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
101  print '<td>';
102  print img_picto('', 'product');
103  $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');
104  print '</td>';
105 }
106 print '<td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td>';
107 print '<td>';
108 if ($object->element == 'product' || $object->element == 'stock') {
109  print '<select name="mouvement" id="mouvement" class="minwidth125 valignmiddle">';
110  print '<option value="0">'.$langs->trans("Add").'</option>';
111  print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
112  print '</select>';
113  print ajax_combobox("mouvement");
114 }
115 print '<input name="nbpiece" id="nbpiece" class="center valignmiddle maxwidth75" value="'.GETPOST("nbpiece").'">';
116 print '</td>';
117 print '</tr>';
118 
119 // If product is a Kit, we ask if we must disable stock change of subproducts
120 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $object->element == 'product' && $object->hasFatherOrChild(1)) {
121  print '<tr>';
122  print '<td></td>';
123  print '<td colspan="3">';
124  print '<input type="checkbox" name="disablesubproductstockchange" id="disablesubproductstockchange" value="1"'.(GETPOST('disablesubproductstockchange') ? ' checked="checked"' : '').'">';
125  print ' <label for="disablesubproductstockchange">'.$langs->trans("DisableStockChangeOfSubProduct").'</label>';
126  print '</td>';
127  print '</tr>';
128 }
129 
130 // Serial / Eat-by date
131 if (!empty($conf->productbatch->enabled) &&
132 (($object->element == 'product' && $object->hasbatch())
133 || ($object->element == 'stock'))
134 ) {
135  print '<tr>';
136  print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
137  print '<input type="text" name="batch_number" class="minwidth300" value="'.GETPOST("batch_number").'">';
138  print '</td>';
139  print '</tr>';
140  print '<tr>';
141  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
142  print '<td>'.$langs->trans("SellByDate").'</td><td>';
143  $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
144  print $form->selectDate($sellbyselected, 'sellby', '', '', 1, "");
145  print '</td>';
146  }
147  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
148  print '<td>'.$langs->trans("EatByDate").'</td><td>';
149  $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
150  print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
151  print '</td>';
152  }
153  print '</tr>';
154 }
155 
156 // Purchase price and project
157 print '<tr>';
158 print '<td>'.$langs->trans("UnitPurchaseValue").'</td>';
159 print '<td colspan="'.(!empty($conf->project->enabled) ? '1' : '3').'"><input name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
160 if (!empty($conf->project->enabled)) {
161  print '<td>'.$langs->trans('Project').'</td>';
162  print '<td>';
163  print img_picto('', 'project');
164  $formproject->select_projects(-1, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300 widthcentpercentminusx');
165  print '</td>';
166 }
167 print '</tr>';
168 
169 // Label of mouvement of id of inventory
170 $valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref));
171 print '<tr>';
172 print '<td>'.$langs->trans("MovementLabel").'</td>';
173 print '<td>';
174 print '<input type="text" name="label" class="minwidth400" value="'.dol_escape_htmltag($valformovementlabel).'">';
175 print '</td>';
176 print '<td>'.$langs->trans("InventoryCode").'</td>';
177 print '<td>';
178 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')).'">';
179 print '</td>';
180 print '</tr>';
181 
182 print '</table>';
183 
184 print dol_get_fiche_end();
185 
186 print '<div class="center">';
187 print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
188 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
189 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
190 print '</div>';
191 
192 print '</form>';
193 ?>
194 <!-- 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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
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.
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)
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve', $idforemptyvalue= '-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:429
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.