dolibarr 23.0.4
api_supplier_orders.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 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21use Luracast\Restler\RestException;
22
23require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
24
32{
36 public static $FIELDS = array(
37 'socid'
38 );
39
43 public $order;
44
48 public function __construct()
49 {
50 global $db, $conf;
51 $this->db = $db;
52 $this->order = new CommandeFournisseur($this->db);
53 }
54
65 public function get($id)
66 {
67 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "lire")) {
68 throw new RestException(403);
69 }
70
71 $result = $this->order->fetch($id);
72 if (!$result) {
73 throw new RestException(404, 'Supplier order not found');
74 }
75
76 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
77 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
78 }
79
80 $this->order->fetchObjectLinked();
81 return $this->_cleanObjectDatas($this->order);
82 }
83
106 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '', $pagination_data = false)
107 {
108 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "lire")) {
109 throw new RestException(403);
110 }
111
112 $obj_ret = array();
113
114 // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
115 $socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
116
117 // If the internal user must only see his customers, force searching by him
118 $search_sale = 0;
119 if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !empty($socids)) {
120 $search_sale = DolibarrApiAccess::$user->id;
121 }
122
123 $sql = "SELECT t.rowid";
124 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur AS t";
125 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_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
126 if (!empty($product_ids)) {
127 $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; // We need this table joined to the select in order to filter by product
128 }
129 $sql .= ' WHERE t.entity IN ('.getEntity('supplier_order').')';
130 if (!empty($product_ids)) {
131 $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$this->db->sanitize($product_ids).")";
132 }
133 if ($socids) {
134 $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")";
135 }
136 // Filter by status
137 if ($status == 'draft') {
138 $sql .= " AND t.fk_statut IN (0)";
139 }
140 if ($status == 'validated') {
141 $sql .= " AND t.fk_statut IN (1)";
142 }
143 if ($status == 'approved') {
144 $sql .= " AND t.fk_statut IN (2)";
145 }
146 if ($status == 'running') {
147 $sql .= " AND t.fk_statut IN (3)";
148 }
149 if ($status == 'received_start') {
150 $sql .= " AND t.fk_statut IN (4)";
151 }
152 if ($status == 'received_end') {
153 $sql .= " AND t.fk_statut IN (5)";
154 }
155 if ($status == 'cancelled') {
156 $sql .= " AND t.fk_statut IN (6,7)";
157 }
158 if ($status == 'refused') {
159 $sql .= " AND t.fk_statut IN (9)";
160 }
161 // Search on sale representative
162 if ($search_sale && $search_sale != '-1') {
163 if ($search_sale == -2) {
164 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
165 } elseif ($search_sale > 0) {
166 $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).")";
167 }
168 }
169 // Add sql filters
170 if ($sqlfilters) {
171 $errormessage = '';
172 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
173 if ($errormessage) {
174 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
175 }
176 }
177 // Add sql filters for lines
178 if ($sqlfilterlines) {
179 $errormessage = '';
180 $sql .= " AND EXISTS (SELECT tl.rowid FROM ".MAIN_DB_PREFIX."commande_fournisseurdet AS tl WHERE tl.fk_commande = t.rowid";
181 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilterlines, $errormessage);
182 $sql .= ")";
183 if ($errormessage) {
184 throw new RestException(400, 'Error when validating parameter sqlfilterlines -> '.$errormessage);
185 }
186 }
187
188 //this query will return total supplier orders with the filters given
189 $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
190
191 $sql .= $this->db->order($sortfield, $sortorder);
192 if ($limit) {
193 if ($page < 0) {
194 $page = 0;
195 }
196 $offset = $limit * $page;
197
198 $sql .= $this->db->plimit($limit + 1, $offset);
199 }
200
201 $result = $this->db->query($sql);
202 if ($result) {
203 $i = 0;
204 $num = $this->db->num_rows($result);
205 $min = min($num, ($limit <= 0 ? $num : $limit));
206 while ($i < $min) {
207 $obj = $this->db->fetch_object($result);
208 $order_static = new CommandeFournisseur($this->db);
209 if ($order_static->fetch($obj->rowid)) {
210 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($order_static), $properties);
211 }
212 $i++;
213 }
214 } else {
215 throw new RestException(503, 'Error when retrieve supplier order list : '.$this->db->lasterror());
216 }
217
218 //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
219 if ($pagination_data) {
220 $totalsResult = $this->db->query($sqlTotals);
221 $total = $this->db->fetch_object($totalsResult)->total;
222
223 $tmp = $obj_ret;
224 $obj_ret = [];
225
226 $obj_ret['data'] = $tmp;
227 $obj_ret['pagination'] = [
228 'total' => (int) $total,
229 'page' => $page, //count starts from 0
230 'page_count' => (int) ceil((int) $total / $limit),
231 'limit' => $limit
232 ];
233 }
234
235 return $obj_ret;
236 }
237
248 public function post($request_data = null)
249 {
250 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
251 throw new RestException(403, "Insufficiant rights");
252 }
253
254 if (!is_array($request_data)) {
255 $request_data = array();
256 }
257
258 // Check mandatory fields (not using output, only possible exception is important)
259 $this->_validate($request_data);
260
261 foreach ($request_data as $field => $value) {
262 if ($field === 'caller') {
263 // 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
264 $this->order->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
265 continue;
266 }
267
268 $this->order->$field = $this->_checkValForAPI($field, $value, $this->order);
269 }
270 if (!array_keys($request_data, 'date')) {
271 $this->order->date = dol_now();
272 }
273 /* We keep lines as an array
274 if (isset($request_data["lines"])) {
275 $lines = array();
276 foreach ($request_data["lines"] as $line) {
277 array_push($lines, (object) $line);
278 }
279 $this->order->lines = $lines;
280 }*/
281
282 if ($this->order->create(DolibarrApiAccess::$user) < 0) {
283 throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors));
284 }
285 return $this->order->id;
286 }
287
297 public function put($id, $request_data = null)
298 {
299 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
300 throw new RestException(403);
301 }
302
303 $result = $this->order->fetch($id);
304 if (!$result) {
305 throw new RestException(404, 'Supplier order not found');
306 }
307
308 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
309 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
310 }
311
312 foreach ($request_data as $field => $value) {
313 if ($field == 'id') {
314 continue;
315 }
316 if ($field === 'caller') {
317 // 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
318 $this->order->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
319 continue;
320 }
321 if ($field == 'array_options' && is_array($value)) {
322 foreach ($value as $index => $val) {
323 $this->order->array_options[$index] = $this->_checkValForAPI($field, $val, $this->order);
324 }
325 continue;
326 }
327
328 $this->order->$field = $this->_checkValForAPI($field, $value, $this->order);
329 }
330
331 if ($this->order->update(DolibarrApiAccess::$user)) {
332 return $this->get($id);
333 }
334
335 return false;
336 }
337
350 public function postLine($id, $request_data = null)
351 {
352 if (!DolibarrApiAccess::$user->hasRight('fournisseur', 'commande', 'creer')) {
353 throw new RestException(403);
354 }
355
356 $result = $this->order->fetch($id);
357 if (!$result) {
358 throw new RestException(404, 'Supplier order not found');
359 }
360
361 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
362 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
363 }
364
365 $request_data = (object) $request_data;
366
367 $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml');
368
369 $updateRes = $this->order->addline(
370 $request_data->desc,
371 $request_data->subprice,
372 $request_data->qty,
373 $request_data->tva_tx,
374 $request_data->localtax1_tx,
375 $request_data->localtax2_tx,
376 $request_data->fk_product,
377 $request_data->fk_prod_fourn_price,
378 $request_data->ref_fourn,
379 $request_data->remise_percent,
380 $request_data->price_base_type ? $request_data->price_base_type : 'HT',
381 $request_data->pu_ttc,
382 $request_data->product_type,
383 $request_data->info_bits,
384 $request_data->notrigger,
385 $request_data->date_start,
386 $request_data->date_end,
387 $request_data->array_options,
388 $request_data->fk_unit,
389 $request_data->multicurrency_subprice,
390 $request_data->origin,
391 $request_data->origin_id,
392 // -1 is the "append at the end" value of addline(). An absent rang is null, which empty() turns into 0,
393 // so without this every line added through the API is stored with rang 0 instead of being appended.
394 isset($request_data->rang) ? $request_data->rang : -1,
395 $request_data->special_code
396 );
397
398 if ($updateRes > 0) {
399 return $updateRes;
400 } else {
401 throw new RestException(400, $this->order->error);
402 }
403 }
404
419 public function getContacts($id, $source, $type = '')
420 {
421 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "lire")) {
422 throw new RestException(403);
423 }
424
425 $result = $this->order->fetch($id);
426 if (!$result) {
427 throw new RestException(404, 'Supplier order not found');
428 }
429
430 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
431 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
432 }
433 $contacts = array();
434
435 if ($source == 'all' || $source == 'external') {
436 $tmpContacts = $this->order->liste_contact(-1, 'external', 0, $type);
437 $contacts = array_merge($contacts, $tmpContacts);
438 }
439
440 if ($source == 'all' || $source == 'internal') {
441 $tmpContacts = $this->order->liste_contact(-1, 'internal', 0, $type);
442 $contacts = array_merge($contacts, $tmpContacts);
443 }
444
445 return $contacts;
446 }
447
464 public function postContact($id, $contactid, $type, $source)
465 {
466 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer")) {
467 throw new RestException(403);
468 }
469
470 $result = $this->order->fetch($id);
471 if (!$result) {
472 throw new RestException(404, 'Supplier order not found');
473 }
474
475 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
476 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
477 }
478
479 $result = $this->order->add_contact($contactid, $type, $source);
480
481 if ($result < 0) {
482 throw new RestException(500, 'Error when added the contact');
483 }
484
485 if ($result == 0) {
486 throw new RestException(304, 'contact already added');
487 }
488
489 return array(
490 'success' => array(
491 'code' => 200,
492 'message' => 'Contact linked to the order'
493 )
494 );
495 }
496
515 public function deleteContact($id, $contactid, $type, $source)
516 {
517 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer")) {
518 throw new RestException(403);
519 }
520
521 $result = $this->order->fetch($id);
522 if (!$result) {
523 throw new RestException(404, 'Supplier order not found');
524 }
525
526 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
527 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
528 }
529
530 $contacts = $this->order->liste_contact(-1, $source, 0, $type);
531
532 $contactToUnlink = 0;
533 foreach ($contacts as $contact) {
534 if ($contact['id'] == $contactid && $contact['code'] == $type) {
535 $contactToUnlink = $contact['rowid'];
536 break;
537 }
538 }
539
540 if ($contactToUnlink == 0) {
541 throw new RestException(404, 'Linked contact not found');
542 }
543
544 $result = $this->order->delete_contact($contact['rowid']);
545
546 if (!$result) {
547 throw new RestException(500, 'Error when deleted the contact');
548 }
549
550 return array(
551 'success' => array(
552 'code' => 200,
553 'message' => 'Contact unlinked from supplier order'
554 )
555 );
556 }
557
566 public function delete($id)
567 {
568 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "supprimer")) {
569 throw new RestException(403);
570 }
571 $result = $this->order->fetch($id);
572 if (!$result) {
573 throw new RestException(404, 'Supplier order not found');
574 }
575
576 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
577 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
578 }
579
580 if ($this->order->delete(DolibarrApiAccess::$user) < 0) {
581 throw new RestException(500, 'Error when deleting order');
582 }
583
584 return array(
585 'success' => array(
586 'code' => 200,
587 'message' => 'Supplier order deleted'
588 )
589 );
590 }
591
592
614 public function validate($id, $idwarehouse = 0, $notrigger = 0)
615 {
616 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
617 throw new RestException(403);
618 }
619 $result = $this->order->fetch($id);
620 if (!$result) {
621 throw new RestException(404, 'Order not found');
622 }
623
624 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
625 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
626 }
627
628 $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
629 if ($result == 0) {
630 throw new RestException(304, 'Error nothing done. May be object is already validated');
631 }
632 if ($result < 0) {
633 throw new RestException(500, 'Error when validating Order: '.$this->order->error);
634 }
635
636 return array(
637 'success' => array(
638 'code' => 200,
639 'message' => 'Order validated (Ref='.$this->order->ref.')'
640 )
641 );
642 }
643
665 public function approve($id, $idwarehouse = 0, $secondlevel = 0)
666 {
667 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
668 throw new RestException(403);
669 }
670 $result = $this->order->fetch($id);
671 if (!$result) {
672 throw new RestException(404, 'Order not found');
673 }
674
675 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
676 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
677 }
678
679 $result = $this->order->approve(DolibarrApiAccess::$user, $idwarehouse, $secondlevel);
680 if ($result == 0) {
681 throw new RestException(304, 'Error nothing done. May be object is already approved');
682 }
683 if ($result < 0) {
684 throw new RestException(500, 'Error when approve Order: '.$this->order->error);
685 }
686
687 return array(
688 'success' => array(
689 'code' => 200,
690 'message' => 'Order approved (Ref='.$this->order->ref.')'
691 )
692 );
693 }
694
695
719 public function makeOrder($id, $date, $method, $comment = '')
720 {
721 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
722 throw new RestException(403);
723 }
724 $result = $this->order->fetch($id);
725 if (!$result) {
726 throw new RestException(404, 'Order not found');
727 }
728
729 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
730 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
731 }
732
733 $result = $this->order->commande(DolibarrApiAccess::$user, $date, $method, $comment);
734 if ($result == 0) {
735 throw new RestException(304, 'Error nothing done. May be object is already sent');
736 }
737 if ($result < 0) {
738 throw new RestException(500, 'Error when sending Order: '.$this->order->error);
739 }
740
741 return array(
742 'success' => array(
743 'code' => 200,
744 'message' => 'Order sent (Ref='.$this->order->ref.')'
745 )
746 );
747 }
748
786 public function receiveOrder($id, $closeopenorder, $comment, $lines)
787 {
788 if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "creer") && !DolibarrApiAccess::$user->hasRight("supplier_order", "creer")) {
789 throw new RestException(403);
790 }
791 $result = $this->order->fetch($id);
792 if (!$result) {
793 throw new RestException(404, 'Order not found');
794 }
795
796 if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
797 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
798 }
799
800 foreach ($lines as $line) {
801 $lineObj = (object) $line;
802
803 $result = $this->order->dispatchProduct(
804 DolibarrApiAccess::$user,
805 $lineObj->fk_product,
806 $lineObj->qty,
807 $lineObj->warehouse,
808 $lineObj->price,
809 $lineObj->comment,
810 $lineObj->eatby,
811 $lineObj->sellby,
812 $lineObj->batch,
813 (int) $lineObj->id,
814 $lineObj->notrigger
815 );
816
817 if ($result < 0) {
818 throw new RestException(500, 'Error dispatch order line '.$lineObj->id.': '.$this->order->error);
819 }
820 }
821
822 $result = $this->order->calcAndSetStatusDispatch(DolibarrApiAccess::$user, $closeopenorder, $comment);
823
824 if ($result == 0) {
825 throw new RestException(304, 'Error nothing done. May be object is already dispatched');
826 }
827 if ($result < 0) {
828 throw new RestException(500, 'Error when receivce order: '.$this->order->error);
829 }
830
831 return array(
832 'success' => array(
833 'code' => 200,
834 'message' => 'Order received (Ref='.$this->order->ref.')'
835 )
836 );
837 }
838
839 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
849 protected function _cleanObjectDatas($object)
850 {
851 // phpcs:enable
852 $object = parent::_cleanObjectDatas($object);
853
854 unset($object->rowid);
855 unset($object->barcode_type);
856 unset($object->barcode_type_code);
857 unset($object->barcode_type_label);
858 unset($object->barcode_type_coder);
859
860 return $object;
861 }
862
871 private function _validate($data)
872 {
873 if ($data === null) {
874 $data = array();
875 }
876 $order = array();
877 foreach (SupplierOrders::$FIELDS as $field) {
878 if (!isset($data[$field])) {
879 throw new RestException(400, "$field field missing");
880 }
881 $order[$field] = $data[$field];
882 }
883 return $order;
884 }
885}
$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 to manage predefined suppliers products.
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
validate($id, $idwarehouse=0, $notrigger=0)
Validate an order.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $product_ids='', $status='', $sqlfilters='', $sqlfilterlines='', $properties='', $pagination_data=false)
List orders.
put($id, $request_data=null)
Update supplier order.
post($request_data=null)
Create supplier order object.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
postLine($id, $request_data=null)
Add a line to a given supplier order.
deleteContact($id, $contactid, $type, $source)
Unlink a contact type of given supplier order.
makeOrder($id, $date, $method, $comment='')
Sends an order to the vendor.
postContact($id, $contactid, $type, $source)
Add a contact type of given supplier order.
getContacts($id, $source, $type='')
Get contacts of given supplier order.
_validate($data)
Validate fields before create or update object.
approve($id, $idwarehouse=0, $secondlevel=0)
Approve an order.
receiveOrder($id, $closeopenorder, $comment, $lines)
Receives the order, dispatches products.
dol_now($mode='gmt')
Return date for now.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.