PHP code example of sylapi / erp

1. Go to this page and download the library: Download sylapi/erp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sylapi / erp example snippets


$courier = new Erp('Nazwa Systemu ERP');
$courier->sandbox(true);

$courier->setLogin('123456');
$courier->setPassword('abc12345def');

$courier->auth([
    '_key' => '1234abcd5678',
    '_password' => '123asd'
]);

$items = $erp->getItems();
if ($items->isSuccess()) {
     $response = $items->getResponse();
}
else {
     $items->getError();
}

$params = [
    'id' => 123
];
$item = $erp->getItem($params);

$stock = $erp->getStock();

$params = [
    'document_def' => 123,
    'external_id' => 12345,
    'comment' => 'Zamówienie #12345',
    'currency' => 'PLN',
    'buyer' => [
        'name' => 'Jan Kowalski',
        'street' => 'Ulica 2A',
        'city' => 'Warszawa',
        'postcode' => '22-001',
        'country' => 'PL',
        'nip' => '',
        'email' => '[email protected]',
    ],
    'seller' => [
        'name' => 'Firma sp z o.o.',
        'street' => 'Ulica 233',
        'city' => 'Poznań',
        'postcode' => '23-001',
        'country' => 'PL',
        'nip' => '',
        'email' => '[email protected]',
    ]
];

$params['items'][] = [
    'model' => 'model1',
    'warehouse_id' => 1,
    'name' => 'Nazwa produktu',
    'tax' => 23,
    'price_gross' => 233.99,
    'quantity' => 2
];
$order = $erp->createOrder($params);

$document = $erp->createInvoice($params);

$params = array(
    'order_id' => '123',
    'document_def' => '123456',
    'type' => '',
    'amount' => 100.99,
    'sell_date' => '2020-01-01',
    'date' => '2020-01-01',
    'comment' => 'Zamówienie nr 123',
    'country' => 'PL',
);
$advance = $erp->createAdvance($params);

$params = array(
    'order_id' => 123,
    'payment_id' => 'payu',
    'transaction_id' => '123abc',
    'price' => 123.0,
    'date' => '2020-01-01'
);
$items = $erp->createPayment($params);

$params = [
    'order_id' => 12345,
];
$items = $erp->deleteOrder($params);

$params = [
    'warehouse_id' => '1',
    'items' => [
        [
            'code' => 'MODEL1',
            'quantity' => 2,
        ],
    ],
    'comment' => 'Informacja dodatkowa'
];
$document = $erp->createRw($params);

$document = $erp->createPw($params);

$params = [
    'warehouse_from' => 1,
    'warehouse_to' => 2,
    'order_id' => 12345',
    'items_from' => [
        [
            'code' => 'MODEL1',
            'quantity' => 0.5,
        ],
        [
            'code' => 'MODEL2',
            'quantity' => 0.21,
        ],
    ],
    'items_to' => [
        [
            'code' => 'MODEL4',
            'quantity' => 1,
        ]
    ],
    'comment' => 'Infomacja dodatkowa'
];

$document = $erp->createRwpw($params);