dolibarr  13.0.2
ajax.inventory.php
1 <?php
2 
3 require '../../../main.inc.php';
4 require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
5 
6 $get = GETPOST('get', 'alpha');
7 $put = GETPOST('put', 'alpha');
8 
9 switch ($put)
10 {
11  case 'qty':
12  if (empty($user->rights->stock->creer)) { echo -1; exit; }
13 
14  $fk_det_inventory = GETPOST('fk_det_inventory');
15 
16  $det = new InventoryLine($db);
17  if ($det->fetch($fk_det_inventory))
18  {
19  $det->qty_view += GETPOST('qty');
20  $res = $det->update($user);
21 
22  echo $det->qty_view;
23  } else {
24  echo -2;
25  }
26 
27  break;
28 
29  case 'pmp':
30  if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; }
31 
32  $fk_det_inventory = GETPOST('fk_det_inventory');
33 
34  $det = new InventoryLine($db);
35  if ($det->fetch($fk_det_inventory))
36  {
37  $det->new_pmp = price2num(GETPOST('pmp'));
38  $det->update($user);
39 
40  echo $det->new_pmp;
41  } else {
42  echo -2;
43  }
44 
45  break;
46 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class InventoryLine.