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";
57dol_syslog(
"Call Dolibarr webservices interfaces");
63 $langs->load(
"admin");
64 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
65 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
66 print $langs->trans(
"ToActivateModule");
71$server =
new nusoap_server();
72$server->soap_defencoding =
'UTF-8';
73$server->decode_utf8 =
false;
74$ns =
'http://www.dolibarr.org/ns/';
75$server->configureWSDL(
'WebServicesDolibarrOrder', $ns);
76$server->wsdl->schemaTargetNamespace = $ns;
80$server->wsdl->addComplexType(
87 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
88 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
89 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
90 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
91 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string')
95$server->wsdl->addComplexType(
102 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
103 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
108 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
109 'type' => array(
'name' =>
'type',
'type' =>
'xsd:int'),
110 'fk_commande' => array(
'name' =>
'fk_commande',
'type' =>
'xsd:int'),
111 'fk_parent_line' => array(
'name' =>
'fk_parent_line',
'type' =>
'xsd:int'),
112 'desc' => array(
'name' =>
'desc',
'type' =>
'xsd:string'),
113 'qty' => array(
'name' =>
'qty',
'type' =>
'xsd:double'),
114 'price' => array(
'name' =>
'price',
'type' =>
'xsd:double'),
115 'unitprice' => array(
'name' =>
'unitprice',
'type' =>
'xsd:double'),
116 'vat_rate' => array(
'name' =>
'vat_rate',
'type' =>
'xsd:double'),
118 'remise' => array(
'name' =>
'remise',
'type' =>
'xsd:double'),
119 'remise_percent' => array(
'name' =>
'remise_percent',
'type' =>
'xsd:double'),
121 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
122 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
123 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
125 'date_start' => array(
'name' =>
'date_start',
'type' =>
'xsd:date'),
126 'date_end' => array(
'name' =>
'date_end',
'type' =>
'xsd:date'),
129 'product_id' => array(
'name' =>
'product_id',
'type' =>
'xsd:int'),
130 'product_ref' => array(
'name' =>
'product_ref',
'type' =>
'xsd:string'),
131 'product_label' => array(
'name' =>
'product_label',
'type' =>
'xsd:string'),
132 'product_desc' => array(
'name' =>
'product_desc',
'type' =>
'xsd:string')
135$elementtype =
'commandedet';
140$extrafields->fetch_name_optionals_label($elementtype,
true);
141$extrafield_line_array =
null;
142if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
143 $extrafield_line_array = array();
145if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
146 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
148 $type = $extrafields->attributes[$elementtype][
'type'][$key];
149 if ($type ==
'date' || $type ==
'datetime') {
150 $type =
'xsd:dateTime';
152 $type =
'xsd:string';
154 $extrafield_line_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
157if (is_array($extrafield_line_array)) {
158 $line_fields = array_merge($line_fields, $extrafield_line_array);
162$server->wsdl->addComplexType(
186$server->wsdl->addComplexType(
195 'type' =>
'tns:line',
197 'maxOccurs' =>
'unbounded'
202$order_fields = array(
203 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
204 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
205 'ref_client' => array(
'name' =>
'ref_client',
'type' =>
'xsd:string'),
206 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
207 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
208 'status' => array(
'name' =>
'status',
'type' =>
'xsd:int'),
209 'billed' => array(
'name' =>
'billed',
'type' =>
'xsd:string'),
210 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
211 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
212 'total_localtax1' => array(
'name' =>
'total_localtax1',
'type' =>
'xsd:double'),
213 'total_localtax2' => array(
'name' =>
'total_localtax2',
'type' =>
'xsd:double'),
214 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
215 'date' => array(
'name' =>
'date',
'type' =>
'xsd:date'),
216 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
217 'date_validation' => array(
'name' =>
'date_validation',
'type' =>
'xsd:dateTime'),
218 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
219 'source' => array(
'name' =>
'source',
'type' =>
'xsd:string'),
220 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
221 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
222 'project_id' => array(
'name' =>
'project_id',
'type' =>
'xsd:string'),
224 'mode_reglement_id' => array(
'name' =>
'mode_reglement_id',
'type' =>
'xsd:string'),
225 'mode_reglement_code' => array(
'name' =>
'mode_reglement_code',
'type' =>
'xsd:string'),
226 'mode_reglement' => array(
'name' =>
'mode_reglement',
'type' =>
'xsd:string'),
227 'cond_reglement_id' => array(
'name' =>
'cond_reglement_id',
'type' =>
'xsd:string'),
228 'cond_reglement_code' => array(
'name' =>
'cond_reglement_code',
'type' =>
'xsd:string'),
229 'cond_reglement' => array(
'name' =>
'cond_reglement',
'type' =>
'xsd:string'),
230 'cond_reglement_doc' => array(
'name' =>
'cond_reglement_doc',
'type' =>
'xsd:string'),
232 'date_livraison' => array(
'name' =>
'date_livraison',
'type' =>
'xsd:date'),
233 'demand_reason_id' => array(
'name' =>
'demand_reason_id',
'type' =>
'xsd:string'),
235 'lines' => array(
'name' =>
'lines',
'type' =>
'tns:LinesArray2')
238$elementtype =
'commande';
243$extrafields->fetch_name_optionals_label($elementtype,
true);
244$extrafield_array =
null;
245if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
246 $extrafield_array = array();
248if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
249 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
251 $type = $extrafields->attributes[$elementtype][
'type'][$key];
252 if ($type ==
'date' || $type ==
'datetime') {
253 $type =
'xsd:dateTime';
255 $type =
'xsd:string';
257 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
260if (is_array($extrafield_array)) {
261 $order_fields = array_merge($order_fields, $extrafield_array);
264$server->wsdl->addComplexType(
289$server->wsdl->addComplexType(
298 'type' =>
'tns:order',
300 'maxOccurs' =>
'unbounded'
311$styleuse =
'encoded';
317 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
318 array(
'result' =>
'tns:result',
'order' =>
'tns:order'),
323 'WS to get a particular invoice'
327 'getOrdersForThirdParty',
328 array(
'authentication' =>
'tns:authentication',
'idthirdparty' =>
'xsd:string'),
329 array(
'result' =>
'tns:result',
'orders' =>
'tns:OrdersArray2'),
331 $ns.
'#getOrdersForThirdParty',
334 'WS to get all orders of a third party'
339 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
340 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
345 'WS to create an order'
350 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
351 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
356 'WS to update an order'
361 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'id_warehouse' =>
'xsd:string'),
362 array(
'result' =>
'tns:result'),
367 'WS to valid an order'
379function getOrder($authentication, $id = 0, $ref =
'', $ref_ext =
'')
383 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
385 if ($authentication[
'entity']) {
386 $conf->entity = $authentication[
'entity'];
390 $objectresp = array();
399 $socid = $fuser->socid;
403 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
405 $errorcode =
'BAD_PARAMETERS';
406 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
412 if ($fuser->hasRight(
'commande',
'lire')) {
414 $result = $order->fetch($id, $ref, $ref_ext);
417 if ($socid && $socid != $order->socid) {
419 $errorcode =
'PERMISSION_DENIED';
420 $errorlabel =
'User does not have permission for this request';
424 $linesresp = array();
426 foreach ($order->lines as $line) {
428 $linesresp[] = array(
429 'id' => $line->rowid,
430 'fk_commande' => $line->fk_commande,
431 'fk_parent_line' => $line->fk_parent_line,
432 'desc' => $line->desc,
434 'price' => $line->price,
435 'unitprice' => $line->subprice,
436 'vat_rate' => $line->tva_tx,
437 'remise' => $line->remise,
438 'remise_percent' => $line->remise_percent,
439 'product_id' => $line->fk_product,
440 'product_type' => $line->product_type,
441 'total_net' => $line->total_ht,
442 'total_vat' => $line->total_tva,
443 'total' => $line->total_ttc,
444 'date_start' => $line->date_start,
445 'date_end' => $line->date_end,
446 'product_ref' => $line->product_ref,
447 'product_label' => $line->product_label,
448 'product_desc' => $line->product_desc
455 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
458 'ref' => $order->ref,
459 'ref_client' => $order->ref_client,
460 'ref_ext' => $order->ref_ext,
461 'thirdparty_id' => $order->socid,
462 'status' => $order->statut,
464 'total_net' => $order->total_ht,
465 'total_vat' => $order->total_tva,
466 'total_localtax1' => $order->total_localtax1,
467 'total_localtax2' => $order->total_localtax2,
468 'total' => $order->total_ttc,
469 'project_id' => $order->fk_project,
471 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
472 'date_creation' => $order->date_creation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
473 'date_validation' => $order->date_validation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
474 'date_modification' => $order->date_modification ?
dol_print_date($order->date_modification,
'dayhourrfc') :
'',
476 'source' => $order->source,
477 'billed' => $order->billed,
478 'note_private' => $order->note_private,
479 'note_public' => $order->note_public,
480 'cond_reglement_id' => $order->cond_reglement_id,
481 'cond_reglement_code' => $order->cond_reglement_code,
482 'cond_reglement' => $order->cond_reglement,
483 'mode_reglement_id' => $order->mode_reglement_id,
484 'mode_reglement_code' => $order->mode_reglement_code,
485 'mode_reglement' => $order->mode_reglement,
487 'date_livraison' => $order->delivery_date,
489 'demand_reason_id' => $order->demand_reason_id,
490 'demand_reason_code' => $order->demand_reason_code,
492 'lines' => $linesresp
497 $errorcode =
'NOT_FOUND';
498 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
502 $errorcode =
'PERMISSION_DENIED';
503 $errorlabel =
'User does not have permission for this request';
508 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
526 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
528 if ($authentication[
'entity']) {
529 $conf->entity = $authentication[
'entity'];
533 $objectresp = array();
540 $socid = $fuser->socid;
544 if (!$error && empty($idthirdparty)) {
546 $errorcode =
'BAD_PARAMETERS';
547 $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(
584 'id' => $line->rowid,
585 'type' => $line->product_type,
586 'fk_commande' => $line->fk_commande,
587 'fk_parent_line' => $line->fk_parent_line,
588 'desc' => $line->desc,
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 'source' => $order->source,
626 'billed' => $order->billed,
627 'note_private' => $order->note_private,
628 'note_public' => $order->note_public,
629 'cond_reglement_id' => $order->cond_reglement_id,
630 'cond_reglement' => $order->cond_reglement,
631 'cond_reglement_doc' => $order->cond_reglement_doc,
632 'cond_reglement_code' => $order->cond_reglement_code,
633 'mode_reglement_id' => $order->mode_reglement_id,
634 'mode_reglement' => $order->mode_reglement,
635 'mode_reglement_code' => $order->mode_reglement_code,
637 'date_livraison' => $order->delivery_date,
639 'demand_reason_id' => $order->demand_reason_id,
640 'demand_reason_code' => $order->demand_reason_code,
642 'lines' => $linesresp
649 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
650 'orders' => $linesorders
655 $errorcode = $db->lasterrno();
656 $errorlabel = $db->lasterror();
661 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
677 global $db, $conf, $langs;
679 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
683 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
685 if ($authentication[
'entity']) {
686 $conf->entity = $authentication[
'entity'];
690 $objectresp = array();
701 $newobject->socid = $order[
'thirdparty_id'];
702 $newobject->type = $order[
'type'];
703 $newobject->ref_ext = $order[
'ref_ext'];
705 $newobject->date_lim_reglement =
dol_stringtotime($order[
'date_due'],
'dayrfc');
706 $newobject->note_private = $order[
'note_private'];
707 $newobject->note_public = $order[
'note_public'];
709 $newobject->billed = $order[
'billed'];
710 $newobject->fk_project = $order[
'project_id'];
711 $newobject->cond_reglement_id = $order[
'cond_reglement_id'];
712 $newobject->demand_reason_id = $order[
'demand_reason_id'];
713 $newobject->date_creation = $now;
715 $elementtype =
'commande';
720 $extrafields->fetch_name_optionals_label($elementtype,
true);
721 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
722 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
723 $key =
'options_'.$key;
724 $newobject->array_options[$key] = $order[$key];
729 $arrayoflines = array();
730 if (isset($order[
'lines'][
'line'][0])) {
731 $arrayoflines = $order[
'lines'][
'line'];
733 $arrayoflines = $order[
'lines'];
736 foreach ($arrayoflines as $key => $line) {
740 $newline->type = $line[
'type'];
741 $newline->desc = $line[
'desc'];
742 $newline->fk_product = $line[
'product_id'];
743 $newline->tva_tx = $line[
'vat_rate'];
744 $newline->qty = $line[
'qty'];
745 $newline->price = $line[
'price'];
746 $newline->subprice = $line[
'unitprice'];
747 $newline->total_ht = $line[
'total_net'];
748 $newline->total_tva = $line[
'total_vat'];
749 $newline->total_ttc = $line[
'total'];
750 $newline->date_start = $line[
'date_start'];
751 $newline->date_end = $line[
'date_end'];
753 $elementtype =
'commandedet';
758 $extrafields->fetch_name_optionals_label($elementtype,
true);
759 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
760 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
761 $tmpkey =
'options_'.$tmpkey;
762 $newline->array_options[$tmpkey] = $line[$tmpkey];
766 $newobject->lines[] = $newline;
771 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
772 $result = $newobject->create($fuser);
773 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
775 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
779 if ($order[
'status'] == 1) {
780 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
781 $result = $newobject->valid($fuser);
783 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
789 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
791 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
793 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
797 $errorlabel = $newobject->error;
802 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
817function validOrder($authentication, $id = 0, $id_warehouse = 0)
819 global $db, $conf, $langs;
821 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".$id.
" id_warehouse=".$id_warehouse);
824 $objectresp = array();
828 if ($authentication[
'entity']) {
829 $conf->entity = $authentication[
'entity'];
836 if ($fuser->hasRight(
'commande',
'lire')) {
838 $result = $order->fetch($id);
840 $order->fetch_thirdparty();
843 $result = $order->valid($fuser, $id_warehouse);
847 $outputlangs = $langs;
848 $order->generateDocument($order->model_pdf, $outputlangs);
853 $errorlabel = $order->error;
859 $errorlabel = $order->error;
865 $errorlabel =
'Bad permission';
870 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
873 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
888 global $db, $conf, $langs;
890 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
892 if ($authentication[
'entity']) {
893 $conf->entity = $authentication[
'entity'];
897 $objectresp = array();
903 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
906 $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'] :
''));
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' =>
''),
979 } elseif ($objectfound) {
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"));
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.