23 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK",
'1');
25 require
'../master.inc.php';
26 require_once NUSOAP_PATH.
'/nusoap.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32 dol_syslog(
"Call Dolibarr webservices interfaces");
37 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
39 $langs->load(
"admin");
40 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
41 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
42 print $langs->trans(
"ToActivateModule");
47 $server =
new nusoap_server();
48 $server->soap_defencoding =
'UTF-8';
49 $server->decode_utf8 =
false;
50 $ns =
'http://www.dolibarr.org/ns/';
51 $server->configureWSDL(
'WebServicesDolibarrSupplierInvoice', $ns);
52 $server->wsdl->schemaTargetNamespace = $ns;
56 $server->wsdl->addComplexType(
63 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
64 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
65 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
66 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
67 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
71 $server->wsdl->addComplexType(
78 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
79 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
84 $server->wsdl->addComplexType(
91 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
92 'type' => array(
'name'=>
'type',
'type'=>
'xsd:int'),
93 'desc' => array(
'name'=>
'desc',
'type'=>
'xsd:string'),
94 'fk_product' => array(
'name'=>
'fk_product',
'type'=>
'xsd:int'),
95 'total_net' => array(
'name'=>
'total_net',
'type'=>
'xsd:double'),
96 'total_vat' => array(
'name'=>
'total_vat',
'type'=>
'xsd:double'),
97 'total' => array(
'name'=>
'total',
'type'=>
'xsd:double'),
98 'vat_rate' => array(
'name'=>
'vat_rate',
'type'=>
'xsd:double'),
99 'qty' => array(
'name'=>
'qty',
'type'=>
'xsd:double'),
100 'date_start' => array(
'name'=>
'date_start',
'type'=>
'xsd:date'),
101 'date_end' => array(
'name'=>
'date_end',
'type'=>
'xsd:date'),
103 'product_ref' => array(
'name'=>
'product_ref',
'type'=>
'xsd:string'),
104 'product_label' => array(
'name'=>
'product_label',
'type'=>
'xsd:string'),
105 'product_desc' => array(
'name'=>
'product_desc',
'type'=>
'xsd:string')
109 $server->wsdl->addComplexType(
117 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:line[]')
122 $server->wsdl->addComplexType(
129 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
130 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
131 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
132 'ref_supplier' => array(
'name'=>
'ref_supplier',
'type'=>
'xsd:string'),
133 'fk_user_author' => array(
'name'=>
'fk_user_author',
'type'=>
'xsd:int'),
134 'fk_user_valid' => array(
'name'=>
'fk_user_valid',
'type'=>
'xsd:int'),
135 'fk_thirdparty' => array(
'name'=>
'fk_thirdparty',
'type'=>
'xsd:int'),
136 'date_creation' => array(
'name'=>
'date_creation',
'type'=>
'xsd:dateTime'),
137 'date_validation' => array(
'name'=>
'date_validation',
'type'=>
'xsd:dateTime'),
138 'date_modification' => array(
'name'=>
'date_modification',
'type'=>
'xsd:dateTime'),
139 'date_invoice' => array(
'name'=>
'date_invoice',
'type'=>
'xsd:date'),
140 'date_term' => array(
'name'=>
'date_modification',
'type'=>
'xsd:date'),
141 'label' => array(
'name'=>
'label',
'type'=>
'xsd:date'),
142 'type' => array(
'name'=>
'type',
'type'=>
'xsd:int'),
143 'total_net' => array(
'name'=>
'type',
'type'=>
'xsd:double'),
144 'total_vat' => array(
'name'=>
'type',
'type'=>
'xsd:double'),
145 'total' => array(
'name'=>
'type',
'type'=>
'xsd:double'),
146 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
147 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
148 'status' => array(
'name'=>
'status',
'type'=>
'xsd:int'),
149 'close_code' => array(
'name'=>
'close_code',
'type'=>
'xsd:string'),
150 'close_note' => array(
'name'=>
'close_note',
'type'=>
'xsd:string'),
151 'lines' => array(
'name'=>
'lines',
'type'=>
'tns:LinesArray')
155 $server->wsdl->addComplexType(
163 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:invoice[]')
168 $server->wsdl->addComplexType(
176 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:invoice[]')
187 $styleuse =
'encoded';
192 'getSupplierInvoice',
194 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
196 array(
'result'=>
'tns:result',
'invoice'=>
'tns:invoice'),
198 $ns.
'#getSupplierInvoice',
201 'WS to get SupplierInvoice'
204 'getSupplierInvoicesForThirdParty',
206 array(
'authentication'=>
'tns:authentication',
'idthirdparty'=>
'xsd:string'),
208 array(
'result'=>
'tns:result',
'invoices'=>
'tns:invoices'),
210 $ns.
'#getSupplierInvoicesForThirdParty',
213 'WS to get SupplierInvoicesForThirdParty'
230 dol_syslog(
"Function: getSupplierInvoice login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
232 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
235 $objectresp = array();
236 $errorcode =
''; $errorlabel =
'';
240 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
243 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
250 if ($fuser->rights->fournisseur->facture->lire)
253 $result = $invoice->fetch($id, $ref, $ref_ext);
256 $linesresp = array();
258 foreach ($invoice->lines as $line)
261 $linesresp[] = array(
263 'type'=>$line->product_type,
264 'total_net'=>$line->total_ht,
265 'total_vat'=>$line->total_tva,
266 'total'=>$line->total_ttc,
267 'vat_rate'=>$line->tva_tx,
275 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
277 'id' => $invoice->id,
278 'ref' => $invoice->ref,
279 'ref_supplier'=>$invoice->ref_supplier,
280 'ref_ext' => $invoice->ref_ext,
281 'fk_user_author' => $invoice->fk_user_author,
282 'fk_user_valid' => $invoice->fk_user_valid,
283 'fk_thirdparty' => $invoice->fk_soc,
284 'type'=>$invoice->type,
285 'status'=>$invoice->statut,
286 'total_net'=>$invoice->total_ht,
287 'total_vat'=>$invoice->total_tva,
288 'total'=>$invoice->total_ttc,
292 'date_term'=>
dol_print_date($invoice->date_echeance,
'dayhourrfc'),
293 'label'=>$invoice->label,
294 'paid'=>$invoice->paid,
295 'note_private'=>$invoice->note_private,
296 'note_public'=>$invoice->note_public,
297 'close_code'=>$invoice->close_code,
298 'close_note'=>$invoice->close_note,
300 'lines' => $linesresp,
308 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
313 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
319 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
338 dol_syslog(
"Function: getSupplierInvoicesForThirdParty login=".$authentication[
'login'].
" idthirdparty=".$idthirdparty);
340 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
343 $objectresp = array();
344 $errorcode =
''; $errorlabel =
'';
349 if (!$error && empty($idthirdparty))
352 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
'Parameter id is not provided';
357 $linesinvoice = array();
359 $sql .=
'SELECT f.rowid as facid';
360 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
365 $sql .=
" WHERE f.entity = ".$conf->entity;
366 if ($idthirdparty !=
'all') $sql .=
" AND f.fk_soc = ".$db->escape($idthirdparty);
368 $resql = $db->query($sql);
371 $num = $db->num_rows(
$resql);
376 $obj = $db->fetch_object(
$resql);
379 $result = $invoice->fetch($obj->facid);
383 $errorcode = $result; $errorlabel = $invoice->error;
388 $linesresp = array();
389 foreach ($invoice->lines as $line)
391 $linesresp[] = array(
393 'type'=>$line->product_type,
395 'total_net'=>$line->total_ht,
396 'total_vat'=>$line->total_tva,
397 'total'=>$line->total_ttc,
398 'vat_rate'=>$line->tva_tx,
400 'product_ref'=>$line->product_ref,
401 'product_label'=>$line->product_label,
402 'product_desc'=>$line->product_desc,
407 $linesinvoice[] = array(
409 'ref'=>$invoice->ref,
410 'ref_supplier'=>$invoice->ref_supplier,
411 'ref_ext'=>$invoice->ref_ext,
412 'fk_user_author' => $invoice->fk_user_author,
413 'fk_user_valid' => $invoice->fk_user_valid,
414 'fk_thirdparty' => $invoice->fk_soc,
415 'type'=>$invoice->type,
416 'status'=>$invoice->statut,
417 'total_net'=>$invoice->total_ht,
418 'total_vat'=>$invoice->total_tva,
419 'total'=>$invoice->total_ttc,
423 'date_term'=>
dol_print_date($invoice->date_echeance,
'dayhourrfc'),
424 'label'=>$invoice->label,
425 'paid'=>$invoice->paid,
426 'note_private'=>$invoice->note_private,
427 'note_public'=>$invoice->note_public,
428 'close_code'=>$invoice->close_code,
429 'close_note'=>$invoice->close_note,
431 'lines' => $linesresp
438 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
439 'invoices'=>$linesinvoice
445 $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
451 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
458 $server->service(file_get_contents(
"php://input"));
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.
Class to manage suppliers invoices.
getSupplierInvoicesForThirdParty($authentication, $idthirdparty)
Get list of invoices for third party.
getSupplierInvoice($authentication, $id= '', $ref= '', $ref_ext= '')
Get invoice from id, ref or ref_ext.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
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_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.