";print_r($_REQUEST);die; if($_REQUEST['action'] == "getVehDataovers") { if (in_array($_SESSION['sys_group_id'], $popup_notification_overspeed)) { //and sys_service_id not in(43226,67547,71530,78983,43226,67547,78983,43226,67547,78983) $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, concat(message , 'Time:-',DATE_FORMAT(insert_time, '%M %d %Y %k:%i')) as msg FROM alert_notification WHERE is_active=1 and alert_type='Overspeed' and client_id=".$_SESSION['sys_group_id']." order by insert_time desc limit 10 ", $condition); echo json_encode($vehicles); } else if (in_array($_SESSION['sys_group_id'], $popup_notification_notworking)) { $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',idle_hr) AS idle_vehicle,is_active,CONCAT(veh_no,' Notworking since last ',idle_hr,' Hours','') as msg FROM notworking_notification WHERE is_active=1 AND submit_type IS null and sys_group_id=".$_SESSION['sys_group_id'], $condition); echo json_encode($vehicles); } } if(isset($_GET["dravoalert_source"]) && $_GET["dravoalert_source"]!="" && $_GET["dravoalert_source"]=="select_dravoalers") { $start = $_GET["start"]; $end = $_GET["end"]; $type = $_GET["type"]; $vehid = $_GET["vehid"]; $dravoalertrow=db__select("SELECT *, adddate(gps_time,interval 330 MINUTE) as latesttime FROM all_alerts WHERE DATE(adddate(gps_time,interval 330 MINUTE)) >= '".$start."' AND DATE(adddate(gps_time,interval 330 MINUTE)) <= '".$end."' AND alert_msg = '".$type."' and veh_id = '".$vehid."' ", ""); if(count($dravoalertrow)>0) { echo json_encode($dravoalertrow); //echo $dravoalertrow; } else { echo 'NO'; } } if(isset($_GET['action']) && $_GET['action']=='fornestleAPI') { if($_GET['status']=="Deactivate") { $Updateapprovestatus="update matrix.group_services set active=0 where sys_group_id=".$_GET['gid']." and sys_service_id=".$_GET['row_id']; db__select($Updateapprovestatus,''); } else { $Insertapprovestatus="INSERT INTO `group_services` (`sys_service_id`, `sys_group_id`, `active`, `sys_modified`, `sys_added_date`) VALUES (".$_GET['row_id'].", ".$_GET['gid'].", 1, NULL, now())"; db__select($Insertapprovestatus,''); } } if($_REQUEST['action'] == "panicalert") { if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $group_id=6173; // echo " SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.panic_alert_popup WHERE is_active=1 and alert_type='panic' and client_id=".$_SESSION['sys_group_id']." ";die; $vehicles = db__select_staging(" SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.panic_alert_popup WHERE is_active=1 and alert_type='panic' and sys_service_id in (".$_SESSION['vehId'].") and client_id=".$group_id." ", $condition); //echo " SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.panic_alert_popup WHERE is_active=1 and alert_type='panic' and client_id=".$group_id." "; echo json_encode($vehicles); } else if($_REQUEST['action'] == "getIdleForAnowman") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',idle_hr) AS idle_vehicle,is_active,CONCAT(veh_no,' halted since last ',idle_hr,' Hours') as msg FROM idle_notification WHERE is_active=1 AND submit_type IS null and sys_service_id in(".$_SESSION['stoppage_vehId'].") and sys_group_id=".$group_id, $condition); echo json_encode($vehicles); } else if($_REQUEST['action'] == "getVehDatasensor") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging( "SELECT id,CONCAT(veh_no,'##') AS idle_vehicle,is_active,CONCAT(veh_no,' Temperature Sensor is not working ') as msg FROM sensor_issue where sensor_issue.`type`=1 and is_active=1 AND submit_type IS null and sys_group_id=".$group_id, $condition); echo json_encode($vehicles); } else if($_REQUEST['action'] == "servicedue") { //echo "SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type='servicedue' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null "; $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type='servicedue' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null ", $condition); //echo "SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type!='MainPoweralert' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null "; echo json_encode($vehicles); } else if($_REQUEST['action'] == "getVehTempData") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.temperaturealert_notification WHERE is_active=1 and client_id=".$group_id." and submit_type IS null group by sys_Service_id ", $condition); echo json_encode($vehicles); } else if($_REQUEST['action'] == "getVehTempDataSnowman") { $masterObj = new master(); $vehiclesdata = array(); $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg,sys_Service_id FROM matrix.temperaturealert_notification WHERE is_active=1 and client_id=".$group_id." and submit_type IS null group by sys_Service_id ", $condition); //echo "
";print_r($vehicles);die;
    
    for($v=0;$v";print_r($veh_lat_long);die;
        
        if($v==0 || $v==1) 
        {
            $veh_lat_long = db__select("select gps_latitude,gps_longitude from matrix.latest_telemetry where 
            sys_service_id=".$vehicles[$v]['sys_Service_id'], $condition);
            
            //$AddressLocation = $veh_lat_long[0]['gps_latitude'].",".$veh_lat_long[0]['gps_longitude'];
            
            $Locationdata = $masterObj->GetLocationFrmGtracDB($veh_lat_long[0]['gps_latitude'].",".$veh_lat_long[0]['gps_longitude']);
            
            $LocationNameArr = explode("##",$Locationdata);
            $AddressLocation = $LocationNameArr[0];
        } else {
            $AddressLocation = '';
        }            
                
        $getvehicle_array=array (
                'id' => $vehicles[$v]['id'],
                'idle_vehicle'=> $vehicles[$v]['idle_vehicle'],
                'is_active' => $vehicles[$v]['is_active'],
                'msg' => $vehicles[$v]['msg']." 
Source:- ".$veh_src_des[0]['source'].", Destination:- ".$veh_src_des[0]['destination']."
Location:- ".$AddressLocation."
Driver Name:- ".$veh_src_des[0]['driver_name'].", Driver Mobile:- ".$veh_src_des[0]['driver_number'].", Driver Code:- ".$veh_src_des[0]['driver_code'], ); array_push($vehiclesdata,$getvehicle_array); } echo json_encode($vehiclesdata); } //select `id`, `userid`, `groupid`,vehicle_num as lorry_no, concat(vehicle_num,' ',DATE_FORMAT(datetime, '%- %b %d %Y %H:%i')) as vehicle_num, DATE_FORMAT(datetime, '%Y-%m-%d %H:%i') as datetime, `message`, `alert_type`, `severity` from client_alert_customize where notification=1 limit 1 else if($_REQUEST['action'] == "getVehData") { if (in_array($_SESSION['sys_group_id'], $popup_notification_idle)) { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } /*echo "SELECT id,CONCAT(veh_no,'##',idle_hr) AS idle_vehicle,is_active,CONCAT(veh_no,' halted since last ',idle_hr,' Hours',', ') as msg FROM idle_notification WHERE is_active=1 AND submit_type IS null and sys_service_id in (".$_SESSION['vehId'].") and sys_group_id=". $group_id;*/ $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',idle_hr) AS idle_vehicle,is_active,CONCAT(veh_no,' halted since last ',idle_hr,' Hours',', ',location', ',insert_time) as msg FROM idle_notification WHERE is_active=1 AND submit_type IS null and sys_service_id in (".$_SESSION['vehId'].") and sys_group_id=". $group_id, $condition); echo json_encode($vehicles); } else if (in_array($_SESSION['sys_group_id'], $popup_notification_mainpower)) { $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type='MainPoweralert' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null ", $condition); //echo "SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type!='MainPoweralert' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null "; echo json_encode($vehicles); } else if (in_array($_SESSION['sys_group_id'], $popup_notification_panic_overspeed)) { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } if($_SESSION['sys_group_id']=="7595") { $masterObj = new master(); $vehicles=array(); $vehicleslist = db__select("select id,veh_id,latitude,longitude,ADDDATE(gtrac_alert.gps_time,INTERVAL 19800 SECOND) as gps_time,current_status from gtrac_alert where gtrac_alert.veh_id in (54523,54547,54553,54554,54571) and current_status=0", $condition); if(count($vehicleslist)>0) { for($v=0;$vGetLocationFrmGtracDB($vehicleslist[$v]['latitude'].",".$vehicleslist[$v]['longitude']); $LocationNameArr = explode("##",$Locationdata); $AddressLocation = $LocationNameArr[0]; $VehicleVeh_number=$masterObj->getvehiclenumber($vehicleslist[$v]['veh_id']); $VehicleNum=$VehicleVeh_number[0]["veh_reg"]; $getvehicle_array=array ( 'id' => $vehicleslist[$v]['veh_id']."##".$vehicleslist[$v]['id'], 'idle_vehicle'=> $VehicleNum."##panic", 'is_active' =>0, 'msg' => "Vehicle : ".$VehicleNum." Panic On at ".$vehicleslist[$v]['gps_time']." Loction:- ".$AddressLocation, ); array_push($vehicles,$getvehicle_array); } } else { //echo json_encode($vehicles); $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type!='Overspeed' and client_id=".$group_id." and submit_type IS null ", $condition); } } else { $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM alert_notification WHERE is_active=1 and alert_type!='Overspeed' and client_id=".$group_id." and submit_type IS null ", $condition); } echo json_encode($vehicles); } else if (in_array($_SESSION['sys_group_id'], $popup_notification_temperaturealert)) { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } //echo "SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM temperaturealert_notification //WHERE is_active=1 and alert_type!='Overspeed' and client_id=".$_SESSION['sys_group_id']." and submit_type IS null "; //$vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.temperaturealert_notification //WHERE is_active=1 and alert_type!='Overspeed' and client_id=".$group_id." and sys_service_id in (".$_SESSION['stoppage_vehId'].") and submit_type IS null ", $condition); $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.alert_notification WHERE is_active=1 and alert_type='temperature' and client_id=".$group_id." and submit_type IS null "); echo json_encode($vehicles); } } else if($_REQUEST['action'] == "getidleintransit") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.Controlroomnotification_notification WHERE is_active=1 and client_id=".$group_id." and alert_type='transit' and and submit_type IS null group by sys_Service_id "); echo json_encode($vehicles); } else if($_REQUEST['action'] == "kmtcontrolroom") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.Controlroomnotification_notification WHERE is_active=1 and submit_type IS null group by sys_Service_id "); echo json_encode($vehicles); } else if($_REQUEST['action'] == "vrccontrolroom") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); $userid=$_SESSION['UserId']; $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.Controlroomnotification_notification WHERE is_active=1 and submit_type IS null and client_id=".$userid." group by sys_Service_id "); echo json_encode($vehicles); } else if($_REQUEST['action'] == "getidleinloadingunloading") { $parent_group_id = db__select("SELECT * FROM `GROUP` WHERE id=".$_SESSION['sys_group_id'], $condition); if( $parent_group_id[0]['sys_parent_group_id']!=1) { $group_id=$parent_group_id[0]['sys_parent_group_id']; } else { $group_id=$_SESSION['sys_group_id']; } $vehicles = db__select_staging("SELECT id,CONCAT(veh_no,'##',alert_type) AS idle_vehicle,is_active, message as msg FROM matrix.Controlroomnotification_notification WHERE is_active=1 and client_id=".$group_id." and alert_type='unloading' and submit_type IS null group by sys_Service_id "); echo json_encode($vehicles); } if($_REQUEST['action'] == "Temp") { $veh_id=$_GET["id"]; $vehicles_temp = db__select("SELECT tel_temperature from latest_telemetry where sys_Service_id=".$veh_id, $condition); if(count($vehicles_temp)>0) { echo $Temperature=sprintf('%0.2f', round($vehicles_temp[0]["tel_temperature"],2))."°C"; } } if($_REQUEST['action'] == "Tempalert") { //veh_no,alert_type,message } if(isset($_GET["currentedit_source"]) && $_GET["currentedit_source"]!="" && $_GET["currentedit_source"]=="select_currentmonthrow") { $id = $_GET["id"]; $date = $_GET["date"]; $currentmonthrow=db__select_staging("SELECT total_km FROM matrix.consolidate WHERE sys_service_id=".$id." and consolidate.DateOf_journey='".$date."' ", ""); if(count($currentmonthrow)>0) { echo $currentmonthrow[0]['total_km']; } else { echo 'NO'; } } if(isset($_GET["currenteditupdate_source"]) && $_GET["currenteditupdate_source"]!="" && $_GET["currenteditupdate_source"]=="update_currentmonthrow") { $id = $_POST["cur_id"]; $date = $_POST["pick_date"]; //echo "UPDATE matrix.consolidate set total_km='".$_POST["totalkm"]."' , start_time=concat(DateOf_journey,' 00:00:00') WHERE sys_service_id=".$id." and consolidate.DateOf_journey='".$date."' LIMIT 1"; $currentmonthrow=db__select_staging("UPDATE matrix.consolidate set total_km='".$_POST["totalkm"]."' , start_time=concat(DateOf_journey,' 00:00:00'),end_time=concat(DateOf_journey,' 00:00:00') WHERE sys_service_id=".$id." and consolidate.DateOf_journey='".$date."' LIMIT 1", ""); echo 1; } if($_REQUEST['action'] == "updateTempSnowm") { //echo "
";print_r($_REQUEST);die;
	 
	

	 
$status = 0;
$submit_type = "Accept";
$condition = "";
$veh_no = $_REQUEST['veh_no'];
$comment = $_REQUEST['comment'];
$username=$_REQUEST['UserName'];
$close_time_msg=$_REQUEST['close_time_msg'];
  $alert_id =  $_REQUEST['alert_id'];
     
     $getSDL = explode(" 
",$data_msg[0]); //echo "
";print_r($getSDL);die;
     
	 /*$update_dispatch_data = "UPDATE matrix.temperaturealert_notification SET comment='".$comment."', submit_type='".$submit_type."', update_time='".date("Y-m-d H:i:s")."', is_active='".$status."', comment_by='".$_SESSION['UserName']."', close_time_msg='Source:-".$getSDL[1]."' where veh_no='".$veh_no."' AND is_active='1' ";*/
     
      echo $update_dispatch_data = "UPDATE matrix.temperaturealert_notification SET comment='".$comment."', submit_type='".$submit_type."', update_time='".date("Y-m-d H:i:s")."', is_active='".$status."', comment_by='".$_SESSION['UserName']."', close_time_msg='".$close_time_msg."' where veh_no='".$veh_no."' AND id='".$alert_id."' AND is_active='1' ";
	   //and id='".$data_msg[1]."'
         
     db__select_staging($update_dispatch_data, $condition);
    
    echo "Done";
   
}

if($_REQUEST['action'] == "updatepanicalert")
{

	
$status = 0;
$submit_type = "Accept";
$condition = "";
$veh_no = $_REQUEST['veh_no'];
$comment = $_REQUEST['comment'];
$username=$_REQUEST['UserName'];
 
   
    $dispatch_update="UPDATE matrix.panic_alert_popup SET comment='".$comment."',submit_type='".$submit_type."',update_time='".date("Y-m-d H:i:s")."',popup_closetime='".date("Y-m-d H:i:s")."',
    is_active='".$status."',comment_by='".$_SESSION['UserName']."' where veh_no='".$veh_no."' and is_active='1'";
   
    db__select_staging($dispatch_update, $condition);

}




exit;
?>