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