<?php

echo "<div class='form_panel' align=left >";
	echo "<div class='form_panel_title'>";
	
					
		echo "<div class='fa-stack fa-lg'  style='cursor:pointer;float:left;'  onclick=\"document.".$this_form_name.".ui_action.value='ADD_ITEM_OK';mon_submit_form('".$this_form_name."','".$this_url."')\" >";
			echo "<i class='fa fa-square fa-stack-2x color_green'  ></i><i class='fa fa-check fa-stack-1x color_white' ></i>";
		echo "</div>";
			
	
		
		echo "<div class='fa-stack fa-lg'  style='cursor:pointer;float:right;'  onclick=\"document.".$this_form_name.".ui_action.value='';mon_submit_form('".$this_form_name."','".$this_url."')\" >";
			echo "<i class='fa fa-square fa-stack-2x color_red'  ></i><i class='fa fa-times fa-stack-1x color_white' ></i>";
		echo "</div>";

	
	
	
	echo "</div>";
	echo "<div class='form_panel_content'>";
		
		
		
		
			
		echo "<div style='width:96%;padding:1%;margin:1%;box-shadow:0px 0px 3px #888;background:#ECF0F1;'>";
			
			echo "<input type=text class='textbox textbox-l' name='add_item_search' value='".$_REQUEST["add_item_search"]."' >";
			echo "<div class='fa-stack fa-lg'  style='cursor:pointer;'  onclick=\"document.".$this_form_name.".ui_action.value='ADD_ITEM1';mon_submit_form('".$this_form_name."','".$this_url."')\" >";
				echo "<i class='fa fa-square fa-stack-2x color_grey'  ></i><i class='fa fa-search fa-stack-1x color_white' ></i>";
			echo "</div>";
		
		echo "</div>";
		
		echo "<div style='width:100%;height:400px;overflow:auto;float:left;'>";
		
		
		
		//get balance:
		$query_balance="select sum(bal_quantity) as total_quantity,
					bal_product_code
		  			from t_".$key_table_prefix."_balance 
					where bal_warehouse_code = '".$_REQUEST["warehouse_code"]."' 
					group by bal_product_code
					";
		$result_balance = mysqli_query($dbconn, $query_balance);
		echo mysqli_error();
		while($line_balance = mysqli_fetch_array($result_balance,MYSQLI_ASSOC))
		{
			$product_balance[$line_balance["bal_product_code"]] = $line_balance["total_quantity"]+0;
			
		}
		
					
		
		
		
		$query_product = " select * 
					from t_".$key_table_prefix."_product 
					";
		if($_REQUEST["add_item_search"]!="")
		{
			$query_product=$query_product." where (
											pdt_code like '%".$_REQUEST["add_item_search"]."%'
											or
											pdt_name like '%".$_REQUEST["add_item_search"]."%'
											or
											pdt_barcode like '%".$_REQUEST["add_item_search"]."%'
			
											) ";	
		}
		$query_product=$query_product." order by pdt_code ";
		
		
		$result_product = mysqli_query($dbconn,$query_product);
		while($line_product = mysqli_fetch_array($result_product,MYSQLI_ASSOC))
		{
			echo "<div style='width:96%;padding:1%;margin:1%;box-shadow:0px 0px 3px #888;'
			     onclick=\"document.".$this_form_name.".ui_action.value='ADD_ITEM2';document.".$this_form_name.".add_item_id.value='".$line_product["pdt_id"]."';mon_submit_form('".$this_form_name."','".$this_url."')\"
				>";
				
				//show balance:
				echo "<span style='float:right;text-align:right;'>";
					echo ($product_balance[$line_product["pdt_code"]]+0)."<br>";
					echo "<font size=1 color=#BDC3C7 >".$line_product["pdt_uom"]."</font>";
				echo "</span>";
				
				
				//show info:	
				echo "<b>".$line_product["pdt_code"]."</b><br>";
				echo $line_product["pdt_name"];
				
			
			
			
			
			
			echo "</div>";
			
			
		}
		echo "</div>";
		
		
	 
	
	
	echo "</div>";
echo "</div>";

?>