25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL', 1);
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREHTML')) {
32 define(
'NOREQUIREHTML',
'1');
34if (!defined(
'NOREQUIREAJAX')) {
35 define(
'NOREQUIREAJAX',
'1');
37if (!defined(
'NOREQUIRESOC')) {
38 define(
'NOREQUIRESOC',
'1');
40require
'../../main.inc.php';
41include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
50$action =
GETPOST(
"action",
"alpha");
51$barcode =
GETPOST(
"barcode",
"aZ09");
58$batch =
GETPOST(
"batch",
"aZ09");
63$objectreturn = array();
64$usesublevelpermission =
'';
69if (!empty($user->socid)) {
70 $socid = $user->socid;
92if ($action ==
"existbarcode" && !empty($barcode) && $user->hasRight(
'stock',
'lire')) {
93 if (!empty($mode) && $mode ==
"lotserial") {
94 $sql =
"SELECT ps.fk_entrepot, ps.fk_product, p.barcode, ps.reel, pb.batch";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_batch as pb";
96 $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";
97 $sql .=
" WHERE pb.batch = '".$db->escape($barcode).
"'";
99 $sql =
"SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
101 $sql .=
" WHERE p.barcode = '".$db->escape($barcode).
"'";
103 if (!empty($fk_entrepot)) {
104 $sql .=
" AND ps.fk_entrepot = '".$db->escape((
string) $fk_entrepot).
"'";
106 $result = $db->query($sql);
108 $nbline = $db->num_rows($result);
109 for ($i = 0; $i < $nbline; $i++) {
110 $obj = $db->fetch_object($result);
111 if (($mode ==
"barcode" && $barcode == $obj->barcode) || ($mode ==
"lotserial" && $barcode == $obj->batch)) {
112 if (!empty($obj->fk_entrepot) && $fk_entrepot == $obj->fk_entrepot) {
114 $warehouseid = $obj->fk_entrepot;
115 $fk_product = $obj->fk_product;
116 $reelqty = $obj->reel;
118 $objectreturn = array(
'fk_warehouse' => $warehouseid,
'fk_product' => $fk_product,
'reelqty' => $reelqty);
122 if ($warehousefound < 1) {
123 $response = array(
'status' =>
'error',
'errorcode' =>
'NotFound',
'message' =>
'No warehouse found for barcode'.$barcode);
124 } elseif ($warehousefound > 1) {
125 $response = array(
'status' =>
'error',
'errorcode' =>
'TooManyWarehouse',
'message' =>
'Too many warehouse found');
127 $response = array(
'status' =>
'success',
'message' =>
'Warehouse found',
'object' => $objectreturn);
130 $response = array(
'status' =>
'error',
'errorcode' =>
'NotFound',
'message' =>
"No results found for barcode");
133 $response = array(
'status' =>
'error',
'errorcode' =>
'ActionError',
'message' =>
"Error on action");
136$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.