dolibarr 21.0.0-alpha
product_lot.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023 Lionel Vessiller <lvessiller@easya.solutions>
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
24if (!defined('NOTOKENRENEWAL')) {
25 define('NOTOKENRENEWAL', '1');
26}
27if (!defined('NOREQUIREMENU')) {
28 define('NOREQUIREMENU', '1');
29}
30if (!defined('NOREQUIREHTML')) {
31 define('NOREQUIREHTML', '1');
32}
33if (!defined('NOREQUIREAJAX')) {
34 define('NOREQUIREAJAX', '1');
35}
36if (!defined('NOBROWSERNOTIF')) {
37 define('NOBROWSERNOTIF', '1');
38}
39
40// Load Dolibarr environment
41require '../../main.inc.php'; // Load $user and permissions
42require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
43
44$action = GETPOST('action', 'aZ09');
45$productId = GETPOSTINT('product_id');
46$batch = GETPOST('batch', 'alphanohtml');
47
48// Security check
49restrictedArea($user, 'produit|service', $productId, 'product&product');
50
51
52/*
53 * View
54 */
55
56top_httphead('application/json');
57
58$rows = array();
59
60if ($action == 'search' && $batch != '') {
61 $productLot = new Productlot($db);
62 $result = $productLot->fetch('', $productId, $batch);
63
64 if ($result > 0 && $productLot->id > 0) {
65 $rows[] = array(
66 'rowid' => $productLot->id,
67 'sellby' => ($productLot->sellby ? dol_print_date($productLot->sellby, 'day') : ''),
68 'eatby' => ($productLot->eatby ? dol_print_date($productLot->eatby, 'day') : ''),
69 );
70 }
71}
72
73echo json_encode($rows);
74exit();
Class with list of lots and properties.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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.