<?php
include "start.php";
include "../includes/function.php";

$json_array_status = array();



$query_get="select * from t_".$key_table_prefix."_invoice_header
		where ivh_operation_mode = 'ORDER'
		and not ifnull(ivh_delivery_status,'') = 'DELIVERED'
		and ivh_id = '".$_REQUEST["pkh_id"]."'
		
		";
$result_get = mysqli_query($dbconn, $query_get);
if($line_get = mysqli_fetch_array($result_get,MYSQLI_ASSOC))
{
  
  
  	$query_get_item="select * 
				from t_".$key_table_prefix."_invoice_item 
				where ivi_id = '".$_REQUEST["pki_id"]."' ";
	$result_get_item = mysqli_query($dbconn, $query_get_item);
	if($line_get_item = mysqli_fetch_array($result_get_item,MYSQLI_ASSOC))
	{
		
		$query_update_item = "update  t_".$key_table_prefix."_invoice_item
     			
				set  ivi_picking_status = '".$_REQUEST["pki_status"]."' , 
					ivi_picking_datetime = '".$_REQUEST["pki_datetime"]."' ,
					ivi_picking_user = '".$_REQUEST["pki_user"]."' , 
					ivi_picking_quantity = '".$_REQUEST["pki_quantity"]."' , 
					
					ivi_before_picking_quantity = ivi_quantity 
					
					
					
					
					
					
				where ivi_id = '".$_REQUEST["pki_id"]."'
     			
     			";
				
     	$result_update_item = mysqli_query($dbconn, $query_update_item);
		
		
		
		$this_data = array(
			"status" => "SUCCESS",
			"message" => "Update successful"
			
		  );
		array_push($json_array_status, $this_data); 
	
		
		
		
	}
	else {
		
		$this_data = array(
			"status" => "FAIL",
			"message" => "Update Fail"
			
		  );
		array_push($json_array_status, $this_data); 
	
		
	}
	
  
  
  
  
		
	   
	


}


$content_array["update"] = $json_array_status;	





$json = json_encode($content_array);	
echo $json;
?>