21use Luracast\Restler\RestException;
23require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
70 public function get(
$id)
92 return $this->
_fetch(0, $ref);
110 public function index($sortfield =
"t.ref", $sortorder =
'ASC', $limit = 100, $page = 0, $sqlfilters =
'', $properties =
'')
114 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
115 throw new RestException(403);
120 $socid = DolibarrApiAccess::$user->socid ?:
'';
122 $sql =
"SELECT t.rowid, t.ref";
123 $sql .=
" FROM ".$this->db->prefix().
"workstation_workstation as t";
130 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
135 $sqlTotals = str_replace(
'SELECT t.rowid, t.ref',
'SELECT count(t.rowid) as total', $sql);
137 $sql .= $this->db->order($sortfield, $sortorder);
142 $offset = $limit * $page;
144 $sql .= $this->db->plimit($limit + 1, $offset);
147 $result = $this->db->query($sql);
149 $num = $this->db->num_rows($result);
150 $min = min($num, ($limit <= 0 ? $num : $limit));
153 $obj = $this->db->fetch_object($result);
155 if ($workstation_static->fetch($obj->rowid)) {
161 throw new RestException(503,
'Error when retrieve workstation list : '.$this->db->lasterror());
166 $totalsResult = $this->db->query($sqlTotals);
167 $total = $this->db->fetch_object($totalsResult)->total;
172 $obj_ret[
'data'] = $tmp;
173 $obj_ret[
'pagination'] = array(
174 'total' => (
int) $total,
176 'page_count' => (
int) ceil((
int) $total / $limit),
200 unset(
$object->prices_by_qty_id);
202 unset(
$object->product_id_already_linked);
217 unset(
$object->fourn_price_base_type);
221 unset(
$object->product_fourn_id);
224 unset(
$object->linked_objects);
225 unset(
$object->linkedObjectsIds);
233 unset(
$object->commandeFournisseur);
239 unset(
$object->barcode_type_coder);
240 unset(
$object->shipping_method);
241 unset(
$object->fk_multicurrency);
242 unset(
$object->multicurrency_code);
243 unset(
$object->multicurrency_tx);
244 unset(
$object->multicurrency_total_ht);
245 unset(
$object->multicurrency_total_tva);
246 unset(
$object->multicurrency_total_ttc);
247 unset(
$object->multicurrency_total_localtax1);
248 unset(
$object->multicurrency_total_localtax2);
252 unset(
$object->total_localtax1);
253 unset(
$object->total_localtax2);
257 unset(
$object->labelStatusShort);
259 unset(
$object->showphoto_on_popup);
264 unset(
$object->cond_reglement_supplier_id);
265 unset(
$object->deposit_percent);
266 unset(
$object->retained_warranty_fk_cond_reglement);
270 unset(
$object->mode_reglement_id);
271 unset(
$object->cond_reglement_id);
272 unset(
$object->demand_reason_id);
273 unset(
$object->transport_mode_id);
274 unset(
$object->cond_reglement);
275 unset(
$object->shipping_method_id);
280 unset(
$object->recuperableonly);
281 unset(
$object->multiprices_recuperableonly);
287 unset(
$object->supplierprices);
290 unset(
$object->stock_theorique);
291 unset(
$object->stock_warehouse);
310 if (empty(
$id) && empty($ref)) {
311 throw new RestException(400,
'bad value for parameter id or ref');
316 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
317 throw new RestException(403);
320 $result = $this->workstation->fetch(
$id, $ref);
322 throw new RestException(404,
'Workstation not found');
326 throw new RestException(401,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
_fetch($id, $ref='')
Get properties of 1 workstation object.
_cleanObjectDatas($object)
Clean sensible object datas.
getByRef($ref)
Get properties of a workstation object by ref.
index($sortfield="t.ref", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='')
List workstations.
__construct()
Constructor.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...