25 if (!defined(
"NOCSRFCHECK")) {
26 define(
"NOCSRFCHECK",
'1');
29 require
'../master.inc.php';
30 require_once NUSOAP_PATH.
'/nusoap.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
33 require_once DOL_DOCUMENT_ROOT.
"/commande/class/commande.class.php";
36 dol_syslog(
"Call Dolibarr webservices interfaces");
41 if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
42 $langs->load(
"admin");
43 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
44 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
45 print $langs->trans(
"ToActivateModule");
50 $server =
new nusoap_server();
51 $server->soap_defencoding =
'UTF-8';
52 $server->decode_utf8 =
false;
53 $ns =
'http://www.dolibarr.org/ns/';
54 $server->configureWSDL(
'WebServicesDolibarrOrder', $ns);
55 $server->wsdl->schemaTargetNamespace = $ns;
59 $server->wsdl->addComplexType(
66 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
67 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
68 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
69 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
70 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string')
74 $server->wsdl->addComplexType(
81 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
82 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
87 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
88 'type' => array(
'name'=>
'type',
'type'=>
'xsd:int'),
89 'fk_commande' => array(
'name'=>
'fk_commande',
'type'=>
'xsd:int'),
90 'fk_parent_line' => array(
'name'=>
'fk_parent_line',
'type'=>
'xsd:int'),
91 'desc' => array(
'name'=>
'desc',
'type'=>
'xsd:string'),
92 'qty' => array(
'name'=>
'qty',
'type'=>
'xsd:double'),
93 'price' => array(
'name'=>
'price',
'type'=>
'xsd:double'),
94 'unitprice' => array(
'name'=>
'unitprice',
'type'=>
'xsd:double'),
95 'vat_rate' => array(
'name'=>
'vat_rate',
'type'=>
'xsd:double'),
97 'remise' => array(
'name'=>
'remise',
'type'=>
'xsd:double'),
98 'remise_percent' => array(
'name'=>
'remise_percent',
'type'=>
'xsd:double'),
100 'total_net' => array(
'name'=>
'total_net',
'type'=>
'xsd:double'),
101 'total_vat' => array(
'name'=>
'total_vat',
'type'=>
'xsd:double'),
102 'total' => array(
'name'=>
'total',
'type'=>
'xsd:double'),
104 'date_start' => array(
'name'=>
'date_start',
'type'=>
'xsd:date'),
105 'date_end' => array(
'name'=>
'date_end',
'type'=>
'xsd:date'),
108 'product_id' => array(
'name'=>
'product_id',
'type'=>
'xsd:int'),
109 'product_ref' => array(
'name'=>
'product_ref',
'type'=>
'xsd:string'),
110 'product_label' => array(
'name'=>
'product_label',
'type'=>
'xsd:string'),
111 'product_desc' => array(
'name'=>
'product_desc',
'type'=>
'xsd:string')
114 $elementtype =
'commandedet';
119 $extrafields->fetch_name_optionals_label($elementtype,
true);
120 $extrafield_line_array =
null;
121 if (is_array($extrafields) && count($extrafields) > 0) {
122 $extrafield_line_array = array();
124 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
125 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
127 $type = $extrafields->attributes[$elementtype][
'type'][$key];
128 if ($type ==
'date' || $type ==
'datetime') {
129 $type =
'xsd:dateTime';
131 $type =
'xsd:string';
133 $extrafield_line_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
136 if (is_array($extrafield_line_array)) {
137 $line_fields = array_merge($line_fields, $extrafield_line_array);
141 $server->wsdl->addComplexType(
165 $server->wsdl->addComplexType(
174 'type' =>
'tns:line',
176 'maxOccurs' =>
'unbounded'
181 $order_fields = array(
182 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
183 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
184 'ref_client' => array(
'name'=>
'ref_client',
'type'=>
'xsd:string'),
185 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
186 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
187 'status' => array(
'name'=>
'status',
'type'=>
'xsd:int'),
188 'billed' => array(
'name'=>
'billed',
'type'=>
'xsd:string'),
189 'total_net' => array(
'name'=>
'total_net',
'type'=>
'xsd:double'),
190 'total_vat' => array(
'name'=>
'total_vat',
'type'=>
'xsd:double'),
191 'total_localtax1' => array(
'name'=>
'total_localtax1',
'type'=>
'xsd:double'),
192 'total_localtax2' => array(
'name'=>
'total_localtax2',
'type'=>
'xsd:double'),
193 'total' => array(
'name'=>
'total',
'type'=>
'xsd:double'),
194 'date' => array(
'name'=>
'date',
'type'=>
'xsd:date'),
195 'date_creation' => array(
'name'=>
'date_creation',
'type'=>
'xsd:dateTime'),
196 'date_validation' => array(
'name'=>
'date_validation',
'type'=>
'xsd:dateTime'),
197 'date_modification' => array(
'name'=>
'date_modification',
'type'=>
'xsd:dateTime'),
198 'remise' => array(
'name'=>
'remise',
'type'=>
'xsd:string'),
199 'remise_percent' => array(
'name'=>
'remise_percent',
'type'=>
'xsd:string'),
200 'remise_absolue' => array(
'name'=>
'remise_absolue',
'type'=>
'xsd:string'),
201 'source' => array(
'name'=>
'source',
'type'=>
'xsd:string'),
202 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
203 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
204 'project_id' => array(
'name'=>
'project_id',
'type'=>
'xsd:string'),
206 'mode_reglement_id' => array(
'name'=>
'mode_reglement_id',
'type'=>
'xsd:string'),
207 'mode_reglement_code' => array(
'name'=>
'mode_reglement_code',
'type'=>
'xsd:string'),
208 'mode_reglement' => array(
'name'=>
'mode_reglement',
'type'=>
'xsd:string'),
209 'cond_reglement_id' => array(
'name'=>
'cond_reglement_id',
'type'=>
'xsd:string'),
210 'cond_reglement_code' => array(
'name'=>
'cond_reglement_code',
'type'=>
'xsd:string'),
211 'cond_reglement' => array(
'name'=>
'cond_reglement',
'type'=>
'xsd:string'),
212 'cond_reglement_doc' => array(
'name'=>
'cond_reglement_doc',
'type'=>
'xsd:string'),
214 'date_livraison' => array(
'name'=>
'date_livraison',
'type'=>
'xsd:date'),
215 'demand_reason_id' => array(
'name'=>
'demand_reason_id',
'type'=>
'xsd:string'),
217 'lines' => array(
'name'=>
'lines',
'type'=>
'tns:LinesArray2')
220 $elementtype =
'commande';
225 $extrafields->fetch_name_optionals_label($elementtype,
true);
226 $extrafield_array =
null;
227 if (is_array($extrafields) && count($extrafields) > 0) {
228 $extrafield_array = array();
230 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
231 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
233 $type = $extrafields->attributes[$elementtype][
'type'][$key];
234 if ($type ==
'date' || $type ==
'datetime') {
235 $type =
'xsd:dateTime';
237 $type =
'xsd:string';
239 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
242 if (is_array($extrafield_array)) {
243 $order_fields = array_merge($order_fields, $extrafield_array);
246 $server->wsdl->addComplexType(
271 $server->wsdl->addComplexType(
280 'type' =>
'tns:order',
282 'maxOccurs' =>
'unbounded'
293 $styleuse =
'encoded';
299 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
300 array(
'result'=>
'tns:result',
'order'=>
'tns:order'),
305 'WS to get a particular invoice'
309 'getOrdersForThirdParty',
310 array(
'authentication'=>
'tns:authentication',
'idthirdparty'=>
'xsd:string'),
311 array(
'result'=>
'tns:result',
'orders'=>
'tns:OrdersArray2'),
313 $ns.
'#getOrdersForThirdParty',
316 'WS to get all orders of a third party'
321 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
322 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
327 'WS to create an order'
332 array(
'authentication'=>
'tns:authentication',
'order'=>
'tns:order'),
333 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
338 'WS to update an order'
343 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'id_warehouse'=>
'xsd:string'),
344 array(
'result'=>
'tns:result'),
349 'WS to valid an order'
361 function getOrder($authentication, $id =
'', $ref =
'', $ref_ext =
'')
365 dol_syslog(
"Function: getOrder login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
367 if ($authentication[
'entity']) {
368 $conf->entity = $authentication[
'entity'];
372 $objectresp = array();
373 $errorcode =
''; $errorlabel =
'';
380 $socid = $fuser->socid;
384 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
386 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
392 if ($fuser->rights->commande->lire) {
394 $result = $order->fetch($id, $ref, $ref_ext);
397 if ($socid && $socid != $order->socid) {
399 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
403 $linesresp = array();
405 foreach ($order->lines as $line) {
407 $linesresp[] = array(
409 'fk_commande'=>$line->fk_commande,
410 'fk_parent_line'=>$line->fk_parent_line,
413 'price'=>$line->price,
414 'unitprice'=>$line->subprice,
415 'vat_rate'=>$line->tva_tx,
416 'remise'=>$line->remise,
417 'remise_percent'=>$line->remise_percent,
418 'product_id'=>$line->fk_product,
419 'product_type'=>$line->product_type,
420 'total_net'=>$line->total_ht,
421 'total_vat'=>$line->total_tva,
422 'total'=>$line->total_ttc,
423 'date_start'=>$line->date_start,
424 'date_end'=>$line->date_end,
425 'product_ref'=>$line->product_ref,
426 'product_label'=>$line->product_label,
427 'product_desc'=>$line->product_desc
434 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
437 'ref' => $order->ref,
438 'ref_client' => $order->ref_client,
439 'ref_ext' => $order->ref_ext,
440 'thirdparty_id' => $order->socid,
441 'status' => $order->statut,
443 'total_net' => $order->total_ht,
444 'total_vat' => $order->total_tva,
445 'total_localtax1' => $order->total_localtax1,
446 'total_localtax2' => $order->total_localtax2,
447 'total' => $order->total_ttc,
448 'project_id' => $order->fk_project,
450 'date' => $order->date ?
dol_print_date($order->date,
'dayrfc') :
'',
451 'date_creation' => $order->date_creation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
452 'date_validation' => $order->date_validation ?
dol_print_date($order->date_creation,
'dayhourrfc') :
'',
453 'date_modification' => $order->date_modification ?
dol_print_date($order->date_modification,
'dayhourrfc') :
'',
455 'remise' => $order->remise,
456 'remise_percent' => $order->remise_percent,
457 'remise_absolue' => $order->remise_absolue,
459 'source' => $order->source,
460 'billed' => $order->billed,
461 'note_private' => $order->note_private,
462 'note_public' => $order->note_public,
463 'cond_reglement_id' => $order->cond_reglement_id,
464 'cond_reglement_code' => $order->cond_reglement_code,
465 'cond_reglement' => $order->cond_reglement,
466 'mode_reglement_id' => $order->mode_reglement_id,
467 'mode_reglement_code' => $order->mode_reglement_code,
468 'mode_reglement' => $order->mode_reglement,
470 'date_livraison' => $order->delivery_date,
472 'demand_reason_id' => $order->demand_reason_id,
473 'demand_reason_code' => $order->demand_reason_code,
475 'lines' => $linesresp
480 $errorcode =
'NOT_FOUND';
481 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
485 $errorcode =
'PERMISSION_DENIED';
486 $errorlabel =
'User does not have permission for this request';
491 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
509 dol_syslog(
"Function: getOrdersForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
511 if ($authentication[
'entity']) {
512 $conf->entity = $authentication[
'entity'];
516 $objectresp = array();
517 $errorcode =
''; $errorlabel =
'';
522 $socid = $fuser->socid;
526 if (!$error && empty($idthirdparty)) {
528 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
'Parameter id is not provided';
532 $linesorders = array();
534 $sql =
'SELECT c.rowid as orderid';
535 $sql .=
' FROM '.MAIN_DB_PREFIX.
'commande as c';
536 $sql .=
" WHERE c.entity = ".$conf->entity;
537 if ($idthirdparty !=
'all') {
538 $sql .=
" AND c.fk_soc = ".((int) $idthirdparty);
542 $resql = $db->query($sql);
544 $num = $db->num_rows(
$resql);
548 $obj = $db->fetch_object(
$resql);
551 $order->fetch($obj->orderid);
554 if ($socid && ($socid != $order->socid)) {
556 $errorcode =
'PERMISSION_DENIED';
557 $errorlabel = $order->socid.
' User does not have permission for this request';
562 $linesresp = array();
563 foreach ($order->lines as $line) {
564 $linesresp[] = array(
566 'type'=>$line->product_type,
567 'fk_commande'=>$line->fk_commande,
568 'fk_parent_line'=>$line->fk_parent_line,
571 'price'=>$line->price,
572 'unitprice'=>$line->subprice,
573 'tva_tx'=>$line->tva_tx,
574 'remise'=>$line->remise,
575 'remise_percent'=>$line->remise_percent,
576 'total_net'=>$line->total_ht,
577 'total_vat'=>$line->total_tva,
578 'total'=>$line->total_ttc,
579 'date_start'=>$line->date_start,
580 'date_end'=>$line->date_end,
581 'product_id'=>$line->fk_product,
582 'product_ref'=>$line->product_ref,
583 'product_label'=>$line->product_label,
584 'product_desc'=>$line->product_desc
589 $linesorders[] = array(
591 'ref' => $order->ref,
592 'ref_client' => $order->ref_client,
593 'ref_ext' => $order->ref_ext,
594 'socid' => $order->socid,
595 'status' => $order->statut,
597 'total_net' => $order->total_ht,
598 'total_vat' => $order->total_tva,
599 'total_localtax1' => $order->total_localtax1,
600 'total_localtax2' => $order->total_localtax2,
601 'total' => $order->total_ttc,
602 'project_id' => $order->fk_project,
604 'date' => $order->date_commande ?
dol_print_date($order->date_commande,
'dayrfc') :
'',
606 'remise' => $order->remise,
607 'remise_percent' => $order->remise_percent,
608 'remise_absolue' => $order->remise_absolue,
610 'source' => $order->source,
611 'billed' => $order->billed,
612 'note_private' => $order->note_private,
613 'note_public' => $order->note_public,
614 'cond_reglement_id' => $order->cond_reglement_id,
615 'cond_reglement' => $order->cond_reglement,
616 'cond_reglement_doc' => $order->cond_reglement_doc,
617 'cond_reglement_code' => $order->cond_reglement_code,
618 'mode_reglement_id' => $order->mode_reglement_id,
619 'mode_reglement' => $order->mode_reglement,
620 'mode_reglement_code' => $order->mode_reglement_code,
622 'date_livraison' => $order->delivery_date,
624 'demand_reason_id' => $order->demand_reason_id,
625 'demand_reason_code' => $order->demand_reason_code,
627 'lines' => $linesresp
634 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
635 'orders'=>$linesorders
640 $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
645 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
661 global $db, $conf, $langs;
663 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
667 dol_syslog(
"Function: createOrder login=".$authentication[
'login'].
" socid :".$order[
'socid']);
669 if ($authentication[
'entity']) {
670 $conf->entity = $authentication[
'entity'];
674 $objectresp = array();
685 $newobject->socid = $order[
'thirdparty_id'];
686 $newobject->type = $order[
'type'];
687 $newobject->ref_ext = $order[
'ref_ext'];
689 $newobject->date_lim_reglement =
dol_stringtotime($order[
'date_due'],
'dayrfc');
690 $newobject->note_private = $order[
'note_private'];
691 $newobject->note_public = $order[
'note_public'];
693 $newobject->billed = $order[
'billed'];
694 $newobject->fk_project = $order[
'project_id'];
695 $newobject->cond_reglement_id = $order[
'cond_reglement_id'];
696 $newobject->demand_reason_id = $order[
'demand_reason_id'];
697 $newobject->date_creation = $now;
699 $elementtype =
'commande';
704 $extrafields->fetch_name_optionals_label($elementtype,
true);
705 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
706 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
707 $key =
'options_'.$key;
708 $newobject->array_options[$key] = $order[$key];
713 $arrayoflines = array();
714 if (isset($order[
'lines'][
'line'][0])) {
715 $arrayoflines = $order[
'lines'][
'line'];
717 $arrayoflines = $order[
'lines'];
720 foreach ($arrayoflines as $key => $line) {
724 $newline->type = $line[
'type'];
725 $newline->desc = $line[
'desc'];
726 $newline->fk_product = $line[
'product_id'];
727 $newline->tva_tx = $line[
'vat_rate'];
728 $newline->qty = $line[
'qty'];
729 $newline->price = $line[
'price'];
730 $newline->subprice = $line[
'unitprice'];
731 $newline->total_ht = $line[
'total_net'];
732 $newline->total_tva = $line[
'total_vat'];
733 $newline->total_ttc = $line[
'total'];
734 $newline->date_start = $line[
'date_start'];
735 $newline->date_end = $line[
'date_end'];
737 $elementtype =
'commandedet';
742 $extrafields->fetch_name_optionals_label($elementtype,
true);
743 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
744 foreach ($extrafields->attributes[$elementtype][
'label'] as $tmpkey => $tmplabel) {
745 $tmpkey =
'options_'.$tmpkey;
746 $newline->array_options[$tmpkey] = $line[$tmpkey];
750 $newobject->lines[] = $newline;
755 dol_syslog(
"Webservice server_order:: order creation start", LOG_DEBUG);
756 $result = $newobject->create($fuser);
757 dol_syslog(
'Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG);
759 dol_syslog(
"Webservice server_order:: order creation failed", LOG_ERR);
763 if ($order[
'status'] == 1) {
764 dol_syslog(
"Webservice server_order:: order validation start", LOG_DEBUG);
765 $result = $newobject->valid($fuser);
767 dol_syslog(
"Webservice server_order:: order validation failed", LOG_ERR);
773 dol_syslog(
"Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
775 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
777 dol_syslog(
"Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
781 $errorlabel = $newobject->error;
786 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
801 function validOrder($authentication, $id =
'', $id_warehouse = 0)
803 global $db, $conf, $langs;
805 dol_syslog(
"Function: validOrder login=".$authentication[
'login'].
" id=".$id.
" id_warehouse=".$id_warehouse);
808 $objectresp = array();
812 if ($authentication[
'entity']) {
813 $conf->entity = $authentication[
'entity'];
820 if ($fuser->rights->commande->lire) {
822 $result = $order->fetch($id);
824 $order->fetch_thirdparty();
827 $result = $order->valid($fuser, $id_warehouse);
831 $outputlangs = $langs;
832 $order->generateDocument($order->model_pdf, $outputlangs);
837 $errorlabel = $order->error;
843 $errorlabel = $order->error;
849 $errorlabel = $order->error;
854 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
857 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''));
872 global $db, $conf, $langs;
874 dol_syslog(
"Function: updateOrder login=".$authentication[
'login']);
876 if ($authentication[
'entity']) {
877 $conf->entity = $authentication[
'entity'];
881 $objectresp = array();
882 $errorcode =
''; $errorlabel =
'';
886 if (empty($order[
'id']) && empty($order[
'ref']) && empty($order[
'ref_ext'])) {
887 $error++; $errorcode =
'KO'; $errorlabel =
"Order id or ref or ref_ext is mandatory.";
891 $objectfound =
false;
893 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
896 $result = $object->fetch($order[
'id'], (empty($order[
'id']) ? $order[
'ref'] :
''), (empty($order[
'id']) && empty($order[
'ref']) ? $order[
'ref_ext'] :
''));
898 if (!empty($object->id)) {
903 if (isset($order[
'status'])) {
904 if ($order[
'status'] == -1) {
905 $result = $object->cancel($fuser);
907 if ($order[
'status'] == 1) {
908 $result = $object->valid($fuser);
911 $outputlangs = $langs;
912 $object->generateDocument($order->model_pdf, $outputlangs);
915 if ($order[
'status'] == 0) {
916 $result = $object->set_reopen($fuser);
918 if ($order[
'status'] == 3) {
919 $result = $object->cloture($fuser);
923 if (isset($order[
'billed'])) {
924 if ($order[
'billed']) {
925 $result = $object->classifyBilled($fuser);
927 if (!$order[
'billed']) {
928 $result = $object->classifyUnBilled($fuser);
932 $elementtype =
'commande';
937 $extrafields->fetch_name_optionals_label($elementtype,
true);
938 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
939 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
940 $key =
'options_'.$key;
941 if (isset($order[$key])) {
942 $result = $object->setValueFrom($key, $order[$key],
'commande_extrafields');
952 if ((!$error) && ($objectfound)) {
955 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
958 'ref_ext'=>$object->ref_ext
960 } elseif ($objectfound) {
964 $errorlabel = $object->error;
967 $errorcode =
'NOT_FOUND';
968 $errorlabel =
'Order id='.$order[
'id'].
' ref='.$order[
'ref'].
' ref_ext='.$order[
'ref_ext'].
' cannot be found';
973 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
981 $server->service(file_get_contents(
"php://input"));
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
Class to manage order lines.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.