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);
79$server->wsdl->schemaTargetNamespace = $ns;
83$server->wsdl->addComplexType(
90 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
91 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
92 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
93 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
94 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string')
98$server->wsdl->addComplexType(
105 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
106 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
111 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
112 'type' => array(
'name' =>
'type',
'type' =>
'xsd:int'),
113 'fk_commande' => array(
'name' =>
'fk_commande',
'type' =>
'xsd:int'),
114 'fk_parent_line' => array(
'name' =>
'fk_parent_line',
'type' =>
'xsd:int'),
115 'desc' => array(
'name' =>
'desc',
'type' =>
'xsd:string'),
116 'qty' => array(
'name' =>
'qty',
'type' =>
'xsd:double'),
117 'price' => array(
'name' =>
'price',
'type' =>
'xsd:double'),
118 'unitprice' => array(
'name' =>
'unitprice',
'type' =>
'xsd:double'),
119 'vat_rate' => array(
'name' =>
'vat_rate',
'type' =>
'xsd:double'),
121 'remise' => array(
'name' =>
'remise',
'type' =>
'xsd:double'),
122 'remise_percent' => array(
'name' =>
'remise_percent',
'type' =>
'xsd:double'),
124 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
125 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
126 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
128 'date_start' => array(
'name' =>
'date_start',
'type' =>
'xsd:date'),
129 'date_end' => array(
'name' =>
'date_end',
'type' =>
'xsd:date'),
132 'product_id' => array(
'name' =>
'product_id',
'type' =>
'xsd:int'),
133 'product_ref' => array(
'name' =>
'product_ref',
'type' =>
'xsd:string'),
134 'product_label' => array(
'name' =>
'product_label',
'type' =>
'xsd:string'),
135 'product_desc' => array(
'name' =>
'product_desc',
'type' =>
'xsd:string')
138$elementtype =
'commandedet';
143$extrafields->fetch_name_optionals_label($elementtype,
true);
144$extrafield_line_array =
null;
145if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
146 $extrafield_line_array = array();
148if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
149 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
151 $type = $extrafields->attributes[$elementtype][
'type'][$key];
152 if ($type ==
'date' || $type ==
'datetime') {
153 $type =
'xsd:dateTime';
155 $type =
'xsd:string';
157 $extrafield_line_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
160if (is_array($extrafield_line_array)) {
161 $line_fields = array_merge($line_fields, $extrafield_line_array);
165$server->wsdl->addComplexType(
189$server->wsdl->addComplexType(
198 'type' =>
'tns:line',
200 'maxOccurs' =>
'unbounded'
205$order_fields = array(
206 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
207 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
208 'ref_client' => array(
'name' =>
'ref_client',
'type' =>
'xsd:string'),
209 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
210 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
211 'status' => array(
'name' =>
'status',
'type' =>
'xsd:int'),
212 'billed' => array(
'name' =>
'billed',
'type' =>
'xsd:string'),
213 'total_net' => array(
'name' =>
'total_net',
'type' =>
'xsd:double'),
214 'total_vat' => array(
'name' =>
'total_vat',
'type' =>
'xsd:double'),
215 'total_localtax1' => array(
'name' =>
'total_localtax1',
'type' =>
'xsd:double'),
216 'total_localtax2' => array(
'name' =>
'total_localtax2',
'type' =>
'xsd:double'),
217 'total' => array(
'name' =>
'total',
'type' =>
'xsd:double'),
218 'date' => array(
'name' =>
'date',
'type' =>
'xsd:date'),
219 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
220 'date_validation' => array(
'name' =>
'date_validation',
'type' =>
'xsd:dateTime'),
221 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
222 'source' => array(
'name' =>
'source',
'type' =>
'xsd:string'),
223 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
224 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
225 'project_id' => array(
'name' =>
'project_id',
'type' =>
'xsd:string'),
227 'mode_reglement_id' => array(
'name' =>
'mode_reglement_id',
'type' =>
'xsd:string'),
228 'mode_reglement_code' => array(
'name' =>
'mode_reglement_code',
'type' =>
'xsd:string'),
229 'mode_reglement' => array(
'name' =>
'mode_reglement',
'type' =>
'xsd:string'),
230 'cond_reglement_id' => array(
'name' =>
'cond_reglement_id',
'type' =>
'xsd:string'),
231 'cond_reglement_code' => array(
'name' =>
'cond_reglement_code',
'type' =>
'xsd:string'),
232 'cond_reglement' => array(
'name' =>
'cond_reglement',
'type' =>
'xsd:string'),
233 'cond_reglement_doc' => array(
'name' =>
'cond_reglement_doc',
'type' =>
'xsd:string'),
235 'date_livraison' => array(
'name' =>
'date_livraison',
'type' =>
'xsd:date'),
236 'demand_reason_id' => array(
'name' =>
'demand_reason_id',
'type' =>
'xsd:string'),
238 'lines' => array(
'name' =>
'lines',
'type' =>
'tns:LinesArray2')
241$elementtype =
'commande';
246$extrafields->fetch_name_optionals_label($elementtype,
true);
247$extrafield_array =
null;
248if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
249 $extrafield_array = array();
251if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
252 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
254 $type = $extrafields->attributes[$elementtype][
'type'][$key];
255 if ($type ==
'date' || $type ==
'datetime') {
256 $type =
'xsd:dateTime';
258 $type =
'xsd:string';
260 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
263if (is_array($extrafield_array)) {
264 $order_fields = array_merge($order_fields, $extrafield_array);
267$server->wsdl->addComplexType(
292$server->wsdl->addComplexType(
301 'type' =>
'tns:order',
303 'maxOccurs' =>
'unbounded'
314$styleuse =
'encoded';
320 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
321 array(
'result' =>
'tns:result',
'order' =>
'tns:order'),
326 'WS to get a particular invoice'
330 'getOrdersForThirdParty',
331 array(
'authentication' =>
'tns:authentication',
'idthirdparty' =>
'xsd:string'),
332 array(
'result' =>
'tns:result',
'orders' =>
'tns:OrdersArray2'),
334 $ns.
'#getOrdersForThirdParty',
337 'WS to get all orders of a third party'
342 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
343 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
348 'WS to create an order'
353 array(
'authentication' =>
'tns:authentication',
'order' =>
'tns:order'),
354 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
359 'WS to update an order'
364 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'id_warehouse' =>
'xsd:string'),
365 array(
'result' =>
'tns:result'),
370 'WS to valid an order'
382function getOrder($authentication,
$id = 0, $ref =
'', $ref_ext =
'')
386 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
388 if ($authentication[
'entity']) {
389 $conf->entity = $authentication[
'entity'];
393 $objectresp = array();
402 $socid = $fuser->socid;
406 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
408 $errorcode =
'BAD_PARAMETERS';
409 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
413 $fuser->loadRights();
415 if ($fuser->hasRight(
'commande',
'lire')) {
417 $result = $order->fetch(
$id, $ref, $ref_ext);
420 if ($socid && $socid != $order->socid) {
422 $errorcode =
'PERMISSION_DENIED';
423 $errorlabel =
'User does not have permission for this request';
427 $linesresp = array();
429 foreach ($order->lines as $line) {
431 $linesresp[] = array(
432 'id' => $line->rowid,
433 'fk_commande' => $line->fk_commande,
434 'fk_parent_line' => $line->fk_parent_line,
435 'desc' => $line->desc,
437 'price' => $line->price,
438 'unitprice' => $line->subprice,
439 'vat_rate' => $line->tva_tx,
440 'remise' => $line->remise,
441 'remise_percent' => $line->remise_percent,
442 'product_id' => $line->fk_product,
443 'product_type' => $line->product_type,
444 'total_net' => $line->total_ht,
445 'total_vat' => $line->total_tva,
446 'total' => $line->total_ttc,
447 'date_start' => $line->date_start,
448 'date_end' => $line->date_end,
449 'product_ref' => $line->product_ref,
450 'product_label' => $line->product_label,
451 'product_desc' => $line->product_desc
458 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
461 'ref' => $order->ref,
462 'ref_client' => $order->ref_client,
463 'ref_ext' => $order->ref_ext,
464 'thirdparty_id' => $order->socid,
465 'status' => $order->statut,
467 'total_net' => $order->total_ht,
468 'total_vat' => $order->total_tva,
469 'total_localtax1' => $order->total_localtax1,
470 'total_localtax2' => $order->total_localtax2,
471 'total' => $order->total_ttc,
472 'project_id' => $order->fk_project,
474 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
475 'date_creation' => $order->date_creation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
476 'date_validation' => $order->date_validation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
477 'date_modification' => $order->date_modification ?
dol_print_date($order->date_modification,
'dayhourrfc') :
'',
479 'source' => $order->source,
480 'billed' => $order->billed,
481 'note_private' => $order->note_private,
482 'note_public' => $order->note_public,
483 'cond_reglement_id' => $order->cond_reglement_id,
484 'cond_reglement_code' => $order->cond_reglement_code,
485 'cond_reglement' => $order->cond_reglement,
486 'mode_reglement_id' => $order->mode_reglement_id,
487 'mode_reglement_code' => $order->mode_reglement_code,
488 'mode_reglement' => $order->mode_reglement,
490 'date_livraison' => $order->delivery_date,
492 'demand_reason_id' => $order->demand_reason_id,
493 'demand_reason_code' => $order->demand_reason_code,
495 'lines' => $linesresp
500 $errorcode =
'NOT_FOUND';
501 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
505 $errorcode =
'PERMISSION_DENIED';
506 $errorlabel =
'User does not have permission for this request';
511 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
529 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
531 if ($authentication[
'entity']) {
532 $conf->entity = $authentication[
'entity'];
536 $objectresp = array();
543 $socid = $fuser->socid;
549 if (!$error && empty($idthirdparty)) {
551 $errorcode =
'BAD_PARAMETERS';
552 $errorlabel =
'Parameter id is not provided';
556 $linesorders = array();
558 $sql =
'SELECT c.rowid as orderid';
559 $sql .=
' FROM '.MAIN_DB_PREFIX.
'commande as c';
560 $sql .=
" WHERE c.entity = ".$conf->entity;
561 if ($idthirdparty !=
'all') {
562 $sql .=
" AND c.fk_soc = ".((int) $idthirdparty);
566 $resql = $db->query($sql);
568 $num = $db->num_rows($resql);
572 $obj = $db->fetch_object($resql);
575 $order->fetch($obj->orderid);
578 if ($socid && ($socid != $order->socid)) {
580 $errorcode =
'PERMISSION_DENIED';
581 $errorlabel = $order->socid.
' User does not have permission for this request';
586 $linesresp = array();
587 foreach ($order->lines as $line) {
588 $linesresp[] = array(
589 'id' => $line->rowid,
590 'type' => $line->product_type,
591 'fk_commande' => $line->fk_commande,
592 'fk_parent_line' => $line->fk_parent_line,
593 'desc' => $line->desc,
595 'price' => $line->price,
596 'unitprice' => $line->subprice,
597 'tva_tx' => $line->tva_tx,
598 'remise' => $line->remise,
599 'remise_percent' => $line->remise_percent,
600 'total_net' => $line->total_ht,
601 'total_vat' => $line->total_tva,
602 'total' => $line->total_ttc,
603 'date_start' => $line->date_start,
604 'date_end' => $line->date_end,
605 'product_id' => $line->fk_product,
606 'product_ref' => $line->product_ref,
607 'product_label' => $line->product_label,
608 'product_desc' => $line->product_desc
613 $linesorders[] = array(
615 'ref' => $order->ref,
616 'ref_client' => $order->ref_client,
617 'ref_ext' => $order->ref_ext,
618 'socid' => $order->socid,
619 'status' => $order->statut,
621 'total_net' => $order->total_ht,
622 'total_vat' => $order->total_tva,
623 'total_localtax1' => $order->total_localtax1,
624 'total_localtax2' => $order->total_localtax2,
625 'total' => $order->total_ttc,
626 'project_id' => $order->fk_project,
628 'date' => $order->date_commande ?
dol_print_date($order->date_commande,
'dayrfc') :
'',
630 'source' => $order->source,
631 'billed' => $order->billed,
632 'note_private' => $order->note_private,
633 'note_public' => $order->note_public,
634 'cond_reglement_id' => $order->cond_reglement_id,
635 'cond_reglement' => $order->cond_reglement,
636 'cond_reglement_doc' => $order->cond_reglement_doc,
637 'cond_reglement_code' => $order->cond_reglement_code,
638 'mode_reglement_id' => $order->mode_reglement_id,
639 'mode_reglement' => $order->mode_reglement,
640 'mode_reglement_code' => $order->mode_reglement_code,
642 'date_livraison' => $order->delivery_date,
644 'demand_reason_id' => $order->demand_reason_id,
645 'demand_reason_code' => $order->demand_reason_code,
647 'lines' => $linesresp
654 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
655 'orders' => $linesorders
660 $errorcode = $db->lasterrno();
661 $errorlabel = $db->lasterror();
666 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
682 global $db,
$conf, $langs;
684 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
689 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
691 if ($authentication[
'entity']) {
692 $conf->entity = $authentication[
'entity'];
696 $objectresp = array();
708 $newobject->socid = $order[
'thirdparty_id'];
710 $newobject->type = $order[
'type'];
711 $newobject->ref_ext = $order[
'ref_ext'];
714 $newobject->date_lim_reglement =
dol_stringtotime((
string) $order[
'date_due'],
'dayrfc');
715 $newobject->note_private = $order[
'note_private'];
716 $newobject->note_public = $order[
'note_public'];
718 $newobject->billed = (int) $order[
'billed'];
719 $newobject->fk_project = (int) $order[
'project_id'];
720 $newobject->cond_reglement_id = (int) $order[
'cond_reglement_id'];
721 $newobject->demand_reason_id = (int) $order[
'demand_reason_id'];
722 $newobject->date_creation = $now;
724 $elementtype =
'commande';
729 $extrafields->fetch_name_optionals_label($elementtype,
true);
730 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
731 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
732 $key =
'options_'.$key;
733 $newobject->array_options[$key] = $order[$key];
738 $arrayoflines = array();
739 if (isset($order[
'lines'][
'line'][0])) {
740 $arrayoflines = $order[
'lines'][
'line'];
742 $arrayoflines = $order[
'lines'];
744 if (!is_array($arrayoflines)) {
745 $arrayoflines = array();
748 foreach ($arrayoflines as $key => $line) {
752 $newline->type = $line[
'type'];
753 $newline->desc = $line[
'desc'];
754 $newline->fk_product = $line[
'product_id'];
755 $newline->tva_tx = $line[
'vat_rate'];
756 $newline->qty = $line[
'qty'];
757 $newline->price = $line[
'price'];
758 $newline->subprice = $line[
'unitprice'];
759 $newline->total_ht = $line[
'total_net'];
760 $newline->total_tva = $line[
'total_vat'];
761 $newline->total_ttc = $line[
'total'];
762 $newline->date_start = $line[
'date_start'];
763 $newline->date_end = $line[
'date_end'];
765 $elementtype =
'commandedet';
770 $extrafields->fetch_name_optionals_label($elementtype,
true);
771 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
772 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
773 $tmpkey =
'options_'.$tmpkey;
774 $newline->array_options[$tmpkey] = $line[$tmpkey];
778 $newobject->lines[] = $newline;
783 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
784 $result = $newobject->create($fuser);
785 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
787 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
791 if ($order[
'status'] == 1) {
792 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
793 $result = $newobject->valid($fuser);
795 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
801 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
803 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
805 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
809 $errorlabel = $newobject->error;
814 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
831 global $db,
$conf, $langs;
833 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".
$id.
" id_warehouse=".$id_warehouse);
836 $objectresp = array();
840 if ($authentication[
'entity']) {
841 $conf->entity = $authentication[
'entity'];
846 $fuser->loadRights();
848 if ($fuser->hasRight(
'commande',
'lire')) {
850 $result = $order->fetch(
$id);
852 $order->fetch_thirdparty();
855 $result = $order->valid($fuser, $id_warehouse);
859 $outputlangs = $langs;
860 $order->generateDocument($order->model_pdf, $outputlangs);
865 $errorlabel = $order->error;
871 $errorlabel = $order->error;
877 $errorlabel =
'Bad permission';
882 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
885 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
900 global $db,
$conf, $langs;
902 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
904 if ($authentication[
'entity']) {
905 $conf->entity = $authentication[
'entity'];
909 $objectresp = array();
915 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
918 $errorlabel =
"Order id or ref or ref_ext is mandatory.";
922 $objectfound =
false;
924 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
927 $result =
$object->fetch((
int) $order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
934 if (isset($order[
'status'])) {
935 if ($order[
'status'] == -1) {
936 $result =
$object->cancel($fuser);
938 if ($order[
'status'] == 1) {
939 $result =
$object->valid($fuser);
942 $outputlangs = $langs;
946 if ($order[
'status'] == 0) {
947 $result =
$object->set_reopen($fuser);
949 if ($order[
'status'] == 3) {
950 $result =
$object->cloture($fuser);
954 if (isset($order[
'billed'])) {
955 if ($order[
'billed']) {
956 $result =
$object->classifyBilled($fuser);
958 if (!$order[
'billed']) {
959 $result =
$object->classifyUnBilled($fuser);
963 $elementtype =
'commande';
968 $extrafields->fetch_name_optionals_label($elementtype,
true);
969 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
970 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
971 $key =
'options_'.$key;
972 if (isset($order[$key])) {
973 $result =
$object->setValueFrom($key, $order[$key],
'commande_extrafields');
983 if ((!$error) && ($objectfound)) {
986 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
991 } elseif ($objectfound) {
998 $errorcode =
'NOT_FOUND';
999 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
1004 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
1012$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.