<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orbis</title>

<!-- Bootstrap -->
<link href="<?= base_url(); ?>/css/bootstrap.css" rel="stylesheet">
<link href="<?= base_url(); ?>/css/material-kit.css" rel="stylesheet" type="text/css">
<link href="<?= base_url(); ?>/css/demo.css" rel="stylesheet" type="text/css">
<link href="<?= base_url(); ?>/css/styles.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> 
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> -->
<!---<link href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css">-->

<link href="//cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.1.0/material.min.css" rel="stylesheet" type="text/css">
<link href="https://cdn.datatables.net/1.10.15/css/dataTables.material.min.css" rel="stylesheet" type="text/css">

<style type="text/css">
	.dashboard .rightSide { width: 100%; }
	thead th { color: #fff; font-weight: bold; }
	tbody tr td { font-weight: bold; }
</style>


<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body style="background-color: #000;">
<div class="dashboard">
	<div class="rightSide">
		<div class="col-lg-12">
			<div class="logo">
		        	<img src="http://54.218.78.31:50//img/orbisLogo.png">
		    </div>
		</div>
		<div class="col-lg-12">
			<div class="col-lg-6">
				<button id="redirect">Reset</button>
				<div class="search">
					<form method="get">
						<input type="text" name="searchbar" value="<?= $this->session->userdata('search_value'); ?>" placeholder="Search any Number">
						<button type="submit" name="submit">Search</button>
					</form>
				</div>
			</div>
			<div class="col-lg-6">
			</div>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<table  cellpadding="1" cellspacing="1" class="table" width="50%">
					<thead>
						<th  width="50%">PRT</th>
						<th  width="50%">Date Time</th>
						<th  width="50%">IMEINumber</th>
						<th width="50%">Mobilenumber</th>
						<th width="50%">Messagetype</th>
						<th width="50%">Latitude</th>
						<th width="50%">Longitude</th>
						<th width="50%">PositionDateTime</th>
						<th width="50%">PositionType</th>
						<th width="50%">Status content(text)</th>
						<th width="50%">Interval</th>
						<th width="50%">Speed</th>
						<th width="50%">Checksum</th>
					</thead>
					<tbody>
						<?php
							if( !empty($tracking) )
							{
								for($i=0; $i<count($tracking); $i++)
								{

									if( $tracking[$i]['messageType'] == 'AmberStop' || $tracking[$i]['messageType'] == 'AmberExtend' || $tracking[$i]['messageType'] == 'AmberStart' || $tracking[$i]['messageType'] =='Amber' || $tracking[$i]['messageType'] =='AMST' || $tracking[$i]['messageType'] =='AMSP' || $tracking[$i]['messageType'] =='AMEX' || $tracking[$i]['messageType'] =='AMEXP' || $tracking[$i]['messageType'] =='FDA' || $tracking[$i]['messageType'] =='SDI' )
									{
										$backgroundcolor = '#ffff44';
									}
									else if( $tracking[$i]['messageType'] == 'PWON' )
									{
										$backgroundcolor = '#74ff44';
									}
									else if( $tracking[$i]['messageType'] == 'FallDetect' )
									{
										$backgroundcolor = '#ff9144';
									}
									else if( $tracking[$i]['messageType'] == 'Home' || $tracking[$i]['messageType'] == 'RedAlert' || $tracking[$i]['messageType'] == 'SOS' )
									{
										$backgroundcolor = '#ff4444';
									}
									else if( $tracking[$i]['messageType'] == 'PWOFF' || $tracking[$i]['messageType'] == 'MAND' )
									{
										$backgroundcolor = '#ff6644';
									}
									else if( $tracking[$i]['messageType'] == 'PUD' || $tracking[$i]['messageType'] == 'UpdateLocation' || $tracking[$i]['messageType'] == 'STA' )
									{
										$backgroundcolor = '#44ffc3';
									}
									else if( $tracking[$i]['messageType'] == 'NoMovement' )
									{
										$backgroundcolor = '#ff449f';
									}
									else if( $tracking[$i]['messageType'] == 'PUDM' )
									{
										$backgroundcolor = '#b544ff';
									}
									else if( $tracking[$i]['messageType'] == 'Mapupdate' )
									{
										$backgroundcolor = '#44eeff';
									}
									else if( $tracking[$i]['messageType'] == 'Message' )
									{
										$backgroundcolor = '#4744ff';
									}
									elseif( $tracking[$i]['messageType'] == 'EMGUC' || $tracking[$i]['messageType'] == 'KILL' || $tracking[$i]['messageType'] == 'EMG' || $tracking[$i]['messageType'] == 'EMGAC' || $tracking[$i]['messageType'] == 'PDL' )
									{
										$backgroundcolor = '#fff';
									}
									else 
									{
										$backgroundcolor = '';
									}
							
								?>
									<tr style="background-color: <?= $backgroundcolor ?>;">
										<td width="50%">
											<?= 'PRT'; ?>
										</td>
										<td  width="50%">
											<?= $tracking[$i]['DateTime']; ?>
										</td>
										<td  width="50%">
											<?= $tracking[$i]['IMEI']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['number']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['messageType']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['lat']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['long']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['posdatatime']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['postype']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['status']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['interval']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['speed']; ?>
										</td>
										<td width="50%">
											<?= $tracking[$i]['checksum']; ?>
										</td>
									</tr>
								<?php
								}
							}
						?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<!-- <div class="footer">
        <div class="footerNav"> </div>
        <div class="copyright"> © Copyright 2017, Orbis. All Rights Reserved </div>
	</div> -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script src="<?= base_url(); ?>js/jquery-1.11.2.min.js"></script>
<script src="<?= base_url(); ?>js/jquery.validate.min.js"></script>
<script src="<?= base_url(); ?>js/jquery.dataTables.min.js"></script>

<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.material.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed --> 
<script src="<?= base_url(); ?>js/bootstrap.js"></script>
<script src="<?= base_url(); ?>js/common.js"></script>
<script src="<?= base_url(); ?>js/material-kit.js"></script>
<script src="<?= base_url(); ?>js/material.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() {

		setTimeout( function() {
				window.location.href="";
		}, 30000 );

		$('#redirect').click( function()
		{
			window.location.href='<?php echo base_url().'index.php/tracking' ?>'; 
		} );

      var table=$('#example').DataTable();
	  
	  $(".costcenter").combobox({ 
        select: function (event, ui) { 
		
		     $('.contractfiltersubmit').submit();
        } 
      });
	  
	  $(".costcenteroffice").combobox({ 
        select: function (event, ui) {
			$.ajax({
				  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    $(".contractareaoffice option").remove();
						$.each(result, function(i, item) {
							 $('.contractareaoffice').append(new Option(item.contractarea_name,item.contractarea_id));
						});
                  }
			  });
              
        } 
      });
	  
	  $('.contractareaoffice').combobox({ 
	     select: function (event, ui) {
			 if($(this).val()!="Select Contract Area") {
				 
				  $('.office').submit();
			 }
			
		 }
	  });
	  
	  $(".costcenterlwd").combobox({ 
        select: function (event, ui) {
			$.ajax({
				  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
						$.each(result, function(i, item) {
							 $('.contractarealwd').append(new Option(item.contractarea_name,item.contractarea_id));
						});
                  }
			  });
              
        } 
      });
	  
	  $(".contractarealwd").combobox({ 
	      select: function (event, ui) {
			  $.ajax({
				  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    
						$.each(result, function(i, item) {
							 $('.officelwd').append(new Option(item.office_name,item.office_id));
						});
                  }
			  });
			  
		  }
	  });
	  
	  $('.costcenterpopup').change(function(){
		    if($(this).val()!="") {
				  $.ajax({
						  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
						  dataType: "json",				  
						  success: function(result){
								$.each(result, function(i, item) {
									 //$('.contractareapopup').append(new Option(item.contractarea_name,item.contractarea_id));
									$('.contractareapopup').append('<option value="'+item.contractarea_id+'">'+item.contractarea_name+'</option>');
								});
						  }
					  });
			}else{
				 $('#restpartpopup').css('display','none');
			}
	  });
	  
	  $('.contractareapopup').on('change', function() {
		  if($(this).val()!="") {
				 $.ajax({
						  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
						  dataType: "json",				  
						  success: function(result){
								
								$.each(result, function(i, item) {
									 //$('.officelwd').append(new Option(item.office_name,item.office_id));
									 $('.officepopup').append('<option value="'+item.office_id+'">'+item.office_name+'</option>');
								});
						  }
					  });
		  }else{
			  $('#restpartpopup').css('display','none');
		  }
	  });
	  
	  $('.officepopup').on('change', function() {
		  if($(this).val()!="") {
			  $('#restpartpopup').css('display','block');
		  }else{
			  $('#restpartpopup').css('display','none');
		  }
		  
		  
	  });
	  
	  
	  $(".contractarealwd").combobox({ 
	      select: function (event, ui) {
			  $.ajax({
				  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    
						$.each(result, function(i, item) {
							 $('.officelwd').append(new Option(item.office_name,item.office_id));
						});
                  }
			  });
			  
		  }
	  });
	  
	  $('.officelwd').combobox({ 
	     select: function (event, ui) {
			
			 if($('.costcenterlwd').val()!="Select Cost Center" &&  $('.contractarealwd').val()!="Select Contract Area") {
				 
				  $('.lwd').submit();
			 }
			
		 }
	  });
	  
	  
	$('.burgerMenu').click( function() {
		$(".leftSide").toggle("slide");
		$(".leftSide").toggleClass("active");
	});
	
	$('.cancelButton').click( function() {
		$(".leftSide").toggle("slide");
		$(".leftSide").toggleClass("active");	
	});
	
	
	$('.dropdownList1').on('click', function() {
		 $('.dropdownList1 .listInner1').toggleClass("collapse1"); 
		 if( $('.clickArrow2').is(':hidden') )
         {
            $('.clickArrow2').css('display', 'inline-block');
            $('.clickArrow1').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow1').css('display', 'inline-block');
            $('.clickArrow2').css('display', 'none');  
         }
	});
	
	$('.dropdownList2').on('click', function() {
		 $('.dropdownList2 .listInner2').toggleClass("collapse1"); 
		 if( $('.clickArrow4').is(':hidden') )
         {
            $('.clickArrow4').css('display', 'inline-block');
            $('.clickArrow3').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow3').css('display', 'inline-block');
            $('.clickArrow4').css('display', 'none');  
         }
	});
	
	$('.dropdownList3').on('click', function() {
		 $('.dropdownList3 .listInner3').toggleClass("collapse1"); 
		 if( $('.clickArrow6').is(':hidden') )
         {
            $('.clickArrow6').css('display', 'inline-block');
            $('.clickArrow5').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow5').css('display', 'inline-block');
            $('.clickArrow6').css('display', 'none');  
         }
	});
	
	$(window).load(function() {
		$("#example_length .form-control").addClass("combobox");	
	});
	
	var height=$(".dashboard").height();
			$(".leftSide").css('height',height);
			$(".rightSide").css('height',height);
			
	});
</script>
</body>
</html>
