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

?>

<?php


//device library:
$query_device="select * from t_".$key_table_prefix."_device ";
$result_device = mysqli_query($dbconn,$query_device);
while($line_device = mysqli_fetch_array($result_device,MYSQL_ASSOC))
{
	
	$device_data[$line_device["dev_android_id"]]=$line_device["dev_name"];
}



if($_REQUEST["location_date"]=="")
{
	$_REQUEST["location_date"]=date("Y-m-d");
}

include "../map_menu.php";



echo "<form name='frm_customer_location' >";
echo "<br><hr>";
    
    
//onclick=\"mon_send_get_marker('mod/location_transaction/marker.php','');\"

echo "<br><font size=2><b>Customer Location:</b></font><br>";

echo "<table bgcolor=#ECF0F1 width=100% cellpadding=3 style='border-radius:5px 5px;' >";
	echo "<tr>";
		echo "<td>";
			echo "<span class='fa fa-search fa-lg'></span> Search ";
		echo "</td>";
		
		echo "<td>";
		
			
			echo ": <input type=text class='textbox textbox-l' name='search' value='".$_REQUEST["search"]."'>";
			
			
		echo "</td>";
		
	echo "</tr>";
	
	echo "<tr>";
		echo "<td>";
			
		echo "</td>";
		
		echo "<td>";
			echo "<input type=button class='button button-blue' value='Search' onclick=\"mon_send_get_lookup('map/customer_location/index.php','?search='+document.frm_customer_location.search.value,'div_control_panel');\">";
		echo "</td>";
		
	echo "</tr>";
	
	/*
	echo "<tr>";
		echo "<td>";
			echo "Hour";
		echo "</td>";
		
		echo "<td>";
			echo ": <input name='location_hour' type='range'  min='8' max='18' step=1 value=8 onchange=\"document.getElementById('range').innerHTML=this.value;\"  />";
			echo "<span id='range'>0</span>";
		echo "</td>";
		
	echo "</tr>";
	
	
	echo "<tr>";
		echo "<td>";
			
		echo "</td>";
		
		echo "<td>";
			echo "<input type=button class='button_blue' value='Show Location' onclick=\"mon_send_get_marker('mod/location_transaction/marker.php?date='+document.frm_customer_location.location_date.value+'&hour='+document.frm_customer_location.location_hour.value,'');\">";
		echo "</td>";
		
	echo "</tr>";
	*/
	
echo "</table>";


    echo "<br><font size=2><b>Recent Location(s):</b>";
	echo "<span class='fa fa-refresh fa-1x' style='float:right;cursor:pointer;color:#3498DB;' onclick=\"mon_send_get_lookup('map/customer_location/index.php','','div_control_panel');\"></span>";
	echo "</font>";
	
echo "<br>";

echo "<div style='height:250px;overflow:scroll;border:1px solid #ECF0F1;'>";


    
    echo "<table cellpadding=3 cellspacing=2 width=100% >";
    
    	if($_REQUEST["search"]=="")
	{
		
		$query_marker = "
		   
					   select
					   *
					   from t_".$key_table_prefix."_customer
					   order by cus_code
					   limit 0, 40 ; ";
		
	}
	else {
		$query_marker = "
		   
					   select
					   *
					   from t_".$key_table_prefix."_customer
					   where cus_code like  '".$_REQUEST["search"]."'
					   or cus_name like  '".$_REQUEST["search"]."'
					   order by cus_code
					   limit 0, 40 ; ";
	}
            
						
		
		  $result_marker = mysqli_query($dbconn,$query_marker);
            echo mysqli_error($dbconn);
            while($line_marker = mysqli_fetch_array($result_marker,MYSQL_ASSOC))
            {
                
                
                echo "<tr>";
                    echo "<td style='border-radius:2px;background:#ECF0F1;cursor:pointer;' onclick=\"mon_send_get_marker('map/customer_location/marker.php?cus_id=".$line_marker["cus_id"]."','div_control_panel');\">";
						echo "<div style='float:right;text-align:right;'>";
							//echo "<font size=1 color=#BDC3C7 >".$line_marker["total_entry"]." GPS data</font>";
						echo "</div>";
						
						
						echo "<span class='fa fa-map-marker fa-lg'></span> ";
						echo "".$line_marker["cus_name"]."";
                    echo "</td>";
                echo "</tr>";
                
                $temp_date=$line_marker["location_date"];
                
            }
    echo "</table>";     


echo "</div>";
    




echo "</form>";

		    
?>


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

?>