<?php include "../../includes/start_ajax.php";

?>

<div  align=left >
<?php



echo "<section class='view_toolbar'>";
    echo "<div class='view_toolbar_left' style='width:80%;'>";
		echo "<font size=5 ><span class='fa fa-th-large fa-1x'></span> <b>Stock Balance (Matrix)</b></font>";

		echo "<br>";
	    
    echo "</div>";
    echo "<div class='view_toolbar_right'>";
    
		    echo "<div class='fa-stack fa-lg'  style='cursor:pointer;float:right;'  onclick=\"mon_refresh_tab(mon_current_selected_tab);\" >";
			    echo "<i class='fa fa-square fa-stack-2x color_red'   ></i><i class='fa fa-refresh fa-stack-1x color_white' ></i>";
		    echo "</div>";
			    
   
    echo "</div>";
echo "</section>";



$cell_width="50";

$this_url="mod/stock_balance/index.php";


if($_REQUEST["filter_balancematrix_category"]!="")
{
		$_SESSION["list_filter"]["filter_balancematrix_category"] = $_REQUEST["filter_balancematrix_category"];
}



if($_REQUEST["filter_balancematrix_warehouse"]!="")
{
	$_SESSION["list_filter"]["filter_balancematrix_warehouse"] = $_REQUEST["filter_balancematrix_warehouse"];
		
}
if($_SESSION["list_filter"]["filter_balancematrix_warehouse"]=="")
{
    $_SESSION["list_filter"]["filter_balancematrix_warehouse"]="ALL";
}




if($_REQUEST["filter_balancematrix_vendor"]!="")
{
    $_SESSION["list_filter"]["filter_balancematrix_vendor"]=$_REQUEST["filter_balancematrix_vendor"];
}

if($_SESSION["list_filter"]["filter_balancematrix_vendor"]=="")
{
    $_SESSION["list_filter"]["filter_balancematrix_vendor"]="ALL";
}



//-------------toggle filter button---------------------
if($_REQUEST["filter_balancematrix_color"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_color"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_color"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_color"]="YES";
	}
}



if($_REQUEST["filter_balancematrix_size"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_size"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_size"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_size"]="YES";
	}
}


if($_REQUEST["filter_balancematrix_pattern"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_pattern"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_pattern"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_pattern"]="YES";
	}
}


if($_REQUEST["filter_balancematrix_featured"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_featured"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_featured"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_featured"]="YES";
	}
}


if($_REQUEST["filter_balancematrix_inventory"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_inventory"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_inventory"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_inventory"]="YES";
	}
}


if($_REQUEST["filter_balancematrix_discount"]!="")
{
	
	if($_SESSION["list_filter"]["filter_balancematrix_discount"]=="YES")
	{
	    $_SESSION["list_filter"]["filter_balancematrix_discount"]="";
	}
	else {
		$_SESSION["list_filter"]["filter_balancematrix_discount"]="YES";
	}
}








if($_REQUEST["filter_balancematrix_product"]!="")
{
    $_SESSION["list_filter"]["filter_balancematrix_product"] = $_REQUEST["filter_balancematrix_product"];
}






$query_pdt_count="select count(pdt_id) as total,
			pdt_category_code
			from t_".$key_table_prefix."_product 
			group by pdt_category_code ; ";
$result_pdt_count =mysqli_query($dbconn,$query_pdt_count);
while($line_pdt_count = mysqli_fetch_array($result_pdt_count,MYSQLI_ASSOC))
{
	$category_product_count[$line_pdt_count["pdt_category_code"]]=$line_pdt_count["total"];
}





echo "<form name='form_balance_matrix' >";










	
	//----------------------filters 0-------------------------------------------------------------
	
	
	echo "<section class='view_toolbar' >";
		echo "<div class='view_toolbar_search_field'>";
			echo "<span class='fa fa-filter fa-lg'></span> Filter Product with Settings";
		echo "</div>";
		echo "<div class='view_toolbar_filter' style='border:0px solid #ff0000;'>";
			
			echo "<div   class='view_toolbar_filter_box'>";			
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer; ' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_color=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
					if($_SESSION["list_filter"]["filter_balancematrix_color"]=="YES")
					{
						$this_button_color="color_green";
					}
					else {
						$this_button_color="color_grey";
					}
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-tint fa-stack-1x color_white" ></i>';
				echo "</div> Color ";
			echo "</div>";
				
			echo "<div   class='view_toolbar_filter_box'>";				
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer; ' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_size=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				if($_SESSION["list_filter"]["filter_balancematrix_size"]=="YES")
				{
					$this_button_color="color_green";
				}
				else {
					$this_button_color="color_grey";
				}
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-arrows-h fa-stack-1x color_white" ></i>';
				echo "</div> Size ";
			echo "</div>";	
				
			echo "<div class='view_toolbar_filter_box'>";			
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer; ' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_pattern=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				if($_SESSION["list_filter"]["filter_balancematrix_pattern"]=="YES")
				{
					$this_button_color="color_green";
				}
				else {
					$this_button_color="color_grey";
				}
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-puzzle-piece fa-stack-1x color_white" ></i>';
				echo "</div> Pattern";
			echo "</div>";
			
			echo "<div   class='view_toolbar_filter_box'>";			
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer;' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_featured=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				if($_SESSION["list_filter"]["filter_balancematrix_featured"]=="YES")
				{
					$this_button_color="color_green";
				}
				else {
					$this_button_color="color_grey";
				}	
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-lightbulb-o fa-stack-1x color_white" ></i>';
				echo "</div> Featured ";
			echo "</div>";
			
			echo "<div   class='view_toolbar_filter_box'>";			
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer;' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_inventory=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				if($_SESSION["list_filter"]["filter_balancematrix_inventory"]=="YES")
				{
					$this_button_color="color_green";
				}
				else {
					$this_button_color="color_grey";
				}	
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-cubes fa-stack-1x color_white" ></i>';
				echo "</div> Inventory ";
			echo "</div>";
				
			echo "<div   class='view_toolbar_filter_box'>";			
				echo "<div class='fa-stack fa-lg'  style='cursor:pointer;' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&filter_balancematrix_discount=YES&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				if($_SESSION["list_filter"]["filter_balancematrix_discount"]=="YES")
				{
					$this_button_color="color_green";
				}
				else {
					$this_button_color="color_grey";
				}
					echo '<i class="fa fa-square fa-stack-2x '.$this_button_color.'"  ></i><i class="fa fa-cut fa-stack-1x color_white" ></i>';
				echo "</div> Discount ";
			echo "</div>";
				
		echo "</div>";
		
	echo "</section>";
	
	
	
	
	//----------------------filters 1-------------------------------------------------------------
	
	
	echo "<section class='view_toolbar' >";
		echo "<div class='view_toolbar_search_field'>";
			echo "<span class='fa fa-filter fa-lg'></span> Warehouse";
		echo "</div>";
		echo "<div class='view_toolbar_search_button'>";
			
			echo "<select class='dropdown dropdown-auto' name='filter_balancematrix_warehouse' onchange=\"mon_send_get('".$this_url."','?filter_balancematrix_warehouse='+this.value+'&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
				
				
				
				echo "<option value='ALL'>All Warehouses</option>";
				
				
				
				$query_whs="select * from t_".$key_table_prefix."_warehouse order by whs_code ; ";
				$result_whs =mysqli_query($dbconn,$query_whs);
				
				while($line_whs = mysqli_fetch_array($result_whs,MYSQLI_ASSOC))
				{
					
					if($_SESSION["list_filter"]["filter_balancematrix_warehouse"]==$line_whs["whs_code"])
					{
						echo "<option value='".$line_whs["whs_code"]."' selected >";
					}
					else {
						echo "<option value='".$line_whs["whs_code"]."' >";
					}
					
						echo $line_whs["whs_code"];
						echo " - ";
						echo $line_whs["whs_name"];
					echo "</option>";
					
				}
	
	
			
				echo "</select>";
		
		
		echo "</div>";
		echo "<div class='view_toolbar_action_button'>";
			echo "<br>";
		echo "</div>";
			
	echo "</section>";
	
	
	
	
	echo "<section class='view_toolbar' >";
		echo "<div class='view_toolbar_search_field'>";
			echo "<span class='fa fa-filter fa-lg'></span> Product Category";
		echo "</div>";
		echo "<div class='view_toolbar_search_button'>";
			
		echo "<select class='dropdown dropdown-auto' name='filter_balancematrix_category' onchange=\"mon_send_get('".$this_url."','?filter_balancematrix_category='+this.value+'&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
			
			
			echo "<option value=''>-- select category --</option>";
			
			
			$query_cat="select * from t_".$key_table_prefix."_category order by cat_code ; ";
			$result_cat =mysqli_query($dbconn,$query_cat);
			while($line_cat = mysqli_fetch_array($result_cat,MYSQLI_ASSOC))
			{
				if($_SESSION["list_filter"]["filter_balancematrix_category"]==$line_cat["cat_code"])
				{
					echo "<option value='".$line_cat["cat_code"]."' selected >";
				}
				else {
					echo "<option value='".$line_cat["cat_code"]."' >";
				}
				
					echo $line_cat["cat_code"];
					echo " - ";
					echo $line_cat["cat_name"];
					
					echo " (".($category_product_count[$line_cat["cat_code"]]+0).")";
					
				echo "</option>";
				
			}
		echo "</select>";
		
		
		echo "</div>";
		echo "<div class='view_toolbar_action_button'>";
			echo "<br>";
		echo "</div>";
			
	echo "</section>";
	
	
	
	
	
	//----------------------filters 2-------------------------------------------------------------
	
	
	echo "<section class='view_toolbar' >";
		echo "<div class='view_toolbar_search_field'>";
			echo "<span class='fa fa-filter fa-lg'></span> Vendor";
		echo "</div>";
		echo "<div class='view_toolbar_search_button'>";
			echo "<select class='dropdown dropdown-l' name='filter_balancematrix_vendor' onchange=\"mon_send_get('".$this_url."','?filter_balancematrix_vendor='+this.value+'&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\" >";
				
				$query_filter="select * from t_".$key_table_prefix."_vendor order by vdr_code ";
				echo "<option value='ALL'>All</option>";
				$result_filter = mysqli_query($dbconn,$query_filter) or die("Listing failed- Err msg  ". mysqli_error($dbconn));
				while($line_filter=mysqli_fetch_array($result_filter,MYSQLI_ASSOC))
				{
					if($_SESSION["list_filter"]["filter_balancematrix_vendor"]==$line_filter["vdr_code"])
					{
						echo "<option value='".$line_filter["vdr_code"]."' selected >".$line_filter["vdr_code"]." - ".$line_filter["vdr_name"]."</option>";
					}
					else {
						echo "<option value='".$line_filter["vdr_code"]."'>".$line_filter["vdr_code"]." - ".$line_filter["vdr_name"]."</option>";	
					}
				}
			echo "</select>";
		echo "</div>";
		echo "<div class='view_toolbar_action_button'>";
				echo "<br>";
		echo "</div>";
			
	echo "</section>";
	
	
	
	
	echo "<section class='view_toolbar' >";
		echo "<div class='view_toolbar_search_field'>";
			echo "<span class='fa fa-search fa-lg'></span> Search";
		echo "</div>";
		echo "<div class='view_toolbar_search_button'>";
			echo "<input type=text class='textbox textbox-l' name='search_word' id='balancematrix_product_search_word' value='".$_REQUEST["search_word"]."'>";
			echo "<br><br> <input type=button class='button button-blue' name='search_button'  value='Search' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\">";
			echo " <input type=button class='button button-grey' name='clear_button'  value='Clear' onclick=\"mon_send_get('$this_url','?offset=0".$extraurl."&search_word=','div_main')\">";
			echo "<br><br>";
			
		echo "</div>";
		echo "<div class='view_toolbar_action_button'>";
				echo "<br>";
		echo "</div>";
			
	echo "</section>";









		$data_found=false;
		
		$query_pdt="select * from t_".$key_table_prefix."_product 
				where pdt_category_code = '".$_SESSION["list_filter"]["filter_balancematrix_category"]."' ";
					
		if($_SESSION["list_filter"]["filter_balancematrix_vendor"]!="ALL")
		{
			$query_pdt=$query_pdt." and pdt_vendor_code = '".$_SESSION["list_filter"]["filter_balancematrix_vendor"]."' ";
			
		}
		if($_REQUEST["search_word"]!="")
		{
			$query_pdt=$query_pdt." and  ( pdt_code like '%".$_REQUEST["search_word"]."%' ";
			$query_pdt=$query_pdt." or pdt_barcode like '%".$_REQUEST["search_word"]."%' ";
			$query_pdt=$query_pdt." or pdt_name like '%".$_REQUEST["search_word"]."%' ";
			$query_pdt=$query_pdt." ) ";
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_color"]=="YES")
		{
		    $query_pdt=$query_pdt." and pdt_select_color = 'YES' ";   
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_size"]=="YES")
		{
		    $query_pdt=$query_pdt." and pdt_select_size = 'YES' ";   
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_pattern"]=="YES")
		{
		    $query_pdt=$query_pdt." and pdt_select_pattern = 'YES' ";   
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_featured"]=="YES")
		{
		    $query_pdt=$query_pdt." and pdt_featured = 'YES' ";   
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_featured"]=="YES")
		{
		   $query_pdt=$query_pdt." and pdt_featured = 'YES' ";   
		}
		
		if($_SESSION["list_filter"]["filter_balancematrix_inventory"]=="YES")
		{
		   $query_pdt=$query_pdt." and pdt_inventory_tracking = 'YES' ";   
		}
		
		
		if($_SESSION["list_filter"]["filter_balancematrix_discount"]=="YES")
		{
		   $query_pdt=$query_pdt." and pdt_discount_allow = 'YES' ";   
		}
		
		$result_pdt =mysqli_query($dbconn,$query_pdt);
		



echo "<section class='view_toolbar' style='background:#fff;border-top:1px dashed #BDC3C7;padding:20px 0px 10px 0px;'>";
	echo "<div class='view_toolbar_search_field'>";
		
	echo "</div>";
	echo "<div class='view_toolbar_filter'>";
	
			
			
			
			
			$product_match_in_list=false;
			
			echo "<font color=#BDC3C7 >Total of ".(mysqli_num_rows($result_pdt)+0)." Product Matched</font><br><br>";
			
			echo "<span class='fa fa-cubes fa-lg'></span> <select class='dropdown dropdown-l' name='filter_balancematrix_product' onchange=\"mon_send_get('".$this_url."','?filter_balancematrix_product='+this.value+'&search_word='+document.getElementById('balancematrix_product_search_word').value,'div_main')\" >";
			echo "<option value=''>--Select Product--</option>";
			
			while($line_pdt = mysqli_fetch_array($result_pdt,MYSQLI_ASSOC))
			{
				
				if($_SESSION["list_filter"]["filter_balancematrix_product"]==$line_pdt["pdt_code"])
				{
					$product_match_in_list=true;
					echo "<option value='".$line_pdt["pdt_code"]."' selected >".$line_pdt["pdt_code"]." - ".$line_pdt["pdt_name"]."</option>";
				}
				else {
					echo "<option value='".$line_pdt["pdt_code"]."'>".$line_pdt["pdt_code"]." - ".$line_pdt["pdt_name"]."</option>";	
				}
		
		
			}
			echo "</select>";
	
	
			if($product_match_in_list)
			{
				
			}
			else {
				//reset 
				$_SESSION["list_filter"]["filter_balancematrix_product"]="";
				
			}
	
	echo "</div>";
		
echo "</section>";




$query_pdt="select * from t_".$key_table_prefix."_product 
		where pdt_code = '".$_SESSION["list_filter"]["filter_balancematrix_product"]."' ";
		
$result_pdt =mysqli_query($dbconn,$query_pdt);
if($line_pdt = mysqli_fetch_array($result_pdt,MYSQLI_ASSOC))
{
	
	$data_found=true;
	
	
	$select_color=$line_pdt["pdt_select_color"];
	$select_size=$line_pdt["pdt_select_size"];
	$select_pattern=$line_pdt["pdt_select_pattern"];
	
	
	
	$query_color="select * from t_".$key_table_prefix."_color  ";
	$result_color=mysqli_query($dbconn,$query_color);
	while($line_color=mysqli_fetch_array($result_color,MYSQLI_ASSOC))
	{
		$color_data[$line_color["clr_code"]]=$line_color["clr_name"];	
	}
	
	
	$query_size="select * from t_".$key_table_prefix."_size  ";
	$result_size=mysqli_query($dbconn,$query_size);
	while($line_size=mysqli_fetch_array($result_size,MYSQLI_ASSOC))
	{
		$size_data[$line_size["siz_code"]]=$line_size["siz_name"];	
	}
	
	
	$pattern_data["-"]="Unspecified";	
	
	$query_pattern="select * from t_".$key_table_prefix."_pattern  ";
	$result_pattern=mysqli_query($dbconn,$query_pattern);
	while($line_pattern=mysqli_fetch_array($result_pattern,MYSQLI_ASSOC))
	{
		$pattern_data[$line_pattern["ptn_code"]]=$line_pattern["ptn_name"];	
	}
	
	
	$query_whs = "select * from t_".$key_table_prefix."_warehouse ";
	$result_whs = mysqli_query($dbconn,$query_whs);
	while($line_whs = mysqli_fetch_array($result_whs,MYSQLI_ASSOC))
	{
		unset($bal_data);
		
		$query_balance="select * from t_".$key_table_prefix."_balance
		  			where bal_warehouse_code = '".$line_whs["whs_code"]."'
					and bal_product_code = '".$line_pdt["pdt_code"]."'
					
					";
		$result_balance=mysqli_query($dbconn,$query_balance);
		while($line_balance=mysqli_fetch_array($result_balance,MYSQLI_ASSOC))
		{
			if($line_balance["bal_color"]=="")
			{
				$line_balance["bal_color"]="-";
			}
			
			if($line_balance["bal_size"]=="")
			{
				$line_balance["bal_size"]="-";
			}
			
			if($line_balance["bal_pattern"]=="")
			{
				$line_balance["bal_pattern"]="-";
			}
			
			
			$bal_data[$line_balance["bal_color"]][$line_balance["bal_size"]][$line_balance["bal_pattern"]] = $bal_data[$line_balance["bal_color"]][$line_balance["bal_size"]][$line_balance["bal_pattern"]]+  $line_balance["bal_quantity"];	
			
			
			
			
			
		}
		
		//print_r($bal_data);
		
		
		
		echo "<div class='data_display_separator' >";
			echo "<font size=3><b>".$line_whs["whs_code"]." - ".$line_whs["whs_name"]."</b></font>";
		echo "</div>";
		
		echo "<div class='data_display_content'>";	
			echo "<div class='view_list_title_row'>";
				echo "<div class='view_list_title_content'>";
					
					echo "<div style='width:".$cell_width."px;' class='view_list_title_content_object'  >";
						echo "<br>";
					echo "</div>";
					
					echo "<div style='width:".$cell_width."px;' class='view_list_title_content_object'  >";
						echo "Unspecified<br>";
					echo "</div>";
					
					foreach($size_data as $size_key => $size_value)
					{
						
						echo "<div style='width:".$cell_width."px;' class='view_list_title_content_object'  >";
							echo "<b>".$size_key."</b><br>";
							echo "".$size_value."<br>";
						echo "</div>";
						
					}
					
				echo "</div>";
			echo "</div>";
					
				
			
				echo "<div class='view_row'>";
					echo "<div style='width:".$cell_width."px;text-align:right;' class='view_row_content_object'  >";
						echo "<font class='view_row_content_label'>".$listing_header[$i]."</font>";
					
						echo "<font class='view_row_content_text'>";
							
							echo "<font color=#000>Unspecified</font><br>";
						echo "</font><br>";			
					echo "</div>";
			
			
					echo "<div style='width:".$cell_width."px;text-align:right;' class='view_row_content_object'  >";
						echo "<font class='view_row_content_label'>All Color</font>";
					
						echo "<font class='view_row_content_text'>";
							foreach($pattern_data as $pattern_key => $pattern_value)
							{
								if($bal_data["-"]["-"][$pattern_key]!="")
								{
									
									echo "<font size=1>".$pattern_value."</font> ";
									echo $bal_data["-"]["-"][$pattern_key];
									echo "<br><br>";
									
								}
								
								
							}
						echo "</font><br>";			
					echo "</div>";
					
					
			
					foreach($size_data as $size_key => $size_value)
					{
						
						echo "<div style='width:".$cell_width."px;text-align:right;' class='view_row_content_object'  >";
							echo "<font class='view_row_content_label'>Size</font>";
						
							echo "<font class='view_row_content_text'>";
								foreach($pattern_data as $pattern_key => $pattern_value)
								{
									if($bal_data["-"][$size_key][$pattern_key]!="")
									{
										
										echo "<font size=1>".$pattern_value."</font> ";
										echo $bal_data["-"][$size_key][$pattern_key];
										echo "<br><br>";
										
									}
									
									
								}
								
							echo "</font><br>";			
						echo "</div>";
						
					}
					
				echo "</div>";
		
			foreach($color_data as $color_key => $color_value)
			{
				echo "<div class='view_row'>";
					echo "<div style='width:".$cell_width."px;text-align:right;' class='view_row_content_object'  >";
						echo "<font class='view_row_content_label'>Color</font>";
					
						echo "<font class='view_row_content_text'>";
							echo "<font color=#000><b>".$color_key."</b><br>".$color_value."</font><br>";
						echo "</font><br>";			
					echo "</div>";
					
					
				
					echo "<div style='width:".$cell_width."px;text-align:right;' class='view_row_content_object'  >";
						echo "<font class='view_row_content_label'>All Size</font>";
					
						echo "<font class='view_row_content_text'>";
							
							foreach($pattern_data as $pattern_key => $pattern_value)
							{
								
								
								if($bal_data[$color_key]["-"][$pattern_key]!="")
								{
									echo "<font size=1>".$pattern_value."</font> ";
									echo $bal_data[$color_key]["-"][$pattern_key];
									echo "<br><br>";
									
									
								}
								
							}
							
							
						echo "</font><br>";			
					echo "</div>";
					
					
					
					foreach($size_data as $size_key => $size_value)
					{
						
						echo "<div style='width:".$cell_width."px;text-align:center;' class='view_row_content_object'  >";
							echo "<font class='view_row_content_label'>".$listing_header[$i]."</font>";
						
							echo "<font class='view_row_content_text'>";
								
								foreach($pattern_data as $pattern_key => $pattern_value)
								{
									if($bal_data[$color_key][$size_key][$pattern_key]!="")
									{
										echo "<font size=1>".$pattern_value."</font> ";
										echo "<b>".$bal_data[$color_key][$size_key][$pattern_key]."</b>";
										echo "<br><br>";
									}
									
								}
								
								
								
							echo "</font><br>";			
						echo "</div>";
						
					}
					
			
				echo "</div>";
			
			}
		
		echo "</div>";

		
		
		
	}


}
echo "<div style='float:left;height:200px;'></div>";

echo "</form>";
?>
</div>
<?php include "../../includes/end_ajax.php";

?>
