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");
60if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
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 'remise' => array(
'name'=>
'remise',
'type'=>
'xsd:string'),
218 'remise_percent' => array(
'name'=>
'remise_percent',
'type'=>
'xsd:string'),
219 'remise_absolue' => array(
'name'=>
'remise_absolue',
'type'=>
'xsd:string'),
220 'source' => array(
'name'=>
'source',
'type'=>
'xsd:string'),
221 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
222 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
223 'project_id' => array(
'name'=>
'project_id',
'type'=>
'xsd:string'),
225 'mode_reglement_id' => array(
'name'=>
'mode_reglement_id',
'type'=>
'xsd:string'),
226 'mode_reglement_code' => array(
'name'=>
'mode_reglement_code',
'type'=>
'xsd:string'),
227 'mode_reglement' => array(
'name'=>
'mode_reglement',
'type'=>
'xsd:string'),
228 'cond_reglement_id' => array(
'name'=>
'cond_reglement_id',
'type'=>
'xsd:string'),
229 'cond_reglement_code' => array(
'name'=>
'cond_reglement_code',
'type'=>
'xsd:string'),
230 'cond_reglement' => array(
'name'=>
'cond_reglement',
'type'=>
'xsd:string'),
231 'cond_reglement_doc' => array(
'name'=>
'cond_reglement_doc',
'type'=>
'xsd:string'),
233 'date_livraison' => array(
'name'=>
'date_livraison',
'type'=>
'xsd:date'),
234 'demand_reason_id' => array(
'name'=>
'demand_reason_id',
'type'=>
'xsd:string'),
236 'lines' => array(
'name'=>
'lines',
'type'=>
'tns:LinesArray2')
239$elementtype =
'commande';
244$extrafields->fetch_name_optionals_label($elementtype,
true);
245$extrafield_array =
null;
246if (is_array($extrafields) && count($extrafields) > 0) {
247 $extrafield_array = array();
249if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
250 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
252 $type = $extrafields->attributes[$elementtype][
'type'][$key];
253 if ($type ==
'date' || $type ==
'datetime') {
254 $type =
'xsd:dateTime';
256 $type =
'xsd:string';
258 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
261if (is_array($extrafield_array)) {
262 $order_fields = array_merge($order_fields, $extrafield_array);
265$server->wsdl->addComplexType(
290$server->wsdl->addComplexType(
299 'type' =>
'tns:order',
301 'maxOccurs' =>
'unbounded'
312$styleuse =
'encoded';
318 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
319 array(
'result'=>
'tns:result',
'order'=>
'tns:order'),
324 'WS to get a particular invoice'
328 'getOrdersForThirdParty',
329 array(
'authentication'=>
'tns:authentication',
'idthirdparty'=>
'xsd:string'),
330 array(
'result'=>
'tns:result',
'orders'=>
'tns:OrdersArray2'),
332 $ns.
'#getOrdersForThirdParty',
335 'WS to get all orders of a third party'
340 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
341 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
346 'WS to create an order'
351 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
352 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
357 'WS to update an order'
362 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'id_warehouse'=>
'xsd:string'),
363 array(
'result'=>
'tns:result'),
368 'WS to valid an order'
380function getOrder($authentication, $id =
'', $ref =
'', $ref_ext =
'')
384 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
386 if ($authentication[
'entity']) {
387 $conf->entity = $authentication[
'entity'];
391 $objectresp = array();
392 $errorcode =
''; $errorlabel =
'';
399 $socid = $fuser->socid;
403 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
405 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
411 if ($fuser->rights->commande->lire) {
413 $result = $order->fetch($id, $ref, $ref_ext);
416 if ($socid && $socid != $order->socid) {
418 $errorcode =
'PERMISSION_DENIED'; $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 'remise' => $order->remise,
475 'remise_percent' => $order->remise_percent,
476 'remise_absolue' => $order->remise_absolue,
478 'source' => $order->source,
479 'billed' => $order->billed,
480 'note_private' => $order->note_private,
481 'note_public' => $order->note_public,
482 'cond_reglement_id' => $order->cond_reglement_id,
483 'cond_reglement_code' => $order->cond_reglement_code,
484 'cond_reglement' => $order->cond_reglement,
485 'mode_reglement_id' => $order->mode_reglement_id,
486 'mode_reglement_code' => $order->mode_reglement_code,
487 'mode_reglement' => $order->mode_reglement,
489 'date_livraison' => $order->delivery_date,
491 'demand_reason_id' => $order->demand_reason_id,
492 'demand_reason_code' => $order->demand_reason_code,
494 'lines' => $linesresp
499 $errorcode =
'NOT_FOUND';
500 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
504 $errorcode =
'PERMISSION_DENIED';
505 $errorlabel =
'User does not have permission for this request';
510 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
528 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
530 if ($authentication[
'entity']) {
531 $conf->entity = $authentication[
'entity'];
535 $objectresp = array();
536 $errorcode =
''; $errorlabel =
'';
541 $socid = $fuser->socid;
545 if (!$error && empty($idthirdparty)) {
547 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
'Parameter id is not provided';
551 $linesorders = array();
553 $sql =
'SELECT c.rowid as orderid';
554 $sql .=
' FROM '.MAIN_DB_PREFIX.
'commande as c';
555 $sql .=
" WHERE c.entity = ".$conf->entity;
556 if ($idthirdparty !=
'all') {
557 $sql .=
" AND c.fk_soc = ".((int) $idthirdparty);
561 $resql = $db->query($sql);
563 $num = $db->num_rows($resql);
567 $obj = $db->fetch_object($resql);
570 $order->fetch($obj->orderid);
573 if ($socid && ($socid != $order->socid)) {
575 $errorcode =
'PERMISSION_DENIED';
576 $errorlabel = $order->socid.
' User does not have permission for this request';
581 $linesresp = array();
582 foreach ($order->lines as $line) {
583 $linesresp[] = array(
585 'type'=>$line->product_type,
586 'fk_commande'=>$line->fk_commande,
587 'fk_parent_line'=>$line->fk_parent_line,
590 'price'=>$line->price,
591 'unitprice'=>$line->subprice,
592 'tva_tx'=>$line->tva_tx,
593 'remise'=>$line->remise,
594 'remise_percent'=>$line->remise_percent,
595 'total_net'=>$line->total_ht,
596 'total_vat'=>$line->total_tva,
597 'total'=>$line->total_ttc,
598 'date_start'=>$line->date_start,
599 'date_end'=>$line->date_end,
600 'product_id'=>$line->fk_product,
601 'product_ref'=>$line->product_ref,
602 'product_label'=>$line->product_label,
603 'product_desc'=>$line->product_desc
608 $linesorders[] = array(
610 'ref' => $order->ref,
611 'ref_client' => $order->ref_client,
612 'ref_ext' => $order->ref_ext,
613 'socid' => $order->socid,
614 'status' => $order->statut,
616 'total_net' => $order->total_ht,
617 'total_vat' => $order->total_tva,
618 'total_localtax1' => $order->total_localtax1,
619 'total_localtax2' => $order->total_localtax2,
620 'total' => $order->total_ttc,
621 'project_id' => $order->fk_project,
623 'date' => $order->date_commande ?
dol_print_date($order->date_commande,
'dayrfc') :
'',
625 'remise' => $order->remise,
626 'remise_percent' => $order->remise_percent,
627 'remise_absolue' => $order->remise_absolue,
629 'source' => $order->source,
630 'billed' => $order->billed,
631 'note_private' => $order->note_private,
632 'note_public' => $order->note_public,
633 'cond_reglement_id' => $order->cond_reglement_id,
634 'cond_reglement' => $order->cond_reglement,
635 'cond_reglement_doc' => $order->cond_reglement_doc,
636 'cond_reglement_code' => $order->cond_reglement_code,
637 'mode_reglement_id' => $order->mode_reglement_id,
638 'mode_reglement' => $order->mode_reglement,
639 'mode_reglement_code' => $order->mode_reglement_code,
641 'date_livraison' => $order->delivery_date,
643 'demand_reason_id' => $order->demand_reason_id,
644 'demand_reason_code' => $order->demand_reason_code,
646 'lines' => $linesresp
653 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
654 'orders'=>$linesorders
659 $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
664 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
680 global $db, $conf, $langs;
682 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
686 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
688 if ($authentication[
'entity']) {
689 $conf->entity = $authentication[
'entity'];
693 $objectresp = array();
704 $newobject->socid = $order[
'thirdparty_id'];
705 $newobject->type = $order[
'type'];
706 $newobject->ref_ext = $order[
'ref_ext'];
708 $newobject->date_lim_reglement =
dol_stringtotime($order[
'date_due'],
'dayrfc');
709 $newobject->note_private = $order[
'note_private'];
710 $newobject->note_public = $order[
'note_public'];
712 $newobject->billed = $order[
'billed'];
713 $newobject->fk_project = $order[
'project_id'];
714 $newobject->cond_reglement_id = $order[
'cond_reglement_id'];
715 $newobject->demand_reason_id = $order[
'demand_reason_id'];
716 $newobject->date_creation = $now;
718 $elementtype =
'commande';
723 $extrafields->fetch_name_optionals_label($elementtype,
true);
724 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
725 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
726 $key =
'options_'.$key;
727 $newobject->array_options[$key] = $order[$key];
732 $arrayoflines = array();
733 if (isset($order[
'lines'][
'line'][0])) {
734 $arrayoflines = $order[
'lines'][
'line'];
736 $arrayoflines = $order[
'lines'];
739 foreach ($arrayoflines as $key => $line) {
743 $newline->type = $line[
'type'];
744 $newline->desc = $line[
'desc'];
745 $newline->fk_product = $line[
'product_id'];
746 $newline->tva_tx = $line[
'vat_rate'];
747 $newline->qty = $line[
'qty'];
748 $newline->price = $line[
'price'];
749 $newline->subprice = $line[
'unitprice'];
750 $newline->total_ht = $line[
'total_net'];
751 $newline->total_tva = $line[
'total_vat'];
752 $newline->total_ttc = $line[
'total'];
753 $newline->date_start = $line[
'date_start'];
754 $newline->date_end = $line[
'date_end'];
756 $elementtype =
'commandedet';
761 $extrafields->fetch_name_optionals_label($elementtype,
true);
762 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
763 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
764 $tmpkey =
'options_'.$tmpkey;
765 $newline->array_options[$tmpkey] = $line[$tmpkey];
769 $newobject->lines[] = $newline;
774 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
775 $result = $newobject->create($fuser);
776 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
778 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
782 if ($order[
'status'] == 1) {
783 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
784 $result = $newobject->valid($fuser);
786 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
792 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
794 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
796 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
800 $errorlabel = $newobject->error;
805 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
820function validOrder($authentication, $id =
'', $id_warehouse = 0)
822 global $db, $conf, $langs;
824 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".$id.
" id_warehouse=".$id_warehouse);
827 $objectresp = array();
831 if ($authentication[
'entity']) {
832 $conf->entity = $authentication[
'entity'];
839 if ($fuser->rights->commande->lire) {
841 $result = $order->fetch($id);
843 $order->fetch_thirdparty();
846 $result = $order->valid($fuser, $id_warehouse);
850 $outputlangs = $langs;
851 $order->generateDocument($order->model_pdf, $outputlangs);
856 $errorlabel = $order->error;
862 $errorlabel = $order->error;
868 $errorlabel = $order->error;
873 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
876 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''));
891 global $db, $conf, $langs;
893 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
895 if ($authentication[
'entity']) {
896 $conf->entity = $authentication[
'entity'];
900 $objectresp = array();
901 $errorcode =
''; $errorlabel =
'';
905 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
906 $error++; $errorcode =
'KO'; $errorlabel =
"Order id or ref or ref_ext is mandatory.";
910 $objectfound =
false;
912 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
915 $result = $object->fetch($order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
917 if (!empty($object->id)) {
922 if (isset($order[
'status'])) {
923 if ($order[
'status'] == -1) {
924 $result = $object->cancel($fuser);
926 if ($order[
'status'] == 1) {
927 $result = $object->valid($fuser);
930 $outputlangs = $langs;
931 $object->generateDocument($order->model_pdf, $outputlangs);
934 if ($order[
'status'] == 0) {
935 $result = $object->set_reopen($fuser);
937 if ($order[
'status'] == 3) {
938 $result = $object->cloture($fuser);
942 if (isset($order[
'billed'])) {
943 if ($order[
'billed']) {
944 $result = $object->classifyBilled($fuser);
946 if (!$order[
'billed']) {
947 $result = $object->classifyUnBilled($fuser);
951 $elementtype =
'commande';
956 $extrafields->fetch_name_optionals_label($elementtype,
true);
957 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
958 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
959 $key =
'options_'.$key;
960 if (isset($order[$key])) {
961 $result = $object->setValueFrom($key, $order[$key],
'commande_extrafields');
971 if ((!$error) && ($objectfound)) {
974 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
977 'ref_ext'=>$object->ref_ext
979 } elseif ($objectfound) {
983 $errorlabel = $object->error;
986 $errorcode =
'NOT_FOUND';
987 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
992 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
1000$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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createOrder($authentication, $order)
Create order.
validOrder($authentication, $id='', $id_warehouse=0)
Valid an order.
getOrder($authentication, $id='', $ref='', $ref_ext='')
Get order from id, ref or ref_ext.
updateOrder($authentication, $order)
Update 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.