22use Luracast\Restler\RestException;
24require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
38 public static $FIELDS = array(
56 $this->commande =
new Commande($this->db);
71 public function get(
$id, $contact_list = -1)
73 return $this->
_fetch(
$id,
'',
'', $contact_list);
90 public function getByRef($ref, $contact_list = -1)
92 return $this->
_fetch(0, $ref,
'', $contact_list);
111 return $this->
_fetch(0,
'', $ref_ext, $contact_list);
127 private function _fetch(
$id, $ref =
'', $ref_ext =
'', $contact_list = -1)
129 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
130 throw new RestException(403);
132 if (empty(
$id) && empty($ref) && empty($ref_ext)) {
133 throw new RestException(400,
'No ID or Ref provided');
135 $result = $this->commande->fetch(
$id, $ref, $ref_ext);
137 throw new RestException(404,
'Order not found');
141 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
144 if ($contact_list > -1) {
146 $tmparray = $this->commande->liste_contact(-1,
'external', $contact_list);
147 if (is_array($tmparray)) {
148 $this->commande->contacts_ids = $tmparray;
150 $tmparray = $this->commande->liste_contact(-1,
'internal', $contact_list);
151 if (is_array($tmparray)) {
152 $this->commande->contacts_ids_internal = $tmparray;
156 $this->commande->fetchObjectLinked();
159 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
160 $this->commande->online_payment_url = getOnlinePaymentUrl(0,
'order', (
string) $this->commande->ref);
189 public function index($sortfield =
"t.rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $thirdparty_ids =
'', $sqlfilters =
'', $sqlfilterlines =
'', $properties =
'', $pagination_data =
false, $loadlinkedobjects = 0)
193 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
194 throw new RestException(403);
200 $socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
204 if (!DolibarrApiAccess::$user->hasRight(
'societe',
'client',
'voir') && !$socids) {
205 $search_sale = DolibarrApiAccess::$user->id;
208 $sql =
"SELECT t.rowid";
209 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande AS t";
210 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe AS s ON (s.rowid = t.fk_soc)";
211 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields AS ef ON (ef.fk_object = t.rowid)";
212 $sql .=
' WHERE t.entity IN ('.getEntity(
'commande').
')';
214 $sql .=
" AND t.fk_soc IN (".$this->db->sanitize($socids).
")";
217 if ($search_sale && $search_sale !=
'-1') {
218 if ($search_sale == -2) {
219 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
220 } elseif ($search_sale > 0) {
221 $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).
")";
224 $parameters = array();
225 $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this->commande);
226 $sql .= $hookmanager->resPrint;
230 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
232 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
236 if ($sqlfilterlines) {
238 $sql .=
" AND EXISTS (SELECT tl.rowid FROM ".MAIN_DB_PREFIX.
"commandedet AS tl WHERE tl.fk_commande = t.rowid";
239 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilterlines, $errormessage);
242 throw new RestException(400,
'Error when validating parameter sqlfilterlines -> '.$errormessage);
247 $sqlTotals = str_replace(
'SELECT t.rowid',
'SELECT count(t.rowid) as total', $sql);
249 $sql .= $this->db->order($sortfield, $sortorder);
254 $offset = $limit * $page;
256 $sql .= $this->db->plimit($limit + 1, $offset);
260 $result = $this->db->query($sql);
263 $num = $this->db->num_rows($result);
264 $min = min($num, ($limit <= 0 ? $num : $limit));
267 $obj = $this->db->fetch_object($result);
268 $commande_static =
new Commande($this->db);
269 if ($commande_static->fetch($obj->rowid) > 0) {
271 $tmparray = $commande_static->liste_contact(-1,
'external', 1);
272 if (is_array($tmparray)) {
273 $commande_static->contacts_ids = $tmparray;
276 if ($loadlinkedobjects) {
278 $commande_static->fetchObjectLinked();
282 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
283 $commande_static->online_payment_url = getOnlinePaymentUrl(0,
'order', (
string) $commande_static->ref);
290 throw new RestException(503,
'Error when retrieve commande list : '.$this->db->lasterror());
294 if ($pagination_data) {
295 $totalsResult = $this->db->query($sqlTotals);
296 $total = $this->db->fetch_object($totalsResult)->total;
301 $obj_ret[
'data'] = $tmp;
302 $obj_ret[
'pagination'] = [
303 'total' => (int) $total,
305 'page_count' => ceil((
int) $total / $limit),
327 public function post($request_data =
null)
330 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
331 throw new RestException(403,
"Insufficiant rights");
338 $socid = (int) $request_data[
'socid'];
339 $thirdpartytmp =
new Societe($this->db);
340 $thirdparty_result = $thirdpartytmp->fetch($socid);
341 if ($thirdparty_result < 1) {
342 throw new RestException(404,
'Third party with id='.$socid.
' not found or not allowed');
345 throw new RestException(404,
'Third party with id='.$thirdpartytmp->id.
' not found or not allowed');
348 foreach ($request_data as $field => $value) {
349 if ($field ===
'caller') {
351 $this->commande->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
354 if ($field ==
'id') {
355 throw new RestException(400,
'Creating with id field is forbidden');
357 if ($field ==
'entity' && ((
int) $value) != ((
int)
$conf->entity)) {
358 throw new RestException(403,
'Creating with entity='.((
int) $value).
' MUST be the same entity='.((
int)
$conf->entity).
' as your API user/key belongs to');
361 $this->commande->$field = $this->
_checkValForAPI($field, $value, $this->commande);
371 if ($this->commande->create(DolibarrApiAccess::$user) < 0) {
372 throw new RestException(500,
"Error creating order", array_merge(array($this->commande->error), $this->commande->errors));
375 return ((
int) $this->commande->id);
392 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
393 throw new RestException(403);
396 $result = $this->commande->fetch(
$id);
398 throw new RestException(404,
'Order not found');
402 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
404 $this->commande->getLinesArray();
406 foreach ($this->commande->lines as $line) {
426 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
427 throw new RestException(403);
430 $result = $this->commande->fetch(
$id);
432 throw new RestException(404,
'Order not found');
436 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
439 $this->commande->fetch_lines();
440 foreach ($this->commande->lines as $line) {
441 if ($line->id == $lineid) {
445 throw new RestException(404,
'Line not found');
463 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
464 throw new RestException(403);
467 $result = $this->commande->fetch(
$id);
469 throw new RestException(404,
'Order not found');
473 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
476 $request_data = (object) $request_data;
478 $request_data->desc =
sanitizeVal($request_data->desc,
'restricthtml');
479 $request_data->label =
sanitizeVal($request_data->label);
481 $updateRes = $this->commande->addline(
483 $request_data->subprice,
485 $request_data->tva_tx,
486 $request_data->localtax1_tx,
487 $request_data->localtax2_tx,
488 $request_data->fk_product,
489 $request_data->remise_percent,
490 $request_data->info_bits,
491 $request_data->fk_remise_except,
492 $request_data->price_base_type ? $request_data->price_base_type :
'HT',
493 $request_data->subprice,
494 $request_data->date_start,
495 $request_data->date_end,
496 $request_data->product_type,
498 $request_data->special_code,
499 $request_data->fk_parent_line,
500 $request_data->fk_fournprice,
501 $request_data->pa_ht,
502 $request_data->label,
503 $request_data->array_options,
504 $request_data->fk_unit,
505 $request_data->origin,
506 $request_data->origin_id,
507 $request_data->multicurrency_subprice,
508 $request_data->ref_ext
511 if ($updateRes > 0) {
514 throw new RestException(400, $this->commande->error);
533 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
534 throw new RestException(403);
537 $result = $this->commande->fetch(
$id);
539 throw new RestException(404,
'Order not found');
543 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
546 $request_data = (object) $request_data;
548 $request_data->desc =
sanitizeVal($request_data->desc,
'restricthtml');
549 $request_data->label =
sanitizeVal($request_data->label);
551 $updateRes = $this->commande->updateline(
554 $request_data->subprice,
556 $request_data->remise_percent,
557 $request_data->tva_tx,
558 $request_data->localtax1_tx,
559 $request_data->localtax2_tx,
560 $request_data->price_base_type ? $request_data->price_base_type :
'HT',
561 $request_data->info_bits,
562 $request_data->date_start,
563 $request_data->date_end,
564 $request_data->product_type,
565 $request_data->fk_parent_line,
567 $request_data->fk_fournprice,
568 $request_data->pa_ht,
569 $request_data->label,
570 $request_data->special_code,
571 $request_data->array_options,
572 $request_data->fk_unit,
573 $request_data->multicurrency_subprice,
575 $request_data->ref_ext,
579 if ($updateRes > 0) {
580 $result = $this->
get(
$id);
581 unset($result->line);
602 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
603 throw new RestException(403);
606 $result = $this->commande->fetch(
$id);
608 throw new RestException(404,
'Order not found');
612 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
615 $updateRes = $this->commande->deleteLine(DolibarrApiAccess::$user, $lineid,
$id);
616 if ($updateRes > 0) {
617 return $this->
get(
$id);
619 throw new RestException(405, $this->commande->error);
639 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
640 throw new RestException(403);
643 $result = $this->commande->fetch(
$id);
645 throw new RestException(404,
'Order not found');
649 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
652 $contacts = $this->commande->liste_contact(-1,
'external', 0, $type);
653 $socpeoples = $this->commande->liste_contact(-1,
'internal', 0, $type);
655 $contacts = array_merge($contacts, $socpeoples);
680 public function postContact(
$id, $contactid, $type, $source =
"external", $notrigger = 0)
682 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
683 throw new RestException(403);
687 if (empty($source)) {
688 throw new RestException(400,
'Source can not be empty');
690 $sql_distinct_source =
"SELECT DISTINCT source";
691 $sql_distinct_source .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact";
692 $sql_distinct_source .=
" WHERE element LIKE 'commande'";
693 $sql_distinct_source .=
" AND source is NOT NULL";
694 $sql_distinct_source .=
" AND active != 0";
695 $source_result = $this->db->query($sql_distinct_source);
696 $source_array = array();
698 if ($source_result) {
699 $num = $this->db->num_rows($source_result);
702 $obj = $this->db->fetch_object($source_result);
703 $source_kind = (
string) $obj->source;
704 array_push($source_array, $source_kind);
709 throw new RestException(503,
'Error when retrieving a list of order contact sources: '.$this->db->lasterror());
711 if (!in_array($source, (array) $source_array,
true)) {
712 throw new RestException(400,
'Combo of Source='.$source.
' and Type='.$type.
' not found in dictionary with active order contact types');
717 throw new RestException(400,
'type can not be empty');
720 $sql_distinct_type =
"SELECT DISTINCT code";
721 $sql_distinct_type .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact";
722 $sql_distinct_type .=
" WHERE element LIKE 'commande'";
723 $sql_distinct_type .=
" AND source='".$this->db->escape($source).
"'";
724 $sql_distinct_type .=
" AND code is NOT NULL";
725 $sql_distinct_type .=
" AND active != 0";
726 $type_result = $this->db->query($sql_distinct_type);
727 $type_array = array();
730 $num = $this->db->num_rows($type_result);
733 $obj = $this->db->fetch_object($type_result);
735 $type_kind = (
string) $obj->code;
736 array_push($type_array, $type_kind);
741 throw new RestException(503,
'Error when retrieving a list of order contact types: '.$this->db->lasterror());
743 if (!in_array($type, (array) $type_array,
true)) {
744 throw new RestException(400,
'Combo of Type='.$type.
' and Source='.$source.
' not found in dictionary with active order contact types');
748 $result = $this->commande->fetch(
$id);
750 throw new RestException(404,
'Order not found');
753 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
756 $result = $this->commande->add_contact($contactid, $type, $source, $notrigger);
759 throw new RestException(400,
'Already exists: Contact='.$contactid.
' is already linked to the order='.
$id.
' as source='.$source.
' and type='.$type);
760 } elseif ($result == -1) {
761 throw new RestException(400,
'Wrong contact='.$contactid);
762 } elseif ($result == -2) {
763 throw new RestException(400,
'Wrong type='.$type);
764 } elseif ($result == -3) {
765 throw new RestException(400,
'Not allowed contacts');
766 } elseif ($result == -4) {
767 throw new RestException(400,
'ErrorCommercialNotAllowedForThirdparty');
768 } elseif ($result == -5) {
769 throw new RestException(400,
'Trigger failed');
770 } elseif ($result == -6) {
771 throw new RestException(400,
'DB_ERROR_RECORD_ALREADY_EXISTS');
772 } elseif ($result == -7) {
773 throw new RestException(400,
'Some other error');
779 'message' =>
'Contact='.$contactid.
' linked to the order='.
$id.
' as '.$source.
' '.$type
804 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
805 throw new RestException(403);
808 $result = $this->commande->fetch(
$id);
810 throw new RestException(404,
'Order not found');
814 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
817 foreach (array(
'internal',
'external') as $source) {
818 $contacts = $this->commande->liste_contact(-1, $source);
819 foreach ($contacts as $contact) {
820 if ($contact[
'id'] == $contactid && $contact[
'code'] == $type) {
821 $result = $this->commande->delete_contact($contact[
'rowid']);
824 throw new RestException(500,
'Error when deleting the contact '.$contact[
'rowid']);
833 'message' =>
'Contact unlinked from order'
848 public function put(
$id, $request_data =
null)
850 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
851 throw new RestException(403);
854 throw new RestException(400,
'No order with id=0 can exist');
856 $result = $this->commande->fetch(
$id);
858 throw new RestException(404,
'Order not found');
862 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
864 foreach ($request_data as $field => $value) {
865 if ($field ==
'id') {
868 if ($field ===
'caller') {
870 $this->commande->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
873 if ($field ==
'array_options' && is_array($value)) {
874 foreach ($value as $index => $val) {
880 $this->commande->$field = $this->
_checkValForAPI($field, $value, $this->commande);
884 if (!empty($this->commande->availability_id)) {
885 if ($this->commande->availability($this->commande->availability_id) < 0) {
886 throw new RestException(400,
'Error while updating availability');
890 if ($this->commande->update(DolibarrApiAccess::$user) > 0) {
891 return $this->
get(
$id);
893 throw new RestException(500, $this->commande->error);
906 public function delete(
$id)
908 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'supprimer')) {
909 throw new RestException(403);
912 throw new RestException(400,
'No order with id=0 can exist');
914 $result = $this->commande->fetch(
$id);
916 throw new RestException(404,
'Order not found');
920 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
923 if ($this->commande->delete(DolibarrApiAccess::$user) <= 0) {
924 throw new RestException(500,
'Error when deleting order : '.$this->commande->error);
930 'message' =>
'Order deleted'
959 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
960 throw new RestException(403);
962 $result = $this->commande->fetch(
$id);
964 throw new RestException(404,
'Order not found');
967 $result = $this->commande->fetch_thirdparty();
970 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
973 $result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
975 throw new RestException(304,
'Error nothing done. May be object is already validated');
978 throw new RestException(500,
'Error when validating Order: '.$this->commande->error);
980 $result = $this->commande->fetch(
$id);
982 $this->commande->fetchObjectLinked();
985 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
986 $this->commande->online_payment_url = getOnlinePaymentUrl(0,
'order', (
string) $this->commande->ref);
1011 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
1012 throw new RestException(403);
1015 throw new RestException(400,
'Order ID is mandatory');
1017 $result = $this->commande->fetch(
$id);
1019 throw new RestException(404,
'Order not found');
1022 $result = $this->commande->set_reopen(DolibarrApiAccess::$user);
1024 throw new RestException(405, $this->commande->error);
1025 } elseif ($result == 0) {
1026 throw new RestException(304);
1048 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
1049 throw new RestException(403);
1052 throw new RestException(400,
'Order ID is mandatory');
1054 $result = $this->commande->fetch(
$id);
1056 throw new RestException(404,
'Order not found');
1059 $result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
1061 throw new RestException(400, $this->commande->error);
1064 $result = $this->commande->fetch(
$id);
1066 throw new RestException(404,
'Order not found');
1070 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1073 $this->commande->fetchObjectLinked();
1090 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
1091 throw new RestException(403);
1093 $result = $this->commande->fetch(
$id);
1095 throw new RestException(404,
'Order not found');
1099 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1102 $result = $this->commande->cloture(DolibarrApiAccess::$user, $notrigger);
1104 throw new RestException(304,
'Error nothing done. May be object is already closed');
1107 throw new RestException(500,
'Error when closing Order: '.$this->commande->error);
1110 $result = $this->commande->fetch(
$id);
1112 throw new RestException(404,
'Order not found');
1120 $this->commande->fetchObjectLinked();
1137 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
1138 throw new RestException(403);
1140 $result = $this->commande->fetch(
$id);
1142 throw new RestException(404,
'Order not found');
1146 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1149 $result = $this->commande->setDraft(DolibarrApiAccess::$user, $idwarehouse);
1151 throw new RestException(304,
'Nothing done. May be object is already closed');
1154 throw new RestException(500,
'Error when closing Order: '.$this->commande->error);
1157 $result = $this->commande->fetch(
$id);
1159 throw new RestException(404,
'Order not found');
1167 $this->commande->fetchObjectLinked();
1189 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1191 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire')) {
1192 throw new RestException(403);
1194 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'creer')) {
1195 throw new RestException(403);
1197 if (empty($proposalid)) {
1198 throw new RestException(400,
'Proposal ID is mandatory');
1201 $propal =
new Propal($this->db);
1202 $result = $propal->fetch($proposalid);
1204 throw new RestException(404,
'Proposal not found');
1207 $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
1209 throw new RestException(405, $this->commande->error);
1211 $this->commande->fetchObjectLinked();
1234 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
1235 if (!DolibarrApiAccess::$user->hasRight(
'expedition',
'lire')) {
1236 throw new RestException(403);
1239 $sql =
"SELECT e.rowid";
1240 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
1241 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"expeditiondet as edet";
1242 $sql .=
" ON e.rowid = edet.fk_expedition";
1243 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"commandedet as cdet";
1244 $sql .=
" ON edet.fk_elementdet = cdet.rowid";
1245 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"commande as c";
1246 $sql .=
" ON cdet.fk_commande = c.rowid";
1247 $sql .=
" WHERE c.rowid = ".((int)
$id);
1248 $sql .=
" GROUP BY e.rowid";
1249 $sql .= $this->db->order(
"e.rowid",
"ASC");
1252 $result = $this->db->query($sql);
1256 $num = $this->db->num_rows($result);
1258 throw new RestException(404,
'Shipments not found ');
1263 $obj = $this->db->fetch_object($result);
1264 $shipment_static =
new Expedition($this->db);
1265 if ($shipment_static->fetch($obj->rowid)) {
1271 throw new RestException(500,
'Error when retrieve shipment list : '.$this->db->lasterror());
1293 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
1294 if (!DolibarrApiAccess::$user->hasRight(
'expedition',
'creer')) {
1295 throw new RestException(403);
1297 if ($warehouse_id <= 0) {
1298 throw new RestException(404,
'Warehouse not found');
1300 $result = $this->commande->fetch(
$id);
1302 throw new RestException(404,
'Order not found');
1305 $shipment->socid = $this->commande->socid;
1306 $shipment->origin_id = $this->commande->id;
1307 $shipment->origin = $this->commande->element;
1308 $result = $shipment->create(DolibarrApiAccess::$user);
1310 throw new RestException(500,
'Error on creating expedition :'.$this->db->lasterror());
1312 foreach ($this->commande->lines as $line) {
1313 $result = $shipment->create_line($warehouse_id, $line->id, $line->qty);
1315 throw new RestException(500,
'Error on creating expedition lines:'.$this->db->lasterror());
1318 return $shipment->id;
1339 unset(
$object->barcode_type_code);
1340 unset(
$object->barcode_type_label);
1341 unset(
$object->barcode_type_coder);
1355 if ($data ===
null) {
1358 $commande = array();
1359 foreach (Orders::$FIELDS as $field) {
1360 if (!isset($data[$field])) {
1361 throw new RestException(400, $field.
" field missing");
1363 $commande[$field] = $data[$field];
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class to manage customers 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.
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.
deleteContact($id, $contactid, $type)
Unlink a contact type of given order.
__construct()
Constructor.
_validate($data)
Validate fields before create or update object.
deleteLine($id, $lineid)
Delete a line of a given order.
getByRef($ref, $contact_list=-1)
Get properties of an order object by ref.
close($id, $notrigger=0)
Close an order (Classify it as "Delivered")
postContact($id, $contactid, $type, $source="external", $notrigger=0)
Add a contact type of given order.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $sqlfilters='', $sqlfilterlines='', $properties='', $pagination_data=false, $loadlinkedobjects=0)
List orders.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
_fetch($id, $ref='', $ref_ext='', $contact_list=-1)
Get properties of an order object.
put($id, $request_data=null)
Update order general fields (won't touch lines of order)
getLines($id)
Get lines of an order.
reopen($id)
Tag the order as validated (opened)
setinvoiced($id)
Classify the order as invoiced.
getContacts($id, $type='')
Get contacts of a given order.
getLine($id, $lineid, $properties='')
Get properties of a line of an order object by id.
postLine($id, $request_data=null)
Add a line to given order.
post($request_data=null)
Create a sale order.
validate($id, $idwarehouse=0, $notrigger=0)
Validate an order.
createOrderFromProposal($proposalid)
Create an order using an existing proposal.
putLine($id, $lineid, $request_data=null)
Update a line to given order.
getOrderShipments($id)
Get the shipments of an order.
settodraft($id, $idwarehouse=-1)
Set an order to draft.
createOrderShipment($id, $warehouse_id)
Create the shipment of an order.
getByRefExt($ref_ext, $contact_list=-1)
Get properties of an order object by ref_ext.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
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