<?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"];
}





	$counter=1;
	$data="";
	echo "[";
	
	
				
			$query_marker = "select *
						from t_".$key_table_prefix."_invoice_header
						where created_date >='".$_REQUEST["date"]." ".substr($_REQUEST["hour"]+100,1,2).":00:00'
						and created_date <='".$_REQUEST["date"]." ".substr($_REQUEST["hour"]+100,1,2).":59:59'
						
						and (not ifnull(ivh_latitude,'') = '' and not ifnull(ivh_latitude,'') = '0.0')
						order by created_date desc
						 ; ";
			$result_marker = mysqli_query($dbconn,$query_marker);
			
			if(mysqli_num_rows($result_marker)>0)
			{
				
				while($line_marker = mysqli_fetch_array($result_marker,MYSQL_ASSOC))
				{
					
					  
					if($data=="")
					{
						$data =  '["<b>'.$line_marker["ivh_customer_name"]."</b><br>".$device_data[$line_marker["device_id"]]."<br>".$line_marker["created_date"].'", '.$line_marker["ivh_latitude"].', '.$line_marker["ivh_longitude"].', '.$counter.']';
					}
					else
					{
						$data = $data. ',["<b>'.$line_marker["ivh_customer_name"]."</b><br>".$device_data[$line_marker["device_id"]]."<br>".$line_marker["created_date"].'", '.$line_marker["ivh_latitude"].', '.$line_marker["ivh_longitude"].', '.$counter.']';
					}
					
					$counter++;
					
					
				}
				
				
			}
			
		
	
	
	
	
	echo $data;
	echo "]";
	
	
   
	
	
	//echo '[["Bondi Beach", -33.890542, 151.274856, 2],["Maroubra Beach", -33.950198, 151.259302, 1]]';
  /*
    
echo "['Bondi Beach', -33.890542, 151.274856, 4],
										  ['Coogee Beach', -33.923036, 151.259052, 5],
										  ['Cronulla Beach', -34.028249, 151.157507, 3],
										  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
										  ['Maroubra Beach', -33.950198, 151.259302, 1]
										  
										  ";
										  
										  
*/

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