dolibarr 21.0.0-alpha
ajax.php
Go to the documentation of this file.
1<?php
24if (!defined('NOTOKENRENEWAL')) {
25 define('NOTOKENRENEWAL', '1'); // Disables token renewal
26}
27if (!defined('NOREQUIREHTML')) {
28 define('NOREQUIREHTML', '1');
29}
30if (!defined('NOREQUIREAJAX')) {
31 define('NOREQUIREAJAX', '1');
32}
33if (!defined('NOREQUIRESOC')) {
34 define('NOREQUIRESOC', '1');
35}
36if (!defined('NOREQUIREMENU')) {
37 define('NOREQUIREMENU', '1');
38}
39if (!defined('NOBROWSERNOTIF')) {
40 define('NOBROWSERNOTIF', '1');
41}
42
43include_once '../../main.inc.php'; // Load $user and permissions
44require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
46
47
48$action = GETPOST('action', 'aZ09');
49$idproduct = GETPOSTINT('idproduct');
50
51
52/*
53 * View
54 */
55
56top_httphead('application/json');
57
58if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) {
59 $product = new Product($db);
60 $res = $product->fetch($idproduct);
61
62 $cUnit = new CUnits($db);
63 $fk_unit = $cUnit->getUnitFromCode($product->duration_unit, 'short_label', 'time');
64
65 echo json_encode($fk_unit);
66 exit();
67}
68
69if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) {
70 $product = new Product($db);
71 $res = $product->fetch($idproduct);
72
73 $result = array();
74
75 if ($res < 0) {
76 $error = 'SQL ERROR';
77 } elseif ($res == 0) {
78 $error = 'NOT FOUND';
79 } else {
80 $error = null;
81 $result['defaultWk']=$product->fk_default_workstation;
82 }
83
84 $result['error']=$error;
85
86 echo json_encode($result);
87 exit();
88}
Class of dictionary type of thirdparty (used by imports)
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.