25if (!defined(
'NOCSRFCHECK')) {
26 define(
'NOCSRFCHECK',
'1');
28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
40if (!defined(
"NOLOGIN")) {
41 define(
"NOLOGIN",
'1');
43if (!defined(
"NOSESSION")) {
44 define(
"NOSESSION",
'1');
47require
'../main.inc.php';
48require_once NUSOAP_PATH.
'/nusoap.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
51require_once DOL_DOCUMENT_ROOT.
"/commande/class/commande.class.php";
55dol_syslog(
"Call Dolibarr webservices interfaces");
61 $langs->load(
"admin");
62 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
63 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
64 print $langs->trans(
"ToActivateModule");
69$server =
new nusoap_server();
70$server->soap_defencoding =
'UTF-8';
71$server->decode_utf8 =
false;
72$ns =
'http://www.dolibarr.org/ns/';
73$server->configureWSDL(
'WebServicesDolibarrOrder', $ns);
74$server->wsdl->schemaTargetNamespace = $ns;
78$server->wsdl->addComplexType(
85 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
86 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
87 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
88 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
89 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string')
93$server->wsdl->addComplexType(
100 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
101 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
106 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
107 'type' => array(
'name'=>
'type',
'type'=>
'xsd:int'),
108 'fk_commande' => array(
'name'=>
'fk_commande',
'type'=>
'xsd:int'),
109 'fk_parent_line' => array(
'name'=>
'fk_parent_line',
'type'=>
'xsd:int'),
110 'desc' => array(
'name'=>
'desc',
'type'=>
'xsd:string'),
111 'qty' => array(
'name'=>
'qty',
'type'=>
'xsd:double'),
112 'price' => array(
'name'=>
'price',
'type'=>
'xsd:double'),
113 'unitprice' => array(
'name'=>
'unitprice',
'type'=>
'xsd:double'),
114 'vat_rate' => array(
'name'=>
'vat_rate',
'type'=>
'xsd:double'),
116 'remise' => array(
'name'=>
'remise',
'type'=>
'xsd:double'),
117 'remise_percent' => array(
'name'=>
'remise_percent',
'type'=>
'xsd:double'),
119 'total_net' => array(
'name'=>
'total_net',
'type'=>
'xsd:double'),
120 'total_vat' => array(
'name'=>
'total_vat',
'type'=>
'xsd:double'),
121 'total' => array(
'name'=>
'total',
'type'=>
'xsd:double'),
123 'date_start' => array(
'name'=>
'date_start',
'type'=>
'xsd:date'),
124 'date_end' => array(
'name'=>
'date_end',
'type'=>
'xsd:date'),
127 'product_id' => array(
'name'=>
'product_id',
'type'=>
'xsd:int'),
128 'product_ref' => array(
'name'=>
'product_ref',
'type'=>
'xsd:string'),
129 'product_label' => array(
'name'=>
'product_label',
'type'=>
'xsd:string'),
130 'product_desc' => array(
'name'=>
'product_desc',
'type'=>
'xsd:string')
133$elementtype =
'commandedet';
138$extrafields->fetch_name_optionals_label($elementtype,
true);
139$extrafield_line_array =
null;
140if (is_array($extrafields) && count($extrafields) > 0) {
141 $extrafield_line_array = array();
143if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
144 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
146 $type = $extrafields->attributes[$elementtype][
'type'][$key];
147 if ($type ==
'date' || $type ==
'datetime') {
148 $type =
'xsd:dateTime';
150 $type =
'xsd:string';
152 $extrafield_line_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
155if (is_array($extrafield_line_array)) {
156 $line_fields = array_merge($line_fields, $extrafield_line_array);
160$server->wsdl->addComplexType(
184$server->wsdl->addComplexType(
193 'type' =>
'tns:line',
195 'maxOccurs' =>
'unbounded'
200$order_fields = array(
201 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
202 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
203 'ref_client' => array(
'name'=>
'ref_client',
'type'=>
'xsd:string'),
204 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
205 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
206 'status' => array(
'name'=>
'status',
'type'=>
'xsd:int'),
207 'billed' => array(
'name'=>
'billed',
'type'=>
'xsd:string'),
208 'total_net' => array(
'name'=>
'total_net',
'type'=>
'xsd:double'),
209 'total_vat' => array(
'name'=>
'total_vat',
'type'=>
'xsd:double'),
210 'total_localtax1' => array(
'name'=>
'total_localtax1',
'type'=>
'xsd:double'),
211 'total_localtax2' => array(
'name'=>
'total_localtax2',
'type'=>
'xsd:double'),
212 'total' => array(
'name'=>
'total',
'type'=>
'xsd:double'),
213 'date' => array(
'name'=>
'date',
'type'=>
'xsd:date'),
214 'date_creation' => array(
'name'=>
'date_creation',
'type'=>
'xsd:dateTime'),
215 'date_validation' => array(
'name'=>
'date_validation',
'type'=>
'xsd:dateTime'),
216 'date_modification' => array(
'name'=>
'date_modification',
'type'=>
'xsd:dateTime'),
217 'source' => array(
'name'=>
'source',
'type'=>
'xsd:string'),
218 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
219 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
220 'project_id' => array(
'name'=>
'project_id',
'type'=>
'xsd:string'),
222 'mode_reglement_id' => array(
'name'=>
'mode_reglement_id',
'type'=>
'xsd:string'),
223 'mode_reglement_code' => array(
'name'=>
'mode_reglement_code',
'type'=>
'xsd:string'),
224 'mode_reglement' => array(
'name'=>
'mode_reglement',
'type'=>
'xsd:string'),
225 'cond_reglement_id' => array(
'name'=>
'cond_reglement_id',
'type'=>
'xsd:string'),
226 'cond_reglement_code' => array(
'name'=>
'cond_reglement_code',
'type'=>
'xsd:string'),
227 'cond_reglement' => array(
'name'=>
'cond_reglement',
'type'=>
'xsd:string'),
228 'cond_reglement_doc' => array(
'name'=>
'cond_reglement_doc',
'type'=>
'xsd:string'),
230 'date_livraison' => array(
'name'=>
'date_livraison',
'type'=>
'xsd:date'),
231 'demand_reason_id' => array(
'name'=>
'demand_reason_id',
'type'=>
'xsd:string'),
233 'lines' => array(
'name'=>
'lines',
'type'=>
'tns:LinesArray2')
236$elementtype =
'commande';
241$extrafields->fetch_name_optionals_label($elementtype,
true);
242$extrafield_array =
null;
243if (is_array($extrafields) && count($extrafields) > 0) {
244 $extrafield_array = array();
246if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
247 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
249 $type = $extrafields->attributes[$elementtype][
'type'][$key];
250 if ($type ==
'date' || $type ==
'datetime') {
251 $type =
'xsd:dateTime';
253 $type =
'xsd:string';
255 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
258if (is_array($extrafield_array)) {
259 $order_fields = array_merge($order_fields, $extrafield_array);
262$server->wsdl->addComplexType(
287$server->wsdl->addComplexType(
296 'type' =>
'tns:order',
298 'maxOccurs' =>
'unbounded'
309$styleuse =
'encoded';
315 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
316 array(
'result'=>
'tns:result',
'order'=>
'tns:order'),
321 'WS to get a particular invoice'
325 'getOrdersForThirdParty',
326 array(
'authentication'=>
'tns:authentication',
'idthirdparty'=>
'xsd:string'),
327 array(
'result'=>
'tns:result',
'orders'=>
'tns:OrdersArray2'),
329 $ns.
'#getOrdersForThirdParty',
332 'WS to get all orders of a third party'
337 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
338 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
343 'WS to create an order'
348 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
349 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
354 'WS to update an order'
359 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'id_warehouse'=>
'xsd:string'),
360 array(
'result'=>
'tns:result'),
365 'WS to valid an order'
377function getOrder($authentication, $id = 0, $ref =
'', $ref_ext =
'')
381 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
383 if ($authentication[
'entity']) {
384 $conf->entity = $authentication[
'entity'];
388 $objectresp = array();
397 $socid = $fuser->socid;
401 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
403 $errorcode =
'BAD_PARAMETERS';
404 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
410 if ($fuser->hasRight(
'commande',
'lire')) {
412 $result = $order->fetch($id, $ref, $ref_ext);
415 if ($socid && $socid != $order->socid) {
417 $errorcode =
'PERMISSION_DENIED';
418 $errorlabel =
'User does not have permission for this request';
422 $linesresp = array();
424 foreach ($order->lines as $line) {
426 $linesresp[] = array(
428 'fk_commande'=>$line->fk_commande,
429 'fk_parent_line'=>$line->fk_parent_line,
432 'price'=>$line->price,
433 'unitprice'=>$line->subprice,
434 'vat_rate'=>$line->tva_tx,
435 'remise'=>$line->remise,
436 'remise_percent'=>$line->remise_percent,
437 'product_id'=>$line->fk_product,
438 'product_type'=>$line->product_type,
439 'total_net'=>$line->total_ht,
440 'total_vat'=>$line->total_tva,
441 'total'=>$line->total_ttc,
442 'date_start'=>$line->date_start,
443 'date_end'=>$line->date_end,
444 'product_ref'=>$line->product_ref,
445 'product_label'=>$line->product_label,
446 'product_desc'=>$line->product_desc
453 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
456 'ref' => $order->ref,
457 'ref_client' => $order->ref_client,
458 'ref_ext' => $order->ref_ext,
459 'thirdparty_id' => $order->socid,
460 'status' => $order->statut,
462 'total_net' => $order->total_ht,
463 'total_vat' => $order->total_tva,
464 'total_localtax1' => $order->total_localtax1,
465 'total_localtax2' => $order->total_localtax2,
466 'total' => $order->total_ttc,
467 'project_id' => $order->fk_project,
469 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
470 'date_creation' => $order->date_creation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
471 'date_validation' => $order->date_validation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
472 'date_modification' => $order->date_modification ?
dol_print_date($order->date_modification,
'dayhourrfc') :
'',
474 'source' => $order->source,
475 'billed' => $order->billed,
476 'note_private' => $order->note_private,
477 'note_public' => $order->note_public,
478 'cond_reglement_id' => $order->cond_reglement_id,
479 'cond_reglement_code' => $order->cond_reglement_code,
480 'cond_reglement' => $order->cond_reglement,
481 'mode_reglement_id' => $order->mode_reglement_id,
482 'mode_reglement_code' => $order->mode_reglement_code,
483 'mode_reglement' => $order->mode_reglement,
485 'date_livraison' => $order->delivery_date,
487 'demand_reason_id' => $order->demand_reason_id,
488 'demand_reason_code' => $order->demand_reason_code,
490 'lines' => $linesresp
495 $errorcode =
'NOT_FOUND';
496 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
500 $errorcode =
'PERMISSION_DENIED';
501 $errorlabel =
'User does not have permission for this request';
506 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
524 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
526 if ($authentication[
'entity']) {
527 $conf->entity = $authentication[
'entity'];
531 $objectresp = array();
538 $socid = $fuser->socid;
542 if (!$error && empty($idthirdparty)) {
544 $errorcode =
'BAD_PARAMETERS';
545 $errorlabel =
'Parameter id is not provided';
549 $linesorders = array();
551 $sql =
'SELECT c.rowid as orderid';
552 $sql .=
' FROM '.MAIN_DB_PREFIX.
'commande as c';
553 $sql .=
" WHERE c.entity = ".$conf->entity;
554 if ($idthirdparty !=
'all') {
555 $sql .=
" AND c.fk_soc = ".((int) $idthirdparty);
559 $resql = $db->query($sql);
561 $num = $db->num_rows($resql);
565 $obj = $db->fetch_object($resql);
568 $order->fetch($obj->orderid);
571 if ($socid && ($socid != $order->socid)) {
573 $errorcode =
'PERMISSION_DENIED';
574 $errorlabel = $order->socid.
' User does not have permission for this request';
579 $linesresp = array();
580 foreach ($order->lines as $line) {
581 $linesresp[] = array(
583 'type'=>$line->product_type,
584 'fk_commande'=>$line->fk_commande,
585 'fk_parent_line'=>$line->fk_parent_line,
588 'price'=>$line->price,
589 'unitprice'=>$line->subprice,
590 'tva_tx'=>$line->tva_tx,
591 'remise'=>$line->remise,
592 'remise_percent'=>$line->remise_percent,
593 'total_net'=>$line->total_ht,
594 'total_vat'=>$line->total_tva,
595 'total'=>$line->total_ttc,
596 'date_start'=>$line->date_start,
597 'date_end'=>$line->date_end,
598 'product_id'=>$line->fk_product,
599 'product_ref'=>$line->product_ref,
600 'product_label'=>$line->product_label,
601 'product_desc'=>$line->product_desc
606 $linesorders[] = array(
608 'ref' => $order->ref,
609 'ref_client' => $order->ref_client,
610 'ref_ext' => $order->ref_ext,
611 'socid' => $order->socid,
612 'status' => $order->statut,
614 'total_net' => $order->total_ht,
615 'total_vat' => $order->total_tva,
616 'total_localtax1' => $order->total_localtax1,
617 'total_localtax2' => $order->total_localtax2,
618 'total' => $order->total_ttc,
619 'project_id' => $order->fk_project,
621 'date' => $order->date_commande ?
dol_print_date($order->date_commande,
'dayrfc') :
'',
623 'source' => $order->source,
624 'billed' => $order->billed,
625 'note_private' => $order->note_private,
626 'note_public' => $order->note_public,
627 'cond_reglement_id' => $order->cond_reglement_id,
628 'cond_reglement' => $order->cond_reglement,
629 'cond_reglement_doc' => $order->cond_reglement_doc,
630 'cond_reglement_code' => $order->cond_reglement_code,
631 'mode_reglement_id' => $order->mode_reglement_id,
632 'mode_reglement' => $order->mode_reglement,
633 'mode_reglement_code' => $order->mode_reglement_code,
635 'date_livraison' => $order->delivery_date,
637 'demand_reason_id' => $order->demand_reason_id,
638 'demand_reason_code' => $order->demand_reason_code,
640 'lines' => $linesresp
647 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
648 'orders'=>$linesorders
653 $errorcode = $db->lasterrno();
654 $errorlabel = $db->lasterror();
659 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
675 global $db, $conf, $langs;
677 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
681 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
683 if ($authentication[
'entity']) {
684 $conf->entity = $authentication[
'entity'];
688 $objectresp = array();
699 $newobject->socid = $order[
'thirdparty_id'];
700 $newobject->type = $order[
'type'];
701 $newobject->ref_ext = $order[
'ref_ext'];
703 $newobject->date_lim_reglement =
dol_stringtotime($order[
'date_due'],
'dayrfc');
704 $newobject->note_private = $order[
'note_private'];
705 $newobject->note_public = $order[
'note_public'];
707 $newobject->billed = $order[
'billed'];
708 $newobject->fk_project = $order[
'project_id'];
709 $newobject->cond_reglement_id = $order[
'cond_reglement_id'];
710 $newobject->demand_reason_id = $order[
'demand_reason_id'];
711 $newobject->date_creation = $now;
713 $elementtype =
'commande';
718 $extrafields->fetch_name_optionals_label($elementtype,
true);
719 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
720 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
721 $key =
'options_'.$key;
722 $newobject->array_options[$key] = $order[$key];
727 $arrayoflines = array();
728 if (isset($order[
'lines'][
'line'][0])) {
729 $arrayoflines = $order[
'lines'][
'line'];
731 $arrayoflines = $order[
'lines'];
734 foreach ($arrayoflines as $key => $line) {
738 $newline->type = $line[
'type'];
739 $newline->desc = $line[
'desc'];
740 $newline->fk_product = $line[
'product_id'];
741 $newline->tva_tx = $line[
'vat_rate'];
742 $newline->qty = $line[
'qty'];
743 $newline->price = $line[
'price'];
744 $newline->subprice = $line[
'unitprice'];
745 $newline->total_ht = $line[
'total_net'];
746 $newline->total_tva = $line[
'total_vat'];
747 $newline->total_ttc = $line[
'total'];
748 $newline->date_start = $line[
'date_start'];
749 $newline->date_end = $line[
'date_end'];
751 $elementtype =
'commandedet';
756 $extrafields->fetch_name_optionals_label($elementtype,
true);
757 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
758 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
759 $tmpkey =
'options_'.$tmpkey;
760 $newline->array_options[$tmpkey] = $line[$tmpkey];
764 $newobject->lines[] = $newline;
769 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
770 $result = $newobject->create($fuser);
771 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
773 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
777 if ($order[
'status'] == 1) {
778 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
779 $result = $newobject->valid($fuser);
781 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
787 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
789 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
791 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
795 $errorlabel = $newobject->error;
800 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
815function validOrder($authentication, $id = 0, $id_warehouse = 0)
817 global $db, $conf, $langs;
819 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".$id.
" id_warehouse=".$id_warehouse);
822 $objectresp = array();
826 if ($authentication[
'entity']) {
827 $conf->entity = $authentication[
'entity'];
834 if ($fuser->hasRight(
'commande',
'lire')) {
836 $result = $order->fetch($id);
838 $order->fetch_thirdparty();
841 $result = $order->valid($fuser, $id_warehouse);
845 $outputlangs = $langs;
846 $order->generateDocument($order->model_pdf, $outputlangs);
851 $errorlabel = $order->error;
857 $errorlabel = $order->error;
863 $errorlabel =
'Bad permission';
868 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
871 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''));
886 global $db, $conf, $langs;
888 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
890 if ($authentication[
'entity']) {
891 $conf->entity = $authentication[
'entity'];
895 $objectresp = array();
901 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
904 $errorlabel =
"Order id or ref or ref_ext is mandatory.";
908 $objectfound =
false;
910 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
913 $result = $object->fetch($order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
915 if (!empty($object->id)) {
920 if (isset($order[
'status'])) {
921 if ($order[
'status'] == -1) {
922 $result = $object->cancel($fuser);
924 if ($order[
'status'] == 1) {
925 $result = $object->valid($fuser);
928 $outputlangs = $langs;
929 $object->generateDocument($order->model_pdf, $outputlangs);
932 if ($order[
'status'] == 0) {
933 $result = $object->set_reopen($fuser);
935 if ($order[
'status'] == 3) {
936 $result = $object->cloture($fuser);
940 if (isset($order[
'billed'])) {
941 if ($order[
'billed']) {
942 $result = $object->classifyBilled($fuser);
944 if (!$order[
'billed']) {
945 $result = $object->classifyUnBilled($fuser);
949 $elementtype =
'commande';
954 $extrafields->fetch_name_optionals_label($elementtype,
true);
955 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
956 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
957 $key =
'options_'.$key;
958 if (isset($order[$key])) {
959 $result = $object->setValueFrom($key, $order[$key],
'commande_extrafields');
969 if ((!$error) && ($objectfound)) {
972 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
975 'ref_ext'=>$object->ref_ext
977 } elseif ($objectfound) {
981 $errorlabel = $object->error;
984 $errorcode =
'NOT_FOUND';
985 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
990 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
998$server->service(file_get_contents(
"php://input"));
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return 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.