20use Luracast\Restler\RestException;
22require_once DOL_DOCUMENT_ROOT.
'/api/class/api.class.php';
23require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
24require_once DOL_DOCUMENT_ROOT.
'/core/class/objectlink.class.php';
38 public static $FIELDS = array(
97 $clean_field = $this->
_checkValForAPI($field, $value, $this->objectlink);
107 if (in_array($field, $intFields)) {
108 $this->objectlink->$field = (int) $clean_field;
110 $this->objectlink->$field = (
string) $clean_field;
136 public function create($request_data =
null)
139 $result = $this->
_validate($request_data);
141 foreach ($request_data as $field => $value) {
142 if ($field ==
'notrigger') {
143 $this->notrigger = (int) $value;
150 $srctype = $this->objectlink->sourcetype;
151 if ($this->objectlink->sourcetype ==
'subscription') {
152 $srctype =
'adherent';
154 if ($this->objectlink->sourcetype ==
'conferenceorboothattendee') {
157 $tgttype = $this->objectlink->targettype;
158 if ($this->objectlink->targettype ==
'subscription') {
159 $tgttype =
'adherent';
161 if ($this->objectlink->targettype ==
'conferenceorboothattendee') {
164 if (!DolibarrApiAccess::$user->hasRight((
string) $srctype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $srctype,
'write')) {
165 throw new RestException(403,
'denied access to create the objectlinks sourcetype='.$this->objectlink->sourcetype);
167 if (!DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'write')) {
168 throw new RestException(403,
'denied access to create the objectlinks targettype='.$this->objectlink->targettype);
171 $result = $this->objectlink->create(DolibarrApiAccess::$user, $this->objectlink->fk_source, $this->objectlink->sourcetype, $this->objectlink->fk_target, $this->objectlink->targettype, $this->objectlink->relationtype, $this->notrigger);
174 throw new RestException(500,
'when create objectlink : '.$this->objectlink->error);
178 throw new RestException(304,
'Object link already exists');
184 'message' =>
'object link created'
206 $result = $this->objectlink->fetch(
$id);
208 $srctype = $this->objectlink->sourcetype;
209 if ($this->objectlink->sourcetype ==
'subscription') {
210 $srctype =
'adherent';
212 if ($this->objectlink->sourcetype ==
'conferenceorboothattendee') {
215 $tgttype = $this->objectlink->targettype;
216 if ($this->objectlink->targettype ==
'subscription') {
217 $tgttype =
'adherent';
219 if ($this->objectlink->targettype ==
'conferenceorboothattendee') {
222 if (!DolibarrApiAccess::$user->hasRight(((
string) $srctype),
'creer') && !DolibarrApiAccess::$user->hasRight(((
string) $srctype),
'write')) {
223 throw new RestException(403,
'denied access to the objectlinks sourcetype');
225 if (!DolibarrApiAccess::$user->hasRight(((
string) $tgttype),
'creer') && !DolibarrApiAccess::$user->hasRight(((
string) $tgttype),
'write')) {
226 throw new RestException(403,
'denied access to the objectlinks targettype');
229 throw new RestException(404,
'Object Link not found');
232 if (!$this->objectlink->delete(DolibarrApiAccess::$user)) {
233 throw new RestException(500,
'Error when delete objectlink : '.$this->objectlink->error);
239 'message' =>
'object link deleted'
262 public function getByValues($fk_source, $sourcetype, $fk_target, $targettype, $relationtype =
null)
264 $request_data = array(
265 'fk_source' => ((
int) $fk_source),
266 'sourcetype' => (
string) $sourcetype,
267 'fk_target' => ((
int) $fk_target),
268 'targettype' => (
string) $targettype,
269 'relationtype' => $relationtype,
273 $result = $this->
_validate($request_data);
275 foreach ($request_data as $field => $value) {
280 $srctype = $this->objectlink->sourcetype;
281 if ($this->objectlink->sourcetype ==
'subscription') {
282 $srctype =
'adherent';
284 if ($this->objectlink->sourcetype ==
'conferenceorboothattendee') {
287 $tgttype = $this->objectlink->targettype;
288 if ($this->objectlink->targettype ==
'subscription') {
289 $tgttype =
'adherent';
291 if ($this->objectlink->targettype ==
'conferenceorboothattendee') {
294 if (!DolibarrApiAccess::$user->hasRight((
string) $srctype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $srctype,
'write')) {
295 throw new RestException(403,
'denied access to get the objectlinks sourcetype='.$this->objectlink->sourcetype);
297 if (!DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'write')) {
298 throw new RestException(403,
'denied access to get the objectlinks targettype='.$this->objectlink->targettype);
301 $findresult = $this->objectlink->fetchByValues($this->objectlink->fk_source, $this->objectlink->sourcetype, $this->objectlink->fk_target, $this->objectlink->targettype, $this->objectlink->relationtype);
303 if ($findresult < 0) {
304 throw new RestException(500,
'Error when finding objectlink : '.$this->objectlink->error);
305 } elseif ($findresult > 0) {
308 throw new RestException(404,
'Object Link not found');
332 public function deleteByValues($fk_source, $sourcetype, $fk_target, $targettype, $relationtype =
null, $notrigger = 0)
334 $request_data = array(
335 'fk_source' => ((
int) $fk_source),
336 'sourcetype' => (
string) $sourcetype,
337 'fk_target' => ((
int) $fk_target),
338 'targettype' => (
string) $targettype,
339 'relationtype' => $relationtype,
343 $result = $this->
_validate($request_data);
345 foreach ($request_data as $field => $value) {
350 $srctype = $this->objectlink->sourcetype;
351 if ($this->objectlink->sourcetype ==
'subscription') {
352 $srctype =
'adherent';
354 if ($this->objectlink->sourcetype ==
'conferenceorboothattendee') {
357 $tgttype = $this->objectlink->targettype;
358 if ($this->objectlink->targettype ==
'subscription') {
359 $tgttype =
'adherent';
361 if ($this->objectlink->targettype ==
'conferenceorboothattendee') {
364 if (!DolibarrApiAccess::$user->hasRight((
string) $srctype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $srctype,
'write')) {
365 throw new RestException(403,
'denied access to delete the objectlinks sourcetype='.$this->objectlink->sourcetype);
367 if (!DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'creer') && !DolibarrApiAccess::$user->hasRight((
string) $tgttype,
'write')) {
368 throw new RestException(403,
'denied access to delete the objectlinks targettype='.$this->objectlink->targettype);
371 $findresult = $this->objectlink->fetchByValues($this->objectlink->fk_source, $this->objectlink->sourcetype, $this->objectlink->fk_target, $this->objectlink->targettype, $this->objectlink->relationtype);
373 if ($findresult < 0) {
374 throw new RestException(500,
'Error when finding objectlink : '.$this->objectlink->error);
375 } elseif ($findresult > 0) {
376 $result = $this->objectlink->delete(DolibarrApiAccess::$user, $notrigger);
379 throw new RestException(500,
'Error when delete objectlink : '.$this->objectlink->error);
385 'message' =>
'object link deleted'
389 throw new RestException(404,
'Object Link not found');
408 $result = $this->objectlink->fetch(
$id);
410 $srctype = $this->objectlink->sourcetype;
411 if ($this->objectlink->sourcetype ==
'subscription') {
412 $srctype =
'adherent';
414 if ($this->objectlink->sourcetype ==
'conferenceorboothattendee') {
417 $tgttype = $this->objectlink->targettype;
418 if ($this->objectlink->targettype ==
'subscription') {
419 $tgttype =
'adherent';
421 if ($this->objectlink->targettype ==
'conferenceorboothattendee') {
424 if (!DolibarrApiAccess::$user->hasRight(((
string) $srctype),
'lire') && !DolibarrApiAccess::$user->hasRight(((
string) $srctype),
'read')) {
425 throw new RestException(403,
'denied access to the objectlinks sourcetype');
427 if (!DolibarrApiAccess::$user->hasRight(((
string) $tgttype),
'lire') && !DolibarrApiAccess::$user->hasRight(((
string) $tgttype),
'read')) {
428 throw new RestException(403,
'denied access to the objectlinks targettype');
431 throw new RestException(404,
'Object Link not found');
458 unset(
$object->array_languages);
460 unset(
$object->linkedObjectsIds);
476 unset(
$object->barcode_type_coder);
477 unset(
$object->mode_reglement_id);
478 unset(
$object->cond_reglement_id);
479 unset(
$object->demand_reason_id);
480 unset(
$object->transport_mode_id);
481 unset(
$object->shipping_method_id);
482 unset(
$object->shipping_method);
483 unset(
$object->fk_multicurrency);
484 unset(
$object->multicurrency_code);
485 unset(
$object->multicurrency_tx);
486 unset(
$object->multicurrency_total_ht);
487 unset(
$object->multicurrency_total_tva);
488 unset(
$object->multicurrency_total_ttc);
489 unset(
$object->multicurrency_total_localtax1);
490 unset(
$object->multicurrency_total_localtax2);
497 unset(
$object->total_localtax1);
498 unset(
$object->total_localtax2);
501 unset(
$object->actiontypecode);
507 unset(
$object->date_validation);
508 unset(
$object->date_modification);
511 unset(
$object->user_creation_id);
512 unset(
$object->user_validation_id);
513 unset(
$object->user_closing_id);
514 unset(
$object->user_modification_id);
518 unset(
$object->totalcreditnotes);
520 unset(
$object->totalpaid_multicurrency);
521 unset(
$object->totalcreditnotes_multicurrency);
522 unset(
$object->totaldeposits_multicurrency);
524 unset(
$object->cond_reglement_supplier_id);
525 unset(
$object->deposit_percent);
526 unset(
$object->retained_warranty_fk_cond_reglement);
548 $objectlink = array();
549 foreach (ObjectLinks::$FIELDS as $field) {
550 if (!isset($data[$field])) {
551 throw new RestException(400, $field.
" field missing");
553 $objectlink[$field] = $data[$field];
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
_validate($data)
Validate fields before create or update object.
create($request_data=null)
Create object link.
deleteById($id)
Delete an object link.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
__construct()
Constructor of the class.
getByValues($fk_source, $sourcetype, $fk_target, $targettype, $relationtype=null)
GET object link(s) By Values, not id.
_setObjectLinkField($field, $value)
Set a field of $this->objectlink, with proper type.
getById($id)
Get properties of a ObjectLink object.
_fetch($id)
Get properties of an object link.
deleteByValues($fk_source, $sourcetype, $fk_target, $targettype, $relationtype=null, $notrigger=0)
Delete object link By Values, not id.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php