22use Luracast\Restler\RestException;
24require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
25require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40 public static $FIELDS = array(
71 public function get(
$id)
73 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"lire")) {
74 throw new RestException(403);
77 $result = $this->order->fetch(
$id);
79 throw new RestException(404,
'Supplier order not found');
83 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
86 $this->order->fetchObjectLinked();
117 public function index($sortfield =
"t.rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $thirdparty_ids =
'', $product_ids =
'', $status =
'', $sqlfilters =
'', $sqlfilterlines =
'', $properties =
'', $pagination_data =
false)
119 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"lire")) {
120 throw new RestException(403);
126 $socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
130 if (!DolibarrApiAccess::$user->hasRight(
"societe",
"client",
"voir") && !empty($socids)) {
131 $search_sale = DolibarrApiAccess::$user->id;
134 $sql =
"SELECT t.rowid";
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur AS t";
136 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseur_extrafields AS ef ON (ef.fk_object = t.rowid)";
137 if (!empty($product_ids)) {
138 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd";
140 $sql .=
' WHERE t.entity IN ('.getEntity(
'supplier_order').
')';
141 if (!empty($product_ids)) {
142 $sql .=
" AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$this->db->sanitize($product_ids).
")";
145 $sql .=
" AND t.fk_soc IN (".$this->db->sanitize($socids).
")";
148 if ((
string) $status !==
'' && !in_array($status, array(
'draft',
'validated',
'approved',
'running',
'received_start',
'received_end',
'cancelled',
'refused'),
true)) {
149 throw new RestException(400,
"Bad value for parameter status. Expected one of: draft, validated, approved, running, received_start, received_end, cancelled, refused");
152 if ($status ==
'draft') {
153 $sql .=
" AND t.fk_statut IN (0)";
155 if ($status ==
'validated') {
156 $sql .=
" AND t.fk_statut IN (1)";
158 if ($status ==
'approved') {
159 $sql .=
" AND t.fk_statut IN (2)";
161 if ($status ==
'running') {
162 $sql .=
" AND t.fk_statut IN (3)";
164 if ($status ==
'received_start') {
165 $sql .=
" AND t.fk_statut IN (4)";
167 if ($status ==
'received_end') {
168 $sql .=
" AND t.fk_statut IN (5)";
170 if ($status ==
'cancelled') {
171 $sql .=
" AND t.fk_statut IN (6,7)";
173 if ($status ==
'refused') {
174 $sql .=
" AND t.fk_statut IN (9)";
177 if ($search_sale && $search_sale !=
'-1') {
178 if ($search_sale == -2) {
179 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
't.fk_soc', 0, 1);
180 } elseif ($search_sale > 0) {
181 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
't.fk_soc', (
int) $search_sale);
189 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
193 if ($sqlfilterlines) {
195 $sql .=
" AND EXISTS (SELECT tl.rowid FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet AS tl WHERE tl.fk_commande = t.rowid";
199 throw new RestException(400,
'Error when validating parameter sqlfilterlines -> '.$errormessage);
204 $sqlTotals = str_replace(
'SELECT t.rowid',
'SELECT count(t.rowid) as total', $sql);
206 $sql .= $this->db->order($sortfield, $sortorder);
211 $offset = $limit * $page;
213 $sql .= $this->db->plimit($limit + 1, $offset);
216 $result = $this->db->query($sql);
219 $num = $this->db->num_rows($result);
220 $min = min($num, ($limit <= 0 ? $num : $limit));
222 $obj = $this->db->fetch_object($result);
224 if ($order_static->fetch($obj->rowid)) {
230 throw new RestException(503,
'Error when retrieve supplier order list : '.$this->db->lasterror());
234 if ($pagination_data) {
235 $totalsResult = $this->db->query($sqlTotals);
236 $total = $this->db->fetch_object($totalsResult)->total;
241 $obj_ret[
'data'] = $tmp;
242 $obj_ret[
'pagination'] = [
243 'total' => (int) $total,
245 'page_count' => (
int) ceil((
int) $total / $limit),
265 public function post($request_data =
null)
267 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
268 throw new RestException(403,
"Insufficiant rights");
271 if (!is_array($request_data)) {
272 $request_data = array();
278 foreach ($request_data as $field => $value) {
279 if ($field ===
'caller') {
281 $this->order->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
285 $this->order->$field = $this->
_checkValForAPI($field, $value, $this->order);
287 if (!array_keys($request_data,
'date')) {
288 $this->order->date =
dol_now();
299 if ($this->order->create(DolibarrApiAccess::$user) < 0) {
300 throw new RestException(500,
"Error creating order", array_merge(array($this->order->error), $this->order->errors));
302 return $this->order->id;
316 public function put(
$id, $request_data =
null)
318 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
319 throw new RestException(403);
322 $result = $this->order->fetch(
$id);
324 throw new RestException(404,
'Supplier order not found');
328 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
331 foreach ($request_data as $field => $value) {
332 if ($field ==
'id') {
335 if ($field ===
'caller') {
337 $this->order->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
340 if ($field ==
'array_options' && is_array($value)) {
341 foreach ($value as $index => $val) {
347 $this->order->$field = $this->
_checkValForAPI($field, $value, $this->order);
350 if ($this->order->update(DolibarrApiAccess::$user)) {
351 return $this->
get(
$id);
373 if (!DolibarrApiAccess::$user->hasRight(
'fournisseur',
'commande',
'creer')) {
374 throw new RestException(403);
377 $result = $this->order->fetch(
$id);
379 throw new RestException(404,
'Supplier order not found');
383 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
386 $request_data = (object) $request_data;
388 $request_data->desc =
sanitizeVal($request_data->desc,
'restricthtml');
390 $updateRes = $this->order->addline(
392 $request_data->subprice,
394 $request_data->tva_tx,
395 $request_data->localtax1_tx,
396 $request_data->localtax2_tx,
397 $request_data->fk_product,
398 $request_data->fk_prod_fourn_price,
399 $request_data->ref_fourn,
400 $request_data->remise_percent,
401 $request_data->price_base_type ? $request_data->price_base_type :
'HT',
402 $request_data->pu_ttc,
403 $request_data->product_type,
404 $request_data->info_bits,
405 $request_data->notrigger,
406 $request_data->date_start,
407 $request_data->date_end,
408 $request_data->array_options,
409 $request_data->fk_unit,
410 $request_data->multicurrency_subprice,
411 $request_data->origin,
412 $request_data->origin_id,
414 $request_data->special_code
417 if ($updateRes > 0) {
420 throw new RestException(400, $this->order->errorsToString());
459 if (!DolibarrApiAccess::$user->hasRight(
'fournisseur',
'commande',
'creer')) {
460 throw new RestException(403,
'Write permission is required');
464 throw new RestException(409,
'Only draft supplier orders accept line changes');
467 $includingtax = isset($request_data[
'subprice_ttc']) || (!isset($request_data[
'subprice']) && $line->wasEnteredIncludingTax());
468 if (isset($request_data[
'multicurrency_subprice'])) {
470 $includingtax =
false;
471 } elseif ($includingtax || isset($request_data[
'subprice'])) {
472 $line->multicurrency_subprice = 0;
474 $vatrate = $line->tva_tx;
475 if (!isset($request_data[
'tva_tx']) && !empty($line->vat_src_code)) {
476 $vatrate .=
' ('.$line->vat_src_code.
')';
478 if ($this->order->fetch_thirdparty() <= 0) {
479 throw new RestException(500,
'Unable to load supplier for tax calculations');
481 $result = $this->order->updateline(
482 $lineid, $line->desc, $includingtax ? $line->subprice_ttc : $line->subprice,
483 $line->qty, $line->remise_percent, $vatrate, $line->localtax1_tx, $line->localtax2_tx,
484 $includingtax ?
'TTC' :
'HT', $line->info_bits, $line->product_type, 0,
485 (int) $line->date_start, (
int) $line->date_end, $line->array_options, $line->fk_unit,
486 $line->multicurrency_subprice, $line->ref_supplier
489 throw new RestException(400, $this->order->errorsToString());
493 if ($line->fetch($lineid) <= 0) {
494 throw new RestException(500,
'Failed to reload the updated line');
523 if (empty($lineid)) {
524 throw new RestException(400,
'Line ID is mandatory');
527 if (!DolibarrApiAccess::$user->hasRight(
'fournisseur',
'commande',
'creer')) {
528 throw new RestException(403);
535 throw new RestException(405,
'Supplier order must be in draft status to delete lines');
538 $updateRes = $this->order->deleteLine((
int) $lineid);
539 if ($updateRes > 0) {
543 'message' =>
'line '.$lineid.
' deleted'
547 throw new RestException(405, $this->order->errorsToString());
560 if (!is_array($request_data) || empty($request_data)) {
561 throw new RestException(400,
'A non-empty object of line changes is required');
563 $pricefields = array_intersect(array_keys($request_data), array(
'subprice',
'subprice_ttc',
'multicurrency_subprice'));
564 if (count($pricefields) > 1) {
565 throw new RestException(400,
'Give only one unit price: subprice, subprice_ttc or multicurrency_subprice');
568 $allowed = array(
'desc',
'subprice',
'subprice_ttc',
'qty',
'remise_percent',
'tva_tx',
'localtax1_tx',
'localtax2_tx',
'date_start',
'date_end',
'array_options',
'fk_unit',
'multicurrency_subprice',
'ref_supplier');
569 foreach ($request_data as $field => $value) {
570 if (!in_array($field, $allowed,
true)) {
571 throw new RestException(400,
'Unsupported line field: '.$field);
573 if ($field ===
'array_options') {
574 if (!is_array($value)) {
575 throw new RestException(400,
'array_options must be an object');
577 foreach ($value as $key => $optional) {
580 } elseif (in_array($field, array(
'date_start',
'date_end',
'fk_unit'),
true)) {
581 if ($value !==
null && (!is_numeric($value) || (
int) $value != $value || $value < ($field ===
'fk_unit' ? 1 : 0))) {
582 throw new RestException(400,
'Expected a valid integer or null for '.$field);
584 $line->$field = $value ===
null ? null : (int) $value;
585 } elseif (in_array($field, array(
'desc',
'ref_supplier'),
true)) {
586 if (!is_string($value)) {
587 throw new RestException(400,
'Expected a string for '.$field);
590 } elseif (!is_numeric($value) || !is_finite((
float) $value)) {
591 throw new RestException(400,
'Expected a finite numeric value for '.$field);
593 $line->$field = $value;
596 if ((
float) $line->qty == 0) {
597 throw new RestException(400,
'Quantity must not be zero');
599 if ($line->date_start && $line->date_end && $line->date_start > $line->date_end) {
600 throw new RestException(400,
'Start date must not be later than end date');
613 if (!DolibarrApiAccess::$user->hasRight(
'fournisseur',
'commande',
'lire')) {
614 throw new RestException(403,
'Read permission is required');
616 if ($this->order->fetch(
$id) <= 0) {
617 throw new RestException(404,
'Supplier order not found');
619 if (!static::_checkAccessToResource(
'fournisseur', $this->order->id,
'commande_fournisseur',
'commande')) {
620 throw new RestException(403,
'Access denied to supplier order');
634 foreach ($this->order->lines as $line) {
635 if ((
int) $line->id === (
int) $lineid) {
639 throw new RestException(404,
'Line not found in this supplier order');
660 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"lire")) {
661 throw new RestException(403);
664 $result = $this->order->fetch(
$id);
666 throw new RestException(404,
'Supplier order not found');
670 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
674 if ($source ==
'all' || $source ==
'external') {
675 $tmpContacts = $this->order->liste_contact(-1,
'external', 0, $type);
676 $contacts = array_merge($contacts, $tmpContacts);
679 if ($source ==
'all' || $source ==
'internal') {
680 $tmpContacts = $this->order->liste_contact(-1,
'internal', 0, $type);
681 $contacts = array_merge($contacts, $tmpContacts);
707 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer")) {
708 throw new RestException(403);
711 $result = $this->order->fetch(
$id);
713 throw new RestException(404,
'Supplier order not found');
717 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
720 $result = $this->order->add_contact($contactid, $type, $source);
723 throw new RestException(500,
'Error when added the contact');
727 throw new RestException(304,
'contact already added');
733 'message' =>
'Contact linked to the order'
760 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer")) {
761 throw new RestException(403);
764 $result = $this->order->fetch(
$id);
766 throw new RestException(404,
'Supplier order not found');
770 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
773 $contacts = $this->order->liste_contact(-1, $source, 0, $type);
775 $contactToUnlink = 0;
776 foreach ($contacts as $contact) {
777 if ($contact[
'id'] == $contactid && $contact[
'code'] == $type) {
778 $contactToUnlink = $contact[
'rowid'];
783 if ($contactToUnlink == 0) {
784 throw new RestException(404,
'Linked contact not found');
787 $result = $this->order->delete_contact($contactToUnlink);
790 throw new RestException(500,
'Error when deleting the contact');
796 'message' =>
'Contact unlinked from supplier order'
811 public function delete(
$id)
813 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"supprimer")) {
814 throw new RestException(403);
816 $result = $this->order->fetch(
$id);
818 throw new RestException(404,
'Supplier order not found');
822 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
825 if ($this->order->delete(DolibarrApiAccess::$user) < 0) {
826 throw new RestException(500,
'Error when deleting order');
832 'message' =>
'Supplier order deleted'
863 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
864 throw new RestException(403);
866 $result = $this->order->fetch(
$id);
868 throw new RestException(404,
'Order not found');
872 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
875 $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
877 throw new RestException(304,
'Error nothing done. May be object is already validated');
880 throw new RestException(500,
'Error when validating Order: '.$this->order->errorsToString());
886 'message' =>
'Order validated (Ref='.$this->order->ref.
')'
912 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
913 throw new RestException(403);
915 $result = $this->order->fetch(
$id);
917 throw new RestException(404,
'Order not found');
921 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
925 $status = (int) $this->order->status;
927 throw new RestException(405,
'Only validated or approved supplier orders can be set back to draft');
932 $allowed = DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"commander");
934 $allowed = (DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"approuver")
935 && (!
getDolGlobalString(
'SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY') || DolibarrApiAccess::$user->id == $this->order->user_approve_id))
936 || (DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"approve2") &&
getDolGlobalString(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')
937 && (!
getDolGlobalString(
'SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY') || DolibarrApiAccess::$user->id == $this->order->user_approve_id2));
940 throw new RestException(403,
'Not allowed to set this supplier order back to draft');
943 $result = $this->order->setReopen(DolibarrApiAccess::$user);
945 throw new RestException(500,
'Error when setting Order to draft: '.$this->order->errorsToString());
951 'message' =>
'Order set to draft (Ref='.$this->order->ref.
')'
979 public function approve(
$id, $idwarehouse = 0, $secondlevel = 0)
981 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
982 throw new RestException(403);
984 $result = $this->order->fetch(
$id);
986 throw new RestException(404,
'Order not found');
990 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
993 $result = $this->order->approve(DolibarrApiAccess::$user, $idwarehouse, $secondlevel);
995 throw new RestException(304,
'Error nothing done. May be object is already approved');
998 throw new RestException(500,
'Error when approve Order: '.$this->order->errorsToString());
1004 'message' =>
'Order approved (Ref='.$this->order->ref.
')'
1038 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"approuver")) {
1039 throw new RestException(403);
1041 $result = $this->order->fetch(
$id);
1043 throw new RestException(404,
'Order not found');
1047 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1051 throw new RestException(405,
'Only validated supplier orders waiting for approval can be refused');
1054 if ((
string) $comment !==
'') {
1055 $this->order->refuse_note = $comment;
1058 $result = $this->order->refuse(DolibarrApiAccess::$user);
1060 throw new RestException(500,
'Error when refusing Order: '.$this->order->errorsToString());
1066 'message' =>
'Order refused (Ref='.$this->order->ref.
')'
1099 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
1100 throw new RestException(403);
1102 $result = $this->order->fetch(
$id);
1104 throw new RestException(404,
'Order not found');
1108 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1111 $result = $this->order->commande(DolibarrApiAccess::$user, $date, $method, $comment);
1113 throw new RestException(304,
'Error nothing done. May be object is already sent');
1116 throw new RestException(500,
'Error when sending Order: '.$this->order->errorsToString());
1122 'message' =>
'Order sent (Ref='.$this->order->ref.
')'
1156 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"commander")) {
1157 throw new RestException(403);
1159 $result = $this->order->fetch(
$id);
1161 throw new RestException(404,
'Order not found');
1165 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1170 throw new RestException(405,
'Only approved supplier orders can be canceled');
1173 if ((
string) $comment !==
'') {
1174 $this->order->cancel_note = $comment;
1177 $result = $this->order->cancel(DolibarrApiAccess::$user);
1179 throw new RestException(500,
'Error when canceling Order: '.$this->order->errorsToString());
1185 'message' =>
'Order canceled (Ref='.$this->order->ref.
')'
1231 if (!DolibarrApiAccess::$user->hasRight(
"fournisseur",
"commande",
"creer") && !DolibarrApiAccess::$user->hasRight(
"supplier_order",
"creer")) {
1232 throw new RestException(403);
1234 $result = $this->order->fetch(
$id);
1236 throw new RestException(404,
'Order not found');
1240 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1243 foreach ($lines as $line) {
1244 $lineObj = (object) $line;
1246 $result = $this->order->dispatchProduct(
1247 DolibarrApiAccess::$user,
1248 $lineObj->fk_product,
1250 $lineObj->warehouse,
1261 throw new RestException(500,
'Error dispatch order line '.$lineObj->id.
': '.$this->order->errorsToString());
1265 $result = $this->order->calcAndSetStatusDispatch(DolibarrApiAccess::$user, $closeopenorder, $comment);
1268 throw new RestException(304,
'Error nothing done. May be object is already dispatched');
1271 throw new RestException(500,
'Error when receivce order: '.$this->order->errorsToString());
1277 'message' =>
'Order received (Ref='.$this->order->ref.
')'
1299 unset(
$object->barcode_type_code);
1300 unset(
$object->barcode_type_label);
1301 unset(
$object->barcode_type_coder);
1316 if ($data ===
null) {
1320 foreach (SupplierOrders::$FIELDS as $field) {
1321 if (!isset($data[$field])) {
1322 throw new RestException(400,
"$field field missing");
1324 $order[$field] = $data[$field];
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage predefined suppliers products.
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
const STATUS_ACCEPTED
Accepted.
Class to manage line orders.
_checkValExtrafieldsForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $parenttableforentity='')
Check access by user to a given resource.
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.
putLine($id, $lineid, $request_data=null)
Update selected fields of a draft supplier order line.
loadOrderForOperation($id)
Load an authorised order without sanitising its live database handle.
deleteLine($id, $lineid)
Deletes a line of a given draft supplier order.
__construct()
Constructor.
put($id, $request_data=null)
Update supplier order.
settodraft($id)
Set a validated or approved order back to draft.
loadLineForOperation($id, $lineid)
Load the complete line after checking its parent and ownership.
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.
prepareLineUpdate($line, $request_data)
Prepare a partial update without changing the original line or writing data.
deleteContact($id, $contactid, $type, $source)
Unlink a contact type of given supplier order.
makeOrder($id, $date, $method, $comment='')
Sends an order to the vendor.
refuse($id, $comment='')
Refuse a validated order that is waiting for approval.
postContact($id, $contactid, $type, $source)
Add a contact type of given supplier order.
getLine($id, $lineid)
Get one supplier order line after checking access to its parent.
cancel($id, $comment='')
Cancel an approved order that has not been sent to the vendor yet.
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, $forbiddenfields=array())
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.