24if (!defined(
'NOREQUIRESOC')) {
25 define(
'NOREQUIRESOC',
'1');
27if (!defined(
'NOCSRFCHECK')) {
28 define(
'NOCSRFCHECK',
'1');
30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
43require
'../../main.inc.php';
53$batch =
GETPOST(
'batch',
'alphanohtml');
55$action =
GETPOST(
'action',
'alphanohtml');
59$permissiontoproduce = $user->hasRight(
'mrp',
'write');
69if ($action ==
'updateselectbatchbywarehouse' && $permissiontoproduce) {
72 $sql =
"SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
73 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_batch as pb";
74 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_stock as ps on ps.rowid = pb.fk_product_stock";
75 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (" .
getEntity(
'stock') .
")";
76 $sql .=
" WHERE ps.fk_product = " .((int) $fk_product);
77 if ($warehouse_id > 0) {
78 $sql .=
" AND fk_entrepot = '" . ((int) $warehouse_id) .
"'";
80 $sql .=
" ORDER BY e.ref, pb.batch";
82 $resql = $db->query($sql);
85 while ($obj = $db->fetch_object($resql)) {
86 if (empty($TRes[$obj->batch])) {
87 $TRes[$obj->batch] = $obj->qty;
89 $TRes[$obj->batch] += $obj->qty;
94 echo json_encode($TRes);
95} elseif ($action ==
'updateselectwarehousebybatch' && $permissiontoproduce) {
98 $sql =
"SELECT pb.batch, pb.rowid, ps.fk_entrepot, e.ref, pb.qty";
99 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_batch as pb";
100 $sql .=
" JOIN " . MAIN_DB_PREFIX .
"product_stock as ps on ps.rowid = pb.fk_product_stock";
101 $sql .=
" JOIN " . MAIN_DB_PREFIX .
"entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (" .
getEntity(
'stock') .
")";
102 $sql .=
" WHERE ps.fk_product = " .((int) $fk_product);
104 $sql.=
" AND pb.batch = '" . $db->escape($batch) .
"'";
106 $sql .=
" ORDER BY e.ref, pb.batch";
108 $resql = $db->query($sql);
111 if ($db->num_rows($resql) == 1) {
112 $obj = $db->fetch_object($resql);
113 $res = $obj->fk_entrepot;
117 echo json_encode($res);
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.