Advertisement
Guest User

rest_logistik

a guest
Jun 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. function send_adj_item_to_rest_api( $adj_id, $date_, $location)
  2. {
  3.    
  4.     $dimension = get_dimension2_by_loc_code($location);
  5.     $dimension2_id = $dimension['dimension2_id'];
  6.  
  7.     //stock_move
  8.     $stockMove = array();
  9.     $sql = "SELECT * FROM 0_stock_moves WHERE trans_no = ".$adj_id.
  10.             " AND `type` = ".ST_INVADJUST;
  11.     $result2 = db_query($sql);
  12.     if(db_num_rows($result2)>0){
  13.         while($row = db_fetch_assoc($result2)){
  14.             $stockMove[] = $row;
  15.         }
  16.     }
  17.    
  18.     //gl_trans
  19.     $glTrans = array();
  20.     $sql = "SELECT * FROM 0_gl_trans WHERE type_no = ".$adj_id.
  21.             " AND `type` = ".ST_INVADJUST;
  22.     $result3 = db_query($sql);
  23.     if(db_num_rows($result3)>0){
  24.         while($row = db_fetch_assoc($result3)){
  25.             $glTrans[] = $row;
  26.         }
  27.     }
  28.            
  29.         $url = set_link_url_api_with_authentication("adjustment-item/create", ID_PT_LOGISTIK);
  30.         $dataPost = [
  31.  
  32.             "id_pt" => ID_PT_APPS,
  33.             "dimension2_id" => $dimension2_id,
  34.             "tran_date" => $date_,
  35.             "stock_move" =>$stockMove,
  36.             "gl_trans" =>$glTrans
  37.  
  38.         ];
  39.  
  40.         $post = json_encode($dataPost);
  41.         $respon = \Httpful\Request::post($url)
  42.                         ->body($post)
  43.                         ->sendsJson()
  44.                         ->send();
  45.                 // display_error($respon);
  46.         $bodyCode = $respon->body;
  47.         $return =false;
  48.         if($bodyCode->status==200){
  49.             $return =true;
  50.         }
  51.         else{
  52.             if(!empty($bodyCode->message)){
  53.                 display_error($bodyCode->message);
  54.             }
  55.         }
  56.         return $return;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement