| 1 | = Dodaj pozycję do dokumentu (produkt) = |
| 2 | |
| 3 | ''' Definicja parametrów: ''' |
| 4 | {{{ |
| 5 | #!php |
| 6 | <?php |
| 7 | |
| 8 | /** |
| 9 | * Tworzy pozycję na dokumencie |
| 10 | * |
| 11 | * @param data Array - Tablica z parametrami |
| 12 | * @param data['doc_id'] Int - identyfikator dokumentu (documents:doc_id) *wymagany |
| 13 | * @param data['depoid'] Int - identyfikator produktu (depository:depoid) parametr zamienny z product_symbol *wymagany |
| 14 | * @param data['netto_'] Numeric(12, 2) - cena netto |
| 15 | * @param data['vatnam'] String - nazwa stawki VAT (vat:vatnam) |
| 16 | * @param data['quantm'] Numeric(12, 2) - ilość |
| 17 | * @param data['discnp'] Numeric(12, 2) - rabat procentowo |
| 18 | * @param data['discnm'] Numeric(12, 2) - wartość rabatu |
| 19 | * @param data['deppur'] Numeric(12, 2) - koszt zakupu |
| 20 | * @param data['cursmb'] String - symbol waluty |
| 21 | * @param data['product_symbol'] String - symbol produktu (depository:symbol) parametr zamienny z depoid *wymagany |
| 22 | * |
| 23 | * @return Int - id pozycji jeśli sukces (fk_elements:fkelid), 0 w razie niepowodzenia |
| 24 | * |
| 25 | * @throws Exception - SoapFault |
| 26 | */ |
| 27 | Array addPositionToDocument(Array data) |
| 28 | |
| 29 | ?> |
| 30 | }}} |
| 31 | |
| 32 | ''' Przykłady wywołań: ''' |
| 33 | {{{ |
| 34 | #!php |
| 35 | |
| 36 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 37 | // MyService.php |
| 38 | <?php |
| 39 | |
| 40 | define('EDOK_API_LOGIN', 'developer'); |
| 41 | define('EDOK_API_PASSWORD', 'developer'); |
| 42 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 43 | |
| 44 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 45 | |
| 46 | $options = array( |
| 47 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 48 | "uri" => "eDokumentyAPI", |
| 49 | 'encoding'=>'UTF-8' |
| 50 | ); |
| 51 | |
| 52 | $client = new EDokApiClient(NULL, $options); |
| 53 | $client->setUser(EDOK_API_LOGIN); |
| 54 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 55 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 56 | $client->__setSoapHeaders($header); |
| 57 | |
| 58 | |
| 59 | $element = array(); |
| 60 | |
| 61 | try { |
| 62 | $data = array( |
| 63 | 'adddat' => '2014-12-17::', |
| 64 | ); |
| 65 | $element = $client->addPositionToDocument($data); |
| 66 | var_dump($element); |
| 67 | |
| 68 | } catch(SoapFault $fault) { |
| 69 | |
| 70 | var_dump($fault); |
| 71 | |
| 72 | if ($fault->faultcode < 100) { |
| 73 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | ?> |
| 78 | }}} |