107 public function index($sortfield =
"t.ref", $sortorder =
'ASC', $limit = 100, $page = 0, $sqlfilters =
'', $properties =
'')
111 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
112 throw new RestException(403);
117 $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid :
'';
119 $sql =
"SELECT t.rowid, t.ref";
120 $sql .=
" FROM ".$this->db->prefix().
"workstation_workstation as t";
127 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
132 $sqlTotals = str_replace(
'SELECT t.rowid, t.ref',
'SELECT count(t.rowid) as total', $sql);
134 $sql .= $this->db->order($sortfield, $sortorder);
139 $offset = $limit * $page;
141 $sql .= $this->db->plimit($limit + 1, $offset);
144 $result = $this->db->query($sql);
146 $num = $this->db->num_rows($result);
147 $min = min($num, ($limit <= 0 ? $num : $limit));
150 $obj = $this->db->fetch_object($result);
152 if ($workstation_static->fetch($obj->rowid)) {
158 throw new RestException(503,
'Error when retrieve workstation list : '.$this->db->lasterror());
163 $totalsResult = $this->db->query($sqlTotals);
164 $total = $this->db->fetch_object($totalsResult)->total;
169 $obj_ret[
'data'] = $tmp;
170 $obj_ret[
'pagination'] = array(
171 'total' => (
int) $total,
173 'page_count' => ceil((
int) $total/$limit),
197 unset(
$object->prices_by_qty_id);
199 unset(
$object->product_id_already_linked);
214 unset(
$object->fourn_price_base_type);
218 unset(
$object->product_fourn_id);
221 unset(
$object->linked_objects);
222 unset(
$object->linkedObjectsIds);
230 unset(
$object->commandeFournisseur);
236 unset(
$object->barcode_type_coder);
237 unset(
$object->shipping_method);
238 unset(
$object->fk_multicurrency);
239 unset(
$object->multicurrency_code);
240 unset(
$object->multicurrency_tx);
241 unset(
$object->multicurrency_total_ht);
242 unset(
$object->multicurrency_total_tva);
243 unset(
$object->multicurrency_total_ttc);
244 unset(
$object->multicurrency_total_localtax1);
245 unset(
$object->multicurrency_total_localtax2);
249 unset(
$object->total_localtax1);
250 unset(
$object->total_localtax2);
254 unset(
$object->labelStatusShort);
256 unset(
$object->showphoto_on_popup);
261 unset(
$object->cond_reglement_supplier_id);
262 unset(
$object->deposit_percent);
263 unset(
$object->retained_warranty_fk_cond_reglement);
267 unset(
$object->mode_reglement_id);
268 unset(
$object->cond_reglement_id);
269 unset(
$object->demand_reason_id);
270 unset(
$object->transport_mode_id);
271 unset(
$object->cond_reglement);
272 unset(
$object->shipping_method_id);
277 unset(
$object->recuperableonly);
278 unset(
$object->multiprices_recuperableonly);
284 unset(
$object->supplierprices);
287 unset(
$object->stock_theorique);
288 unset(
$object->stock_warehouse);
307 if (empty($id) && empty($ref)) {
308 throw new RestException(400,
'bad value for parameter id or ref');
311 $id = (empty($id) ? 0 : $id);
313 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
314 throw new RestException(403);
317 $result = $this->workstation->fetch($id, $ref);
319 throw new RestException(404,
'Workstation not found');
323 throw new RestException(401,
'Access not allowed for login '.DolibarrApiAccess::$user->login);