24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL', 1);
27if (!defined(
'NOREQUIREMENU')) {
28 define(
'NOREQUIREMENU',
'1');
30if (!defined(
'NOREQUIREHTML')) {
31 define(
'NOREQUIREHTML',
'1');
33if (!defined(
'NOREQUIREAJAX')) {
34 define(
'NOREQUIREAJAX',
'1');
36if (!defined(
'NOREQUIRESOC')) {
37 define(
'NOREQUIRESOC',
'1');
39require
'../../main.inc.php';
40include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
49$action =
GETPOST(
"action",
"alpha");
50$barcode =
GETPOST(
"barcode",
"aZ09");
57$batch =
GETPOST(
"batch",
"aZ09");
62$objectreturn = array();
63$usesublevelpermission =
'';
68if (!empty($user->socid)) {
69 $socid = $user->socid;
91if ($action ==
"existbarcode" && !empty($barcode) && $user->hasRight(
'stock',
'lire')) {
92 if (!empty($mode) && $mode ==
"lotserial") {
93 $sql =
"SELECT ps.fk_entrepot, ps.fk_product, p.barcode, ps.reel, pb.batch";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_batch as pb";
95 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"product_stock as ps ON pb.fk_product_stock = ps.rowid JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
96 $sql .=
" WHERE pb.batch = '".$db->escape($barcode).
"'";
98 $sql =
"SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
100 $sql .=
" WHERE p.barcode = '".$db->escape($barcode).
"'";
102 if (!empty($fk_entrepot)) {
103 $sql .=
" AND ps.fk_entrepot = '".$db->escape($fk_entrepot).
"'";
105 $result = $db->query($sql);
107 $nbline = $db->num_rows($result);
108 for ($i=0; $i < $nbline; $i++) {
109 $obj = $db->fetch_object($result);
110 if (($mode ==
"barcode" && $barcode == $obj->barcode) || ($mode ==
"lotserial" && $barcode == $obj->batch)) {
111 if (!empty($obj->fk_entrepot) && $fk_entrepot == $obj->fk_entrepot) {
113 $warehouseid = $obj->fk_entrepot;
114 $fk_product = $obj->fk_product;
115 $reelqty = $obj->reel;
117 $objectreturn = array(
'fk_warehouse'=>$warehouseid,
'fk_product'=>$fk_product,
'reelqty'=>$reelqty);
121 if ($warehousefound < 1) {
122 $response = array(
'status'=>
'error',
'errorcode'=>
'NotFound',
'message'=>
'No warehouse found for barcode'.$barcode);
123 } elseif ($warehousefound > 1) {
124 $response = array(
'status'=>
'error',
'errorcode'=>
'TooManyWarehouse',
'message'=>
'Too many warehouse found');
126 $response = array(
'status'=>
'success',
'message'=>
'Warehouse found',
'object'=>$objectreturn);
129 $response = array(
'status'=>
'error',
'errorcode'=>
'NotFound',
'message'=>
"No results found for barcode");
132 $response = array(
'status'=>
'error',
'errorcode'=>
'ActionError',
'message'=>
"Error on action");
135$response = json_encode($response);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage products or services.
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.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
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.