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';
688 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
690 if ($authentication[
'entity']) {
691 $conf->entity = $authentication[
'entity'];
695 $objectresp = array();
707 $newobject->socid = $order[
'thirdparty_id'];
708 $newobject->type = $order[
'type'];
709 $newobject->ref_ext = $order[
'ref_ext'];
711 $newobject->date_lim_reglement =
dol_stringtotime($order[
'date_due'],
'dayrfc');
712 $newobject->note_private = $order[
'note_private'];
713 $newobject->note_public = $order[
'note_public'];
715 $newobject->billed = (int) $order[
'billed'];
716 $newobject->fk_project = (int) $order[
'project_id'];
717 $newobject->cond_reglement_id = (int) $order[
'cond_reglement_id'];
718 $newobject->demand_reason_id = (int) $order[
'demand_reason_id'];
719 $newobject->date_creation = $now;
721 $elementtype =
'commande';
726 $extrafields->fetch_name_optionals_label($elementtype,
true);
727 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
728 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
729 $key =
'options_'.$key;
730 $newobject->array_options[$key] = $order[$key];
735 $arrayoflines = array();
736 if (isset($order[
'lines'][
'line'][0])) {
737 $arrayoflines = $order[
'lines'][
'line'];
739 $arrayoflines = $order[
'lines'];
741 if (!is_array($arrayoflines)) {
742 $arrayoflines = array();
745 foreach ($arrayoflines as $key => $line) {
749 $newline->type = $line[
'type'];
750 $newline->desc = $line[
'desc'];
751 $newline->fk_product = $line[
'product_id'];
752 $newline->tva_tx = $line[
'vat_rate'];
753 $newline->qty = $line[
'qty'];
754 $newline->price = $line[
'price'];
755 $newline->subprice = $line[
'unitprice'];
756 $newline->total_ht = $line[
'total_net'];
757 $newline->total_tva = $line[
'total_vat'];
758 $newline->total_ttc = $line[
'total'];
759 $newline->date_start = $line[
'date_start'];
760 $newline->date_end = $line[
'date_end'];
762 $elementtype =
'commandedet';
767 $extrafields->fetch_name_optionals_label($elementtype,
true);
768 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
769 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
770 $tmpkey =
'options_'.$tmpkey;
771 $newline->array_options[$tmpkey] = $line[$tmpkey];
775 $newobject->lines[] = $newline;
780 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
781 $result = $newobject->create($fuser);
782 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
784 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
788 if ($order[
'status'] == 1) {
789 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
790 $result = $newobject->valid($fuser);
792 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
798 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
800 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
802 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
806 $errorlabel = $newobject->error;
811 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
828 global $db,
$conf, $langs;
830 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".
$id.
" id_warehouse=".$id_warehouse);
833 $objectresp = array();
837 if ($authentication[
'entity']) {
838 $conf->entity = $authentication[
'entity'];
843 $fuser->loadRights();
845 if ($fuser->hasRight(
'commande',
'lire')) {
847 $result = $order->fetch(
$id);
849 $order->fetch_thirdparty();
852 $result = $order->valid($fuser, $id_warehouse);
856 $outputlangs = $langs;
857 $order->generateDocument($order->model_pdf, $outputlangs);
862 $errorlabel = $order->error;
868 $errorlabel = $order->error;
874 $errorlabel =
'Bad permission';
879 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
882 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
897 global $db,
$conf, $langs;
899 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
901 if ($authentication[
'entity']) {
902 $conf->entity = $authentication[
'entity'];
906 $objectresp = array();
912 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
915 $errorlabel =
"Order id or ref or ref_ext is mandatory.";
919 $objectfound =
false;
921 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
924 $result =
$object->fetch($order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
931 if (isset($order[
'status'])) {
932 if ($order[
'status'] == -1) {
933 $result =
$object->cancel($fuser);
935 if ($order[
'status'] == 1) {
936 $result =
$object->valid($fuser);
939 $outputlangs = $langs;
940 $object->generateDocument($order->model_pdf, $outputlangs);
943 if ($order[
'status'] == 0) {
944 $result =
$object->set_reopen($fuser);
946 if ($order[
'status'] == 3) {
947 $result =
$object->cloture($fuser);
951 if (isset($order[
'billed'])) {
952 if ($order[
'billed']) {
953 $result =
$object->classifyBilled($fuser);
955 if (!$order[
'billed']) {
956 $result =
$object->classifyUnBilled($fuser);
960 $elementtype =
'commande';
965 $extrafields->fetch_name_optionals_label($elementtype,
true);
966 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
967 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
968 $key =
'options_'.$key;
969 if (isset($order[$key])) {
970 $result =
$object->setValueFrom($key, $order[$key],
'commande_extrafields');
980 if ((!$error) && ($objectfound)) {
983 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
988 } elseif ($objectfound) {
995 $errorcode =
'NOT_FOUND';
996 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
1001 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
1009$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 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.