dolibarr  16.0.5
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', 'class="pictofixedwidth"').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100 maxwidth300 widthcentpercentminusx');
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 img_picto('', 'barcode', 'class="pictofixedwidth"').'<input type="text" name="batch_number" class="minwidth300 maxwidth300 widthcentpercentminusx" value="'.GETPOST("batch_number").'">';
138  print '</td>';
139  print '</tr>';
140 
141  print '<tr>';
142  if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
143  print '<td>'.$langs->trans("SellByDate").'</td><td>';
144  $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
145  print $form->selectDate($sellbyselected, 'sellby', '', '', 1, "");
146  print '</td>';
147  }
148  if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
149  print '<td>'.$langs->trans("EatByDate").'</td><td>';
150  $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
151  print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
152  print '</td>';
153  }
154  print '</tr>';
155 }
156 
157 // Purchase price and project
158 print '<tr>';
159 print '<td>'.$langs->trans("UnitPurchaseValue").'</td>';
160 print '<td colspan="'.(!empty($conf->project->enabled) ? '1' : '3').'"><input name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
161 if (!empty($conf->project->enabled)) {
162  print '<td>'.$langs->trans('Project').'</td>';
163  print '<td>';
164  print img_picto('', 'project');
165  $formproject->select_projects(-1, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300 widthcentpercentminusx');
166  print '</td>';
167 }
168 print '</tr>';
169 
170 // Label of mouvement of id of inventory
171 $valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref));
172 print '<tr>';
173 print '<td>'.$langs->trans("MovementLabel").'</td>';
174 print '<td>';
175 print '<input type="text" name="label" class="minwidth400" value="'.dol_escape_htmltag($valformovementlabel).'">';
176 print '</td>';
177 print '<td>'.$langs->trans("InventoryCode").'</td>';
178 print '<td>';
179 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')).'">';
180 print '</td>';
181 print '</tr>';
182 
183 print '</table>';
184 
185 print dol_get_fiche_end();
186 
187 print '<div class="center">';
188 print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
189 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
190 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
191 print '</div>';
192 
193 print '</form>';
194 ?>
195 <!-- END PHP STOCKCORRECTION.TPL.PHP -->
ajax_combobox
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:438
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
$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
dol_mktime
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...
Definition: functions.lib.php:2757