dolibarr 23.0.4
api_shipments.class.php
1<?php
2/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
3 * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
6 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2026 Marukome0743
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23use Luracast\Restler\RestException;
24
25require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
26
34{
38 public static $FIELDS = array(
39 'socid',
40 'origin_id',
41 'origin_type',
42 );
43
47 public $shipment;
48
52 public function __construct()
53 {
54 global $db;
55 $this->db = $db;
56 $this->shipment = new Expedition($this->db);
57 }
58
69 public function get($id)
70 {
71 if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
72 throw new RestException(403);
73 }
74
75 $result = $this->shipment->fetch($id);
76 if (!$result) {
77 throw new RestException(404, 'Shipment not found');
78 }
79
80 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
81 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
82 }
83
84 $this->shipment->fetchObjectLinked();
85 return $this->_cleanObjectDatas($this->shipment);
86 }
87
88
89
109 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '', $pagination_data = false)
110 {
111 if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
112 throw new RestException(403);
113 }
114
115 global $hookmanager;
116
117 $obj_ret = array();
118
119 // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
120 $socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
121
122 // If the internal user must only see his customers, force searching by him
123 $search_sale = 0;
124 if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) {
125 $search_sale = DolibarrApiAccess::$user->id;
126 }
127
128 $sql = "SELECT t.rowid";
129 $sql .= " FROM ".MAIN_DB_PREFIX."expedition AS t";
130 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe AS s ON (s.rowid = t.fk_soc)";
131 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
132 $sql .= ' WHERE t.entity IN ('.getEntity('expedition').')';
133 if ($socids) {
134 $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")";
135 }
136 // Search on sale representative
137 if ($search_sale && $search_sale != '-1') {
138 if ($search_sale == -2) {
139 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
140 } elseif ($search_sale > 0) {
141 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
142 }
143 }
144 // Add sql filters
145 if ($sqlfilters) {
146 $parameters = array('sqlfilters' => $sqlfilters, 'apiroute' => 'shipments', 'apimethod' => 'index');
147 $object = new stdClass();
148 $action = 'list';
149 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
150 if ($reshook > 0) {
151 $sql = $hookmanager->resPrint;
152 } elseif ($reshook == 0) {
153 $sql .= $hookmanager->resPrint;
154 }
155 $errormessage = '';
156 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
157 if ($errormessage) {
158 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
159 }
160 }
161
162 //this query will return total shipments with the filters given
163 $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
164
165 $sql .= $this->db->order($sortfield, $sortorder);
166 if ($limit) {
167 if ($page < 0) {
168 $page = 0;
169 }
170 $offset = $limit * $page;
171
172 $sql .= $this->db->plimit($limit + 1, $offset);
173 }
174
175 dol_syslog("API Rest request");
176 $result = $this->db->query($sql);
177
178 if ($result) {
179 $num = $this->db->num_rows($result);
180 $min = min($num, ($limit <= 0 ? $num : $limit));
181 $i = 0;
182 while ($i < $min) {
183 $obj = $this->db->fetch_object($result);
184 $shipment_static = new Expedition($this->db);
185 if ($shipment_static->fetch($obj->rowid)) {
186 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($shipment_static), $properties);
187 }
188 $i++;
189 }
190 } else {
191 throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
192 }
193
194 //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
195 if ($pagination_data) {
196 $totalsResult = $this->db->query($sqlTotals);
197 $total = $this->db->fetch_object($totalsResult)->total;
198
199 $tmp = $obj_ret;
200 $obj_ret = [];
201
202 $obj_ret['data'] = $tmp;
203 $obj_ret['pagination'] = [
204 'total' => (int) $total,
205 'page' => $page, //count starts from 0
206 'page_count' => ceil((int) $total / $limit),
207 'limit' => $limit
208 ];
209 }
210
211 return $obj_ret;
212 }
213
222 public function post($request_data = null)
223 {
224 if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
225 throw new RestException(403, "Insufficiant rights");
226 }
227 // Check mandatory fields
228 $result = $this->_validate($request_data);
229
230 foreach ($request_data as $field => $value) {
231 if ($field === 'caller') {
232 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
233 $this->shipment->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
234 continue;
235 }
236
237 $this->shipment->$field = $this->_checkValForAPI($field, $value, $this->shipment);
238 }
239 if (isset($request_data["lines"])) {
240 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
241
242 $lines = array();
243 foreach ($request_data["lines"] as $line) {
244 $shipmentline = new ExpeditionLigne($this->db);
245
246 $shipmentline->entrepot_id = (int) $line['entrepot_id'];
247 $shipmentline->fk_element = (int) ($line['fk_element'] ?? $line['origin_id']); // example: order id. this->origin is 'commande'
248 $shipmentline->origin_line_id = (int) ($line['fk_elementdet'] ?? $line['origin_line_id']); // example: order id
249 $shipmentline->fk_elementdet = (int) ($line['fk_elementdet'] ?? $line['origin_line_id']); // example: order line id
250 $shipmentline->origin_type = $line['element_type'] ?? $line['origin_type']; // example 'commande' or 'order'
251 $shipmentline->element_type = $line['element_type'] ?? $line['origin_type']; // example 'commande' or 'order'
252 $shipmentline->qty = (float) $line['qty'];
253 $shipmentline->rang = (int) $line['rang'];
254 $array_options = $line['array_options'];
255 if (is_array($array_options)) {
256 $shipmentline->array_options = $array_options;
257 }
258 $detail_batch = $line['detail_batch'];
259 if (is_array($detail_batch) || is_object($detail_batch)) {
260 $shipmentline->detail_batch = $detail_batch;
261 }
262
263 // Expedition::create() expands a kit into its components only when the line carries its product.
264 // Without this, the kit is stored as a parent line with a warehouse and no child lines.
265 $orderline = new OrderLine($this->db);
266 if ($orderline->fetch($shipmentline->fk_elementdet) > 0 && (empty($orderline->product_type) || getDolGlobalString('STOCK_SUPPORTS_SERVICES') || getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES'))) {
267 $shipmentline->fk_product = (int) $orderline->fk_product;
268 }
269
270 $lines[] = $shipmentline;
271 }
272 $this->shipment->lines = $lines;
273 }
274
275 if ($this->shipment->create(DolibarrApiAccess::$user) < 0) {
276 throw new RestException(500, "Error creating shipment", array_merge(array($this->shipment->error), $this->shipment->errors));
277 }
278
279 return $this->shipment->id;
280 }
281
282 // /**
283 // * Get lines of an shipment
284 // *
285 // * @param int $id Id of shipment
286 // *
287 // * @url GET {id}/lines
288 // *
289 // * @return int
290 // */
291 /*
292 public function getLines($id)
293 {
294 if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
295 throw new RestException(403);
296 }
297
298 $result = $this->shipment->fetch($id);
299 if( ! $result ) {
300 throw new RestException(404, 'Shipment not found');
301 }
302
303 if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
304 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
305 }
306 $this->shipment->getLinesArray();
307 $result = array();
308 foreach ($this->shipment->lines as $line) {
309 array_push($result,$this->_cleanObjectDatas($line));
310 }
311 return $result;
312 }
313 */
314
315 // /**
316 // * Add a line to given shipment
317 // *
318 // * @param int $id Id of shipment to update
319 // * @param array $request_data ShipmentLine data
320 // * @phan-param ?array<string,string> $request_data
321 // * @phpstan-param ?array<string,string> $request_data
322 // *
323 // * @url POST {id}/lines
324 // *
325 // * @return int
326 // */
327 /*
328 public function postLine($id, $request_data = null)
329 {
330 if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
331 throw new RestException(403);
332 }
333
334 $result = $this->shipment->fetch($id);
335 if ( ! $result ) {
336 throw new RestException(404, 'Shipment not found');
337 }
338
339 if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
340 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
341 }
342
343 $request_data = (object) $request_data;
344
345 $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml');
346 $request_data->label = sanitizeVal($request_data->label);
347
348 $updateRes = $this->shipment->addline(
349 $request_data->desc,
350 $request_data->subprice,
351 $request_data->qty,
352 $request_data->tva_tx,
353 $request_data->localtax1_tx,
354 $request_data->localtax2_tx,
355 $request_data->fk_product,
356 $request_data->remise_percent,
357 $request_data->info_bits,
358 $request_data->fk_remise_except,
359 'HT',
360 0,
361 $request_data->date_start,
362 $request_data->date_end,
363 $request_data->product_type,
364 $request_data->rang,
365 $request_data->special_code,
366 $fk_parent_line,
367 $request_data->fk_fournprice,
368 $request_data->pa_ht,
369 $request_data->label,
370 $request_data->array_options,
371 $request_data->fk_unit,
372 $request_data->origin,
373 $request_data->origin_id,
374 $request_data->multicurrency_subprice
375 );
376
377 if ($updateRes > 0) {
378 return $updateRes;
379
380 }
381 return false;
382 }*/
383
384 // /**
385 // * Update a line to given shipment
386 // *
387 // * @param int $id Id of shipment to update
388 // * @param int $lineid Id of line to update
389 // * @param array $request_data ShipmentLine data
390 // *
391 // * @url PUT {id}/lines/{lineid}
392 // *
393 // * @return object
394 // */
395 /*
396 public function putLine($id, $lineid, $request_data = null)
397 {
398 if (! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
399 throw new RestException(403);
400 }
401
402 $result = $this->shipment->fetch($id);
403 if ( ! $result ) {
404 throw new RestException(404, 'Shipment not found');
405 }
406
407 if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
408 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
409 }
410
411 $request_data = (object) $request_data;
412
413 $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml');
414 $request_data->label = sanitizeVal($request_data->label);
415
416 $updateRes = $this->shipment->updateline(
417 $lineid,
418 $request_data->desc,
419 $request_data->subprice,
420 $request_data->qty,
421 $request_data->remise_percent,
422 $request_data->tva_tx,
423 $request_data->localtax1_tx,
424 $request_data->localtax2_tx,
425 'HT',
426 $request_data->info_bits,
427 $request_data->date_start,
428 $request_data->date_end,
429 $request_data->product_type,
430 $request_data->fk_parent_line,
431 0,
432 $request_data->fk_fournprice,
433 $request_data->pa_ht,
434 $request_data->label,
435 $request_data->special_code,
436 $request_data->array_options,
437 $request_data->fk_unit,
438 $request_data->multicurrency_subprice
439 );
440
441 if ($updateRes > 0) {
442 $result = $this->get($id);
443 unset($result->line);
444 return $this->_cleanObjectDatas($result);
445 }
446 return false;
447 }*/
448
465 public function deleteLine($id, $lineid)
466 {
467 if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
468 throw new RestException(403);
469 }
470
471 $result = $this->shipment->fetch($id);
472 if (!$result) {
473 throw new RestException(404, 'Shipment not found');
474 }
475
476 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
477 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
478 }
479
480 // TODO Check the lineid $lineid is a line of object
481
482 $updateRes = $this->shipment->deleteLine(DolibarrApiAccess::$user, $lineid);
483 if ($updateRes > 0) {
484 return array(
485 'success' => array(
486 'code' => 200,
487 'message' => 'line ' .$lineid. ' deleted'
488 )
489 );
490 } else {
491 throw new RestException(405, $this->shipment->error);
492 }
493 }
494
504 public function put($id, $request_data = null)
505 {
506 if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
507 throw new RestException(403);
508 }
509
510 $result = $this->shipment->fetch($id);
511 if (!$result) {
512 throw new RestException(404, 'Shipment not found');
513 }
514
515 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
516 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
517 }
518 foreach ($request_data as $field => $value) {
519 if ($field == 'id') {
520 continue;
521 }
522 if ($field === 'caller') {
523 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
524 $this->shipment->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
525 continue;
526 }
527
528 if ($field == 'array_options' && is_array($value)) {
529 foreach ($value as $index => $val) {
530 $this->shipment->array_options[$index] = $this->_checkValForAPI($field, $val, $this->shipment);
531 }
532 continue;
533 }
534 $this->shipment->$field = $this->_checkValForAPI($field, $value, $this->shipment);
535 }
536
537 if ($this->shipment->update(DolibarrApiAccess::$user) > 0) {
538 return $this->get($id);
539 } else {
540 throw new RestException(500, $this->shipment->error);
541 }
542 }
543
553 public function delete($id)
554 {
555 if (!DolibarrApiAccess::$user->hasRight('expedition', 'supprimer')) {
556 throw new RestException(403);
557 }
558 $result = $this->shipment->fetch($id);
559 if (!$result) {
560 throw new RestException(404, 'Shipment not found');
561 }
562
563 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
564 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
565 }
566
567 if (!$this->shipment->delete(DolibarrApiAccess::$user)) {
568 throw new RestException(500, 'Error when deleting shipment : '.$this->shipment->error);
569 }
570
571 return array(
572 'success' => array(
573 'code' => 200,
574 'message' => 'Shipment deleted'
575 )
576 );
577 }
578
598 public function validate($id, $notrigger = 0)
599 {
600 if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
601 throw new RestException(403);
602 }
603 $result = $this->shipment->fetch($id);
604 if (!$result) {
605 throw new RestException(404, 'Shipment not found');
606 }
607
608 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
609 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
610 }
611
612 $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger);
613 if ($result == 0) {
614 throw new RestException(304, 'Error nothing done. May be object is already validated');
615 }
616 if ($result < 0) {
617 throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error);
618 }
619
620 // Reload shipment
621 $result = $this->shipment->fetch($id);
622
623 $this->shipment->fetchObjectLinked();
624 return $this->_cleanObjectDatas($this->shipment);
625 }
626
627
628 // /**
629 // * Classify the shipment as invoiced
630 // *
631 // * @param int $id Id of the shipment
632 // *
633 // * @url POST {id}/setinvoiced
634 // *
635 // * @return int
636 // *
637 // * @throws RestException 400
638 // * @throws RestException 401
639 // * @throws RestException 404
640 // * @throws RestException 405
641 // */
642 /*
643 public function setinvoiced($id)
644 {
645
646 if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
647 throw new RestException(403);
648 }
649 if(empty($id)) {
650 throw new RestException(400, 'Shipment ID is mandatory');
651 }
652 $result = $this->shipment->fetch($id);
653 if( ! $result ) {
654 throw new RestException(404, 'Shipment not found');
655 }
656
657 $result = $this->shipment->classifyBilled(DolibarrApiAccess::$user);
658 if( $result < 0) {
659 throw new RestException(400, $this->shipment->error);
660 }
661 return $result;
662 }
663 */
664
665
666 // /**
667 // * Create a shipment using an existing order.
668 // *
669 // * @param int $orderid Id of the order
670 // *
671 // * @url POST /createfromorder/{orderid}
672 // *
673 // * @return int
674 // * @throws RestException 400
675 // * @throws RestException 401
676 // * @throws RestException 404
677 // * @throws RestException 405
678 // */
679 /*
680 public function createShipmentFromOrder($orderid)
681 {
682
683 require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
684
685 if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
686 throw new RestException(403);
687 }
688 if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
689 throw new RestException(403);
690 }
691 if(empty($proposalid)) {
692 throw new RestException(400, 'Order ID is mandatory');
693 }
694
695 $order = new Commande($this->db);
696 $result = $order->fetch($proposalid);
697 if( ! $result ) {
698 throw new RestException(404, 'Order not found');
699 }
700
701 $result = $this->shipment->createFromOrder($order, DolibarrApiAccess::$user);
702 if( $result < 0) {
703 throw new RestException(405, $this->shipment->error);
704 }
705 $this->shipment->fetchObjectLinked();
706 return $this->_cleanObjectDatas($this->shipment);
707 }
708 */
709
720 public function close($id, $notrigger = 0)
721 {
722 if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
723 throw new RestException(403);
724 }
725
726 $result = $this->shipment->fetch($id);
727 if (!$result) {
728 throw new RestException(404, 'Shipment not found');
729 }
730
731 if (!DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) {
732 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
733 }
734
735 $result = $this->shipment->setClosed();
736 if ($result == 0) {
737 throw new RestException(304, 'Error nothing done. May be object is already closed');
738 }
739 if ($result < 0) {
740 throw new RestException(500, 'Error when closing Order: '.$this->shipment->error);
741 }
742
743 // Reload shipment
744 $result = $this->shipment->fetch($id);
745
746 $this->shipment->fetchObjectLinked();
747
748 return $this->_cleanObjectDatas($this->shipment);
749 }
750
751 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
761 protected function _cleanObjectDatas($object)
762 {
763 // phpcs:enable
764 $object = parent::_cleanObjectDatas($object);
765
766 unset($object->canvas);
767
768 unset($object->thirdparty); // id already returned
769
770 unset($object->note);
771 unset($object->address);
772 unset($object->barcode_type);
773 unset($object->barcode_type_code);
774 unset($object->barcode_type_label);
775 unset($object->barcode_type_coder);
776
777 if (!empty($object->lines) && is_array($object->lines)) {
778 foreach ($object->lines as $line) {
779 if (is_array($line->detail_batch)) {
780 foreach ($line->detail_batch as $keytmp2 => $valtmp2) {
781 unset($line->detail_batch[$keytmp2]->db);
782 }
783 }
784 unset($line->canvas);
785
786 unset($line->tva_tx);
787 unset($line->vat_src_code);
788 unset($line->total_ht);
789 unset($line->total_ttc);
790 unset($line->total_tva);
791 unset($line->total_localtax1);
792 unset($line->total_localtax2);
793 unset($line->remise_percent);
794 }
795 }
796
797 return $object;
798 }
799
807 private function _validate($data)
808 {
809 if ($data === null) {
810 $data = array();
811 }
812 $shipment = array();
813 foreach (Shipments::$FIELDS as $field) {
814 if (!isset($data[$field])) {
815 throw new RestException(400, "$field field missing");
816 }
817 $shipment[$field] = $data[$field];
818 }
819 return $shipment;
820 }
821}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class for API REST v1.
Definition api.class.php:33
_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.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition api.class.php:98
Class to manage lines of shipment.
Class to manage order lines.
close($id, $notrigger=0)
Classify the shipment as invoiced.
_validate($data)
Validate fields before create or update object.
put($id, $request_data=null)
Update shipment general fields (won't touch lines of shipment)
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $sqlfilters='', $properties='', $pagination_data=false)
List shipments.
validate($id, $notrigger=0)
Validate a shipment.
__construct()
Constructor.
post($request_data=null)
Create shipment object.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
deleteLine($id, $lineid)
Get lines of an shipment.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.