27if (!defined(
'NOCSRFCHECK')) {
28 define(
'NOCSRFCHECK',
'1');
30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
42if (!defined(
"NOLOGIN")) {
43 define(
"NOLOGIN",
'1');
45if (!defined(
"NOSESSION")) {
46 define(
"NOSESSION",
'1');
49require
'../main.inc.php';
50require_once NUSOAP_PATH.
'/nusoap.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
53require_once DOL_DOCUMENT_ROOT.
"/commande/class/commande.class.php";
60dol_syslog(
"Call Dolibarr webservices interfaces");
66 $langs->load(
"admin");
67 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
68 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
69 print $langs->trans(
"ToActivateModule");
74$server =
new nusoap_server();
75$server->soap_defencoding =
'UTF-8';
76$server->decode_utf8 =
false;
77$ns =
'http://www.dolibarr.org/ns/';
78$server->configureWSDL(
'WebServicesDolibarrOrder', $ns);
80$server->wsdl->schemaTargetNamespace = $ns;
84$server->wsdl->addComplexType(
91 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
92 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
93 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
94 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
95 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string')
99$server->wsdl->addComplexType(
106 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
107 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
112 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
113 'type' => array(
'name' =>
'type',
'type' =>
'xsd:int'),
114 'fk_commande' => array(
'name' =>
'fk_commande',
'type' =>
'xsd:int'),
115 'fk_parent_line' => array(
'name' =>
'fk_parent_line',
'type' =>
'xsd:int'),
116 'desc' => array(
'name' =>
'desc',
'type' =>
'xsd:string'),
117 'qty' => array(
'name' =>
'qty',
'type' =>
'xsd:double'),
118 'price' => array(
'name' =>
'price',
'type' =>
'xsd:double'),
119 'unitprice' => array(
'name' =>
'unitprice',
'type' =>
'xsd:double'),
120 'vat_rate' => array(
'name' =>
'vat_rate',
'type' =>
'xsd:double'),
122 'remise' => array(
'name' =>
'remise',
'type' =>
'xsd:double'),
123 'remise_percent' => array(
'name' =>
'remise_percent',
'type' =>
'xsd:double'),
125 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
126 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
127 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
129 'date_start' => array(
'name' =>
'date_start',
'type' =>
'xsd:date'),
130 'date_end' => array(
'name' =>
'date_end',
'type' =>
'xsd:date'),
133 'product_id' => array(
'name' =>
'product_id',
'type' =>
'xsd:int'),
134 'product_ref' => array(
'name' =>
'product_ref',
'type' =>
'xsd:string'),
135 'product_label' => array(
'name' =>
'product_label',
'type' =>
'xsd:string'),
136 'product_desc' => array(
'name' =>
'product_desc',
'type' =>
'xsd:string')
139$elementtype =
'commandedet';
144$extrafields->fetch_name_optionals_label($elementtype,
true);
145$extrafield_line_array =
null;
146if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
147 $extrafield_line_array = array();
149if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
150 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
152 $type = $extrafields->attributes[$elementtype][
'type'][$key];
153 if ($type ==
'date' || $type ==
'datetime') {
154 $type =
'xsd:dateTime';
156 $type =
'xsd:string';
158 $extrafield_line_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
161if (is_array($extrafield_line_array)) {
162 $line_fields = array_merge($line_fields, $extrafield_line_array);
166$server->wsdl->addComplexType(
190$server->wsdl->addComplexType(
199 'type' =>
'tns:line',
201 'maxOccurs' =>
'unbounded'
206$order_fields = array(
207 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
208 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
209 'ref_client' => array(
'name' =>
'ref_client',
'type' =>
'xsd:string'),
210 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
211 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
212 'status' => array(
'name' =>
'status',
'type' =>
'xsd:int'),
213 'billed' => array(
'name' =>
'billed',
'type' =>
'xsd:string'),
214 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
215 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
216 'total_localtax1' => array(
'name' =>
'total_localtax1',
'type' =>
'xsd:double'),
217 'total_localtax2' => array(
'name' =>
'total_localtax2',
'type' =>
'xsd:double'),
218 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
219 'date' => array(
'name' =>
'date',
'type' =>
'xsd:date'),
220 'date_due' => array(
'name' =>
'date_due',
'type' =>
'xsd:date'),
221 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
222 'date_validation' => array(
'name' =>
'date_validation',
'type' =>
'xsd:dateTime'),
223 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
224 'source' => array(
'name' =>
'source',
'type' =>
'xsd:string'),
225 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
226 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
227 'project_id' => array(
'name' =>
'project_id',
'type' =>
'xsd:string'),
229 'mode_reglement_id' => array(
'name' =>
'mode_reglement_id',
'type' =>
'xsd:string'),
230 'mode_reglement_code' => array(
'name' =>
'mode_reglement_code',
'type' =>
'xsd:string'),
231 'mode_reglement' => array(
'name' =>
'mode_reglement',
'type' =>
'xsd:string'),
232 'cond_reglement_id' => array(
'name' =>
'cond_reglement_id',
'type' =>
'xsd:string'),
233 'cond_reglement_code' => array(
'name' =>
'cond_reglement_code',
'type' =>
'xsd:string'),
234 'cond_reglement' => array(
'name' =>
'cond_reglement',
'type' =>
'xsd:string'),
235 'cond_reglement_doc' => array(
'name' =>
'cond_reglement_doc',
'type' =>
'xsd:string'),
237 'date_livraison' => array(
'name' =>
'date_livraison',
'type' =>
'xsd:date'),
238 'demand_reason_id' => array(
'name' =>
'demand_reason_id',
'type' =>
'xsd:string'),
240 'lines' => array(
'name' =>
'lines',
'type' =>
'tns:LinesArray2')
243$elementtype =
'commande';
248$extrafields->fetch_name_optionals_label($elementtype,
true);
249$extrafield_array =
null;
250if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
251 $extrafield_array = array();
253if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
254 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
256 $type = $extrafields->attributes[$elementtype][
'type'][$key];
257 if ($type ==
'date' || $type ==
'datetime') {
258 $type =
'xsd:dateTime';
260 $type =
'xsd:string';
262 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
265if (is_array($extrafield_array)) {
266 $order_fields = array_merge($order_fields, $extrafield_array);
269$server->wsdl->addComplexType(
294$server->wsdl->addComplexType(
303 'type' =>
'tns:order',
305 'maxOccurs' =>
'unbounded'
316$styleuse =
'encoded';
322 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
323 array(
'result' =>
'tns:result',
'order' =>
'tns:order'),
328 'WS to get a particular invoice'
332 'getOrdersForThirdParty',
333 array(
'authentication' =>
'tns:authentication',
'idthirdparty' =>
'xsd:string'),
334 array(
'result' =>
'tns:result',
'orders' =>
'tns:OrdersArray2'),
336 $ns.
'#getOrdersForThirdParty',
339 'WS to get all orders of a third party'
344 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
345 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
350 'WS to create an order'
355 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
356 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
361 'WS to update an order'
366 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'id_warehouse' =>
'xsd:string'),
367 array(
'result' =>
'tns:result'),
372 'WS to valid an order'
384function getOrder($authentication,
$id = 0, $ref =
'', $ref_ext =
'')
388 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
390 if ($authentication[
'entity']) {
391 $conf->entity = $authentication[
'entity'];
395 $objectresp = array();
404 $socid = $fuser->socid;
408 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
410 $errorcode =
'BAD_PARAMETERS';
411 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
415 $fuser->loadRights();
417 if ($fuser->hasRight(
'commande',
'lire')) {
419 $result = $order->fetch(
$id, $ref, $ref_ext);
422 if ($socid && $socid != $order->socid) {
424 $errorcode =
'PERMISSION_DENIED';
425 $errorlabel =
'User does not have permission for this request';
429 $linesresp = array();
431 foreach ($order->lines as $line) {
433 $linesresp[] = array(
434 'id' => $line->rowid,
435 'fk_commande' => $line->fk_commande,
436 'fk_parent_line' => $line->fk_parent_line,
437 'desc' => $line->desc,
439 'price' => $line->price,
440 'unitprice' => $line->subprice,
441 'vat_rate' => $line->tva_tx,
442 'remise' => $line->remise,
443 'remise_percent' => $line->remise_percent,
444 'product_id' => $line->fk_product,
445 'product_type' => $line->product_type,
446 'total_net' => $line->total_ht,
447 'total_vat' => $line->total_tva,
448 'total' => $line->total_ttc,
449 'date_start' => $line->date_start,
450 'date_end' => $line->date_end,
451 'product_ref' => $line->product_ref,
452 'product_label' => $line->product_label,
453 'product_desc' => $line->product_desc
460 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
463 'ref' => $order->ref,
464 'ref_client' => $order->ref_client,
465 'ref_ext' => $order->ref_ext,
466 'thirdparty_id' => $order->socid,
467 'status' => $order->statut,
469 'total_net' => $order->total_ht,
470 'total_vat' => $order->total_tva,
471 'total_localtax1' => $order->total_localtax1,
472 'total_localtax2' => $order->total_localtax2,
473 'total' => $order->total_ttc,
474 'project_id' => $order->fk_project,
476 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
477 'date_creation' => $order->date_creation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
478 'date_validation' => $order->date_validation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
479 'date_modification' => $order->date_modification ?
dol_print_date($order->date_modification,
'dayhourrfc') :
'',
481 'source' => $order->source,
482 'billed' => $order->billed,
483 'note_private' => $order->note_private,
484 'note_public' => $order->note_public,
485 'cond_reglement_id' => $order->cond_reglement_id,
486 'cond_reglement_code' => $order->cond_reglement_code,
487 'cond_reglement' => $order->cond_reglement,
488 'mode_reglement_id' => $order->mode_reglement_id,
489 'mode_reglement_code' => $order->mode_reglement_code,
490 'mode_reglement' => $order->mode_reglement,
492 'date_livraison' => $order->delivery_date,
494 'demand_reason_id' => $order->demand_reason_id,
495 'demand_reason_code' => $order->demand_reason_code,
497 'lines' => $linesresp
502 $errorcode =
'NOT_FOUND';
503 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
507 $errorcode =
'PERMISSION_DENIED';
508 $errorlabel =
'User does not have permission for this request';
513 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
531 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
533 if ($authentication[
'entity']) {
534 $conf->entity = $authentication[
'entity'];
538 $objectresp = array();
545 $socid = $fuser->socid;
551 if (!$error && empty($idthirdparty)) {
553 $errorcode =
'BAD_PARAMETERS';
554 $errorlabel =
'Parameter id is not provided';
558 $linesorders = array();
560 $sql =
'SELECT c.rowid as orderid';
561 $sql .=
' FROM '.MAIN_DB_PREFIX.
'commande as c';
562 $sql .=
" WHERE c.entity = ".$conf->entity;
563 if ($idthirdparty !=
'all') {
564 $sql .=
" AND c.fk_soc = ".((int) $idthirdparty);
568 $resql = $db->query($sql);
570 $num = $db->num_rows($resql);
574 $obj = $db->fetch_object($resql);
577 $order->fetch($obj->orderid);
580 if ($socid && ($socid != $order->socid)) {
582 $errorcode =
'PERMISSION_DENIED';
583 $errorlabel = $order->socid.
' User does not have permission for this request';
588 $linesresp = array();
589 foreach ($order->lines as $line) {
590 $linesresp[] = array(
591 'id' => $line->rowid,
592 'type' => $line->product_type,
593 'fk_commande' => $line->fk_commande,
594 'fk_parent_line' => $line->fk_parent_line,
595 'desc' => $line->desc,
597 'price' => $line->price,
598 'unitprice' => $line->subprice,
599 'tva_tx' => $line->tva_tx,
600 'remise' => $line->remise,
601 'remise_percent' => $line->remise_percent,
602 'total_net' => $line->total_ht,
603 'total_vat' => $line->total_tva,
604 'total' => $line->total_ttc,
605 'date_start' => $line->date_start,
606 'date_end' => $line->date_end,
607 'product_id' => $line->fk_product,
608 'product_ref' => $line->product_ref,
609 'product_label' => $line->product_label,
610 'product_desc' => $line->product_desc
615 $linesorders[] = array(
617 'ref' => $order->ref,
618 'ref_client' => $order->ref_client,
619 'ref_ext' => $order->ref_ext,
620 'socid' => $order->socid,
621 'status' => $order->statut,
623 'total_net' => $order->total_ht,
624 'total_vat' => $order->total_tva,
625 'total_localtax1' => $order->total_localtax1,
626 'total_localtax2' => $order->total_localtax2,
627 'total' => $order->total_ttc,
628 'project_id' => $order->fk_project,
630 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
632 'source' => $order->source,
633 'billed' => $order->billed,
634 'note_private' => $order->note_private,
635 'note_public' => $order->note_public,
636 'cond_reglement_id' => $order->cond_reglement_id,
637 'cond_reglement_doc' => $order->cond_reglement_doc,
638 'cond_reglement_code' => $order->cond_reglement_code,
639 'mode_reglement_id' => $order->mode_reglement_id,
640 'mode_reglement' => $order->mode_reglement,
641 'mode_reglement_code' => $order->mode_reglement_code,
643 'date_livraison' => $order->delivery_date,
645 'demand_reason_id' => $order->demand_reason_id,
646 'demand_reason_code' => $order->demand_reason_code,
648 'lines' => $linesresp
655 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
656 'orders' => $linesorders
661 $errorcode = $db->lasterrno();
662 $errorlabel = $db->lasterror();
667 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
683 global $db, $conf, $langs;
685 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
689 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'thirdparty_id']);
691 if ($authentication[
'entity']) {
692 $conf->entity = $authentication[
'entity'];
696 $objectresp = array();
708 $newobject->socid = $order[
'thirdparty_id'];
709 $newobject->ref_ext = $order[
'ref_ext'];
711 $newobject->date_lim_reglement =
dol_stringtotime((
string) $order[
'date_due'],
'dayrfc');
712 $newobject->note_private = $order[
'note_private'];
713 $newobject->note_public = $order[
'note_public'];
716 $newobject->billed = (int) $order[
'billed'];
717 $newobject->fk_project = (int) $order[
'project_id'];
718 $newobject->cond_reglement_id = (int) $order[
'cond_reglement_id'];
719 $newobject->demand_reason_id = (int) $order[
'demand_reason_id'];
720 $newobject->date_creation = $now;
722 $elementtype =
'commande';
727 $extrafields->fetch_name_optionals_label($elementtype,
true);
728 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
729 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
730 $key =
'options_'.$key;
731 $newobject->array_options[$key] = $order[$key];
736 $arrayoflines = array();
737 if (isset($order[
'lines'][
'line'][0])) {
738 $arrayoflines = $order[
'lines'][
'line'];
740 $arrayoflines = $order[
'lines'];
742 if (!is_array($arrayoflines)) {
743 $arrayoflines = array();
746 foreach ($arrayoflines as $key => $line) {
750 $newline->product_type = (int) $line[
'type'];
751 $newline->desc = $line[
'desc'];
752 $newline->fk_product = (int) $line[
'product_id'];
753 $newline->tva_tx = (float) $line[
'vat_rate'];
754 $newline->qty = (float) $line[
'qty'];
755 $newline->price = (float) $line[
'price'];
756 $newline->subprice = (float) $line[
'unitprice'];
757 $newline->total_ht = (float) $line[
'total_net'];
758 $newline->total_tva = (float) $line[
'total_vat'];
759 $newline->total_ttc = (float) $line[
'total'];
763 $elementtype =
'commandedet';
768 $extrafields->fetch_name_optionals_label($elementtype,
true);
769 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
770 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
771 $tmpkey =
'options_'.$tmpkey;
772 $newline->array_options[$tmpkey] = $line[$tmpkey];
776 $newobject->lines[] = $newline;
781 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
782 $result = $newobject->create($fuser);
783 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
785 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
789 if ($order[
'status'] == 1) {
790 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
791 $result = $newobject->valid($fuser);
793 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
799 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
801 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
803 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
807 $errorlabel = $newobject->error;
812 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
829 global $db, $conf, $langs;
831 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".
$id.
" id_warehouse=".$id_warehouse);
834 $objectresp = array();
838 if ($authentication[
'entity']) {
839 $conf->entity = $authentication[
'entity'];
844 $fuser->loadRights();
846 if ($fuser->hasRight(
'commande',
'lire')) {
848 $result = $order->fetch(
$id);
850 $order->fetch_thirdparty();
853 $result = $order->valid($fuser, $id_warehouse);
857 $outputlangs = $langs;
858 $order->generateDocument($order->model_pdf, $outputlangs);
863 $errorlabel = $order->error;
869 $errorlabel = $order->error;
875 $errorlabel =
'Bad permission';
880 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
883 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
898 global $db, $conf, $langs;
900 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
902 if ($authentication[
'entity']) {
903 $conf->entity = $authentication[
'entity'];
907 $objectresp = array();
913 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
916 $errorlabel =
"Order id or ref or ref_ext is mandatory.";
920 $objectfound =
false;
922 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
925 $result =
$object->fetch((
int) $order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
932 if (isset($order[
'status'])) {
933 if ($order[
'status'] == -1) {
934 $result =
$object->cancel($fuser);
936 if ($order[
'status'] == 1) {
937 $result =
$object->valid($fuser);
940 $outputlangs = $langs;
944 if ($order[
'status'] == 0) {
945 $result =
$object->set_reopen($fuser);
947 if ($order[
'status'] == 3) {
948 $result =
$object->cloture($fuser);
952 if (isset($order[
'billed'])) {
953 if ($order[
'billed']) {
954 $result =
$object->classifyBilled($fuser);
956 if (!$order[
'billed']) {
957 $result =
$object->classifyUnBilled($fuser);
961 $elementtype =
'commande';
966 $extrafields->fetch_name_optionals_label($elementtype,
true);
967 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
968 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
969 $key =
'options_'.$key;
970 if (isset($order[$key])) {
971 $result =
$object->setValueFrom($key, $order[$key],
'commande_extrafields');
981 if ((!$error) && ($objectfound)) {
984 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
989 } elseif ($objectfound) {
996 $errorcode =
'NOT_FOUND';
997 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
1002 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
1010$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
Class to manage order lines.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createOrder($authentication, $order)
Create order.
updateOrder($authentication, $order)
Update an order.
getOrder($authentication, $id=0, $ref='', $ref_ext='')
Get order from id, ref or ref_ext.
validOrder($authentication, $id=0, $id_warehouse=0)
Valid an order.
getOrdersForThirdParty($authentication, $idthirdparty)
Get list of orders for third party.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.