Advertisement
Remote

Untitled

Mar 22nd, 2025
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1.     public function MotogamaZamow($data){
  2.         foreach($data as $d1){
  3.             $productsOrder[] = array(
  4.                 'reference' => $d1['nazwa_ds'],
  5.                 'quantity' => $d1['ilosc_z'],
  6.             );
  7.         }
  8.  
  9.         $sessionId = $this->doLogin('motogama');
  10.         $jsonData = array(
  11.             'doOrderProducts'           => array(
  12.                 'sessionId'                 => $sessionId,
  13.                 'warehouseId'               => "01",
  14.                 'productOrderList'          => array('productOrder' => $productsOrder),
  15.             )
  16.         );
  17.         // $this->dane->dane($jsonData);
  18.        
  19.         $url = $this->motogamaApi()->apiURL;
  20.         $ch = curl_init();
  21.         if (!$ch) die("Nie można zainicjować cURL!");
  22.         curl_setopt($ch, CURLOPT_URL            , $url);
  23.         curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
  24.         curl_setopt($ch, CURLOPT_POST           , true);
  25.         curl_setopt($ch, CURLOPT_HTTPHEADER     , array('Content-Type: application/json'));
  26.         curl_setopt($ch, CURLOPT_POSTFIELDS     , json_encode($jsonData));
  27.         $jsonResponse = curl_exec($ch);
  28.         curl_close($ch);
  29.        
  30.         if(empty(json_decode($jsonResponse)->error->code)){
  31.             $data = json_decode($jsonResponse);
  32.             $d11 = $data->doOrderProductsResponse;
  33.             foreach($d11->productOrderInfoList->productOrderInfo as $row){
  34.                 $i=0;
  35.                 if (empty($row->error)){
  36.                     $magazyn = "CENTRALA";
  37.                     $confirm = $this->doOrderClose($sessionId, $d11->orderInfo->id, $url);
  38.                     if($confirm==true)  $potwierdzenie = 1;
  39.                     else                $potwierdzenie = 0;
  40.                     $wynik[$i] =array(
  41.                         'dostawca'      => 'Motogama',
  42.                         'ilosc_z'       => $row->quantity ? $row->quantity : null,
  43.                         'ilosc_b'       => (string) $row->quantityBlocked ? $row->quantityBlocked : null,
  44.                         'kod_produktu'  => $row->reference ? $row->reference : null,
  45.                         'magazyn'       => "CENTRALA",
  46.                         'numer_id'      => $d11->orderInfo->id ? $d11->orderInfo->id : null,
  47.                         'numer_zam'     => $d11->orderInfo->number ? $d11->orderInfo->id : null,
  48.                         'nazwa'         => $row->name ? $row->name : null,
  49.                         'potwierdzenie' => $potwierdzenie,
  50.                         'blad'          => "<span class='badge badge-success'>Brak</span>",
  51.                     );
  52.                 }else{
  53.                     $wynik[$i] =array(
  54.                         'dostawca'      => 'Motogama',
  55.                         'ilosc_z'       => null,
  56.                         'ilosc_b'       => null,
  57.                         'kod_produktu'  => $row->reference ? $row->reference : null,
  58.                         'magazyn'       => "CENTRALA",
  59.                         'numer_id'      => $d11->orderInfo->id ? $d11->orderInfo->id : null,
  60.                         'numer_zam'     => $d11->orderInfo->number ? $d11->orderInfo->id : null,
  61.                         'nazwa'         => null,
  62.                         'potwierdzenie' => 0,
  63.                         'blad'          => "<span class='badge badge-danger'>".$row->error."</span>",
  64.                     );
  65.                 }
  66.                 $i++;
  67.             }
  68.         }else{
  69.             $wynik = array();
  70.         }
  71.         return $wynik;     
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement