<?php

$addon_path="../../";
include $addon_path."includes/config.php";
include $addon_path."includes/database.php";
include $addon_path."includes/keyword.php";
include $addon_path."includes/function.php";
include $addon_path."includes/session.php";
$addon_path="";



header("Content-type: image/svg+xml");

?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<script xlink:href="../../plugin/svg/SVGPan.js"/>
<g id="viewport" transform="scale(0.8,0.8),translate(0,35)">
<?php

$color[0]="ECF0F1";//grey
$color[1]="E74C3C";//red
$color[2]="F1C40F";//yellow
$color[3]="3498DB";//blue
$color[4]="1ABC9C";//green



//rack
$query_storage_location="select * from t_".$key_table_prefix."_storage_location 
			where loc_floor_code ='".$_REQUEST["floor"]."'
			order by loc_floor_code, loc_code ";
$result_storage_location = mysqli_query($dbconn, $query_storage_location);
while($line_storage_location = mysqli_fetch_array($result_storage_location,MYSQLI_ASSOC))
{	
	$x = $line_storage_location["loc_x"];
	$y = $line_storage_location["loc_y"];
	$w = $line_storage_location["loc_width"];
	$h = $line_storage_location["loc_height"];
	
	
	/*
	if(rand(0,3)==0)
	{
		
		$color_random = rand(0,4);
		
	}
	else {
		
		$color_random=0;
		
	}
	
	
	$this_color=$color[$color_random];
	*/
	
	$this_color=$color[0];
	
	
	
	$this_text = $line_storage_location["loc_name"];
	

	
	
	
	echo '<rect x="'.$x.'" y="'.$y.'" width="'.$w.'" height="'.$h.'" rx="5" ry="5"  style="fill:#'.$this_color.';stroke-width:0;stroke:rgb(0,0,0)" />';

	echo '<text class="site_name" x="'.($x+5).'" y="'.($y+15).'"  style="fill:#2C3E50;font-family:arial;cursor:pointer;font-size:11px;" text-anchor="right" >';
     	echo '<a onclick="parent.mon_send_get(\'mod/floor_plan_display/display.php\',\'?loc_code='.$line_storage_location["loc_code"].'\',\'div_display\');">'.$this_text.'</a>';
     echo '</text>';	
	
	
	if($color_random!=0)
	{
		$this_bar_bg_color="cccccc";
		$this_bar_fg_color="00AA00";
		
		echo '<rect x="'.($x+1).'" y="'.($y+2).'" width="'.($w-2).'" height="3" rx="1" ry="1"  style="fill:#'.$this_bar_bg_color.';stroke-width:0;stroke:rgb(0,0,0)" />';
		echo '<rect x="'.($x+1).'" y="'.($y+2).'" width="'.($w-rand(10,30)).'" height="3" rx="1" ry="1"  style="fill:#'.$this_bar_fg_color.';stroke-width:0;stroke:rgb(0,0,0)" />';
	}
	
}


//label
$query_label="select * from t_".$key_table_prefix."_label order by lbl_id ";
$result_label = mysqli_query($dbconn, $query_label);
while($line_label = mysqli_fetch_array($result_label,MYSQLI_ASSOC))
{	
	echo 1;
	$x = $line_label["lbl_x"];
	$y = $line_label["lbl_y"];
	$w = $line_label["lbl_width"];
	$h = $line_label["lbl_height"];
	
//	echo '<rect x="'.$x.'" y="'.$y.'" width="'.$w.'" height="'.$h.'" rx="5" ry="5"  style="fill:#ECF0F1;stroke-width:0;stroke:rgb(0,0,0)" />';

	echo '<text class="site_name" x="'.($x+5).'" y="'.($y+20).'"  style="fill:#2C3E50;font-family:arial;cursor:pointer;font-size:15px;" text-anchor="right" >';
     echo ''.$line_label["lbl_code"].'';
     echo '</text>';	
}


 
 //echo '<rect x="110" y="110" width="100" height="30" rx="5" ry="5"  style="fill:#ECF0F1;stroke-width:0;stroke:rgb(0,0,0)" />';
 //echo '<rect x="210" y="210" width="100" height="30" rx="5" ry="5" onclick="alert(1)" style="fill:#ff0000;stroke-width:0;stroke:rgb(0,0,0)" />';
 
 /*
    $circle_radius=5;
    //default display---------------------
    echo '<circle class="site_spot" cx="'.$x.'" cy="'.$y.'" r="'.$circle_radius.'" text-anchor="left" stroke="" stroke-width="3" fill="#'.$this_color.'" style="cursor:pointer;"  />';
    echo '<text class="site_name" x="'.($x).'" y="'.($y).'" style="fill:#2C3E50;font-family:arial;cursor:pointer;font-size:11px;" text-anchor="left" >';
    echo '<a onclick="parent.mon_send_get(\'mod/welcome/display.php\',\'?site='.$line_site["sit_code"].'\',\'div_display\');">'.$line_site["sit_name"].'</a>';
    echo '</text>';
 */
 
 
 ?>
 
 
</g>
</svg>

