Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function MotogamaZamow($data){
- foreach($data as $d1){
- $productsOrder[] = array(
- 'reference' => $d1['nazwa_ds'],
- 'quantity' => $d1['ilosc_z'],
- );
- }
- $sessionId = $this->doLogin('motogama');
- $jsonData = array(
- 'doOrderProducts' => array(
- 'sessionId' => $sessionId,
- 'warehouseId' => "01",
- 'productOrderList' => array('productOrder' => $productsOrder),
- )
- );
- // $this->dane->dane($jsonData);
- $url = $this->motogamaApi()->apiURL;
- $ch = curl_init();
- if (!$ch) die("Nie można zainicjować cURL!");
- curl_setopt($ch, CURLOPT_URL , $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
- curl_setopt($ch, CURLOPT_POST , true);
- curl_setopt($ch, CURLOPT_HTTPHEADER , array('Content-Type: application/json'));
- curl_setopt($ch, CURLOPT_POSTFIELDS , json_encode($jsonData));
- $jsonResponse = curl_exec($ch);
- curl_close($ch);
- if(empty(json_decode($jsonResponse)->error->code)){
- $data = json_decode($jsonResponse);
- $d11 = $data->doOrderProductsResponse;
- foreach($d11->productOrderInfoList->productOrderInfo as $row){
- $i=0;
- if (empty($row->error)){
- $magazyn = "CENTRALA";
- $confirm = $this->doOrderClose($sessionId, $d11->orderInfo->id, $url);
- if($confirm==true) $potwierdzenie = 1;
- else $potwierdzenie = 0;
- $wynik[$i] =array(
- 'dostawca' => 'Motogama',
- 'ilosc_z' => $row->quantity ? $row->quantity : null,
- 'ilosc_b' => (string) $row->quantityBlocked ? $row->quantityBlocked : null,
- 'kod_produktu' => $row->reference ? $row->reference : null,
- 'magazyn' => "CENTRALA",
- 'numer_id' => $d11->orderInfo->id ? $d11->orderInfo->id : null,
- 'numer_zam' => $d11->orderInfo->number ? $d11->orderInfo->id : null,
- 'nazwa' => $row->name ? $row->name : null,
- 'potwierdzenie' => $potwierdzenie,
- 'blad' => "<span class='badge badge-success'>Brak</span>",
- );
- }else{
- $wynik[$i] =array(
- 'dostawca' => 'Motogama',
- 'ilosc_z' => null,
- 'ilosc_b' => null,
- 'kod_produktu' => $row->reference ? $row->reference : null,
- 'magazyn' => "CENTRALA",
- 'numer_id' => $d11->orderInfo->id ? $d11->orderInfo->id : null,
- 'numer_zam' => $d11->orderInfo->number ? $d11->orderInfo->id : null,
- 'nazwa' => null,
- 'potwierdzenie' => 0,
- 'blad' => "<span class='badge badge-danger'>".$row->error."</span>",
- );
- }
- $i++;
- }
- }else{
- $wynik = array();
- }
- return $wynik;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement