22use Luracast\Restler\RestException;
24require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
71 public function get(
$id)
93 return $this->
_fetch(0, $ref);
111 public function index($sortfield =
"t.ref", $sortorder =
'ASC', $limit = 100, $page = 0, $sqlfilters =
'', $properties =
'')
115 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
116 throw new RestException(403);
121 $socid = DolibarrApiAccess::$user->socid ?:
'';
123 $sql =
"SELECT t.rowid, t.ref";
124 $sql .=
" FROM ".$this->db->prefix().
"workstation_workstation as t";
131 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
136 $sqlTotals = str_replace(
'SELECT t.rowid, t.ref',
'SELECT count(t.rowid) as total', $sql);
138 $sql .= $this->db->order($sortfield, $sortorder);
143 $offset = $limit * $page;
145 $sql .= $this->db->plimit($limit + 1, $offset);
148 $result = $this->db->query($sql);
150 $num = $this->db->num_rows($result);
151 $min = min($num, ($limit <= 0 ? $num : $limit));
154 $obj = $this->db->fetch_object($result);
156 if ($workstation_static->fetch($obj->rowid)) {
162 throw new RestException(503,
'Error when retrieve workstation list : '.$this->db->lasterror());
167 $totalsResult = $this->db->query($sqlTotals);
168 $total = $this->db->fetch_object($totalsResult)->total;
173 $obj_ret[
'data'] = $tmp;
174 $obj_ret[
'pagination'] = array(
175 'total' => (
int) $total,
177 'page_count' => (
int) ceil((
int) $total / $limit),
206 unset(
$object->prices_by_qty_id);
207 unset(
$object->product_id_already_linked);
222 unset(
$object->fourn_price_base_type);
226 unset(
$object->product_fourn_id);
229 unset(
$object->linked_objects);
230 unset(
$object->linkedObjectsIds);
238 unset(
$object->commandeFournisseur);
244 unset(
$object->barcode_type_coder);
245 unset(
$object->shipping_method);
246 unset(
$object->fk_multicurrency);
247 unset(
$object->multicurrency_code);
248 unset(
$object->multicurrency_tx);
249 unset(
$object->multicurrency_total_ht);
250 unset(
$object->multicurrency_total_tva);
251 unset(
$object->multicurrency_total_ttc);
252 unset(
$object->multicurrency_total_localtax1);
253 unset(
$object->multicurrency_total_localtax2);
257 unset(
$object->total_localtax1);
258 unset(
$object->total_localtax2);
262 unset(
$object->labelStatusShort);
264 unset(
$object->showphoto_on_popup);
269 unset(
$object->cond_reglement_supplier_id);
270 unset(
$object->deposit_percent);
271 unset(
$object->retained_warranty_fk_cond_reglement);
275 unset(
$object->mode_reglement_id);
276 unset(
$object->cond_reglement_id);
277 unset(
$object->demand_reason_id);
278 unset(
$object->transport_mode_id);
279 unset(
$object->cond_reglement);
280 unset(
$object->shipping_method_id);
285 unset(
$object->recuperableonly);
286 unset(
$object->multiprices_recuperableonly);
293 unset(
$object->stock_theorique);
294 unset(
$object->stock_warehouse);
313 if (empty(
$id) && empty($ref)) {
314 throw new RestException(400,
'bad value for parameter id or ref');
319 if (!DolibarrApiAccess::$user->rights->workstation->workstation->read) {
320 throw new RestException(403);
323 $result = $this->workstation->fetch(
$id, $ref);
325 throw new RestException(404,
'Workstation not found');
329 throw new RestException(401,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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.
_cleanObjectDatas($object)
Clean sensitive object data @phpstan-template T.
_fetch($id, $ref='')
Get properties of 1 workstation object.
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