<?php
	//Start session
	session_start();
	
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: index.html");
		exit();
	}
/*	if($_SESSION['SESS_BILLING']==0) {
		header("location: logout.php");
		exit();
	}*/


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Admin Page</title>
 <link rel="stylesheet" href="../css/style.css"  type="text/css"></link>
 <link rel="stylesheet" href="../css/jquery.autocomplete.css" type="text/css" >
 <link rel="icon" href="images/infosollogosmall.gif" type="image/x-icon" />
  <script type="text/javascript" src="../javascript/jquery.js"></script>
<script type="text/javascript" src="../javascript/jquery.datepick.min.js"></script>

<link rel="stylesheet" href="../css/redmond.datepick.css">
<script type="text/javascript" src="../javascript/jquery.autocomplete.js"></script>

  <script type="text/javascript">
 $(document).ready(function(){
	 $('#reportdfrom').datepick();
$('#reportdto').datepick();
	$('#db_export').click(function() {					
window.open('export.php?reportdto='+$('#reportdto').val()+'&reportdfrom='+$('#reportdfrom').val()+'&billedto='+$('#billedto').val());

}); 
$('#backup').click(function() {	
$win=window.open('backup.php');
window.close($win);
});

$('#UploadType').click(function() {
if($('#UploadType').val()=='book')	
$('#UpSec form').attr('action','import.php?mode=book');
else if($('#UploadType').val()=='bill')	
$('#UpSec form').attr('action','import.php?mode=bill');
else if($('#UploadType').val()=='fuel')	
$('#UpSec form').attr('action','import.php?mode=fuel');
else if($('#UploadType').val()=='maintain')	
$('#UpSec form').attr('action','import.php?mode=maintain');
else if($('#UploadType').val()=='payroll')	
$('#UpSec form').attr('action','import.php?mode=payroll');
else if($('#UploadType').val()=='ratemaster')	
$('#UpSec form').attr('action','import.php?mode=ratemaster');
else if($('#UploadType').val()=='bookingsync')	
$('#UpSec form').attr('action','import.php?mode=bookingsync');
 });
 });

 </script>
</head>

<body>

<?php
if(isset($_GET['mode'])) 
echo "<script type='text/javascript'>alert('$_GET[mode]');window.location='adminpage.php'</script>";
?>

<div class="main">
<div class="page">
<div class="header">
<div class="banner">
<p class="cmpname">WELCOME ADMIN</p>
</div>
</div>
<div class="right-panel-in">
<div >
<div class="loginform">
<table width="500px" height="325px" border="3" cellpadding="1" cellspacing="0"  >


<tr>
  <td align="center"><p>IMPORT</p>
    <p>
      <select name="UploadType" id="UploadType">
        <option value="book" >Booking</option>
        <option value="bill" >Billing</option>
        <option value="fuel" >Fuel</option>
        <option value="maintain" >Maintainence</option>
        <option value="payroll" >Payroll</option>
        <option value="musterroll" >Musterroll</option>
        <option value="ratemaster" >Ratemaster</option>
		<option value="bookingsync" >Duty SYNC</option>
      </select>
    </p></td>
  <td align="center" > 
  <div id="UpSec"> 
   <form enctype="multipart/form-data" method="POST" action="import.php?mode=book">
    <input name="userfile" type="file">
    <input type="submit" value="Upload" class="button">
  </form>
  </div>
  </td></tr>
<!--<tr>
  <td align="center">EXPORT</td><td align="center">
  <table>
  <tr>
  <td>
  FROM:<input name="reportdto" type="text" class="reportdto" id="reportdto" size="20"  />
  </td><td>
  TO:<input name="reportdfrom" type="text" class="reportdfrom" id="reportdfrom" size="20" /> 
  </td>
  </tr>
  <tr>
  <td>
  
  CMP:
  <input name="billedto" type="text"  id="billedto" size="20"  /> 
  </td>
  <td align="center"><input type="button" value="Export" class="button" id="db_export" />
  </td>
  </tr>
  </table>
  </td></tr>-->
  <tr>
  <td align="center">Click to Download</td><td align="center"><table cellpadding="12" cellspacing="10" width="100%" border="0">
    <tr>
      <td  align="left"width="30%"><a href="../docs/master booking.csv" >BOOKINGS</a></td>
      <td width="17%" align="left"><a href="../docs/master fuel.csv">FUEL </a></td>
      <td width="18%" align="left"><a href="../docs/master payroll.csv">PAYROLL </a></td>
      <td width="35%" align="right"><a href="../docs/master maintainces.csv">MAINTAINCES </a></td>
    </tr>
    <tr>
      <td align="left"><a href="../docs/ratemaster.csv">RATEMASTER </a></td>
      <td colspan="3" align="left">&nbsp;</td>
    </tr>
   
    </table>
  
  </td></tr>
<tr>
  <td align="center">BACKUP</td>
  <td align="center" ><input name="backup" type="button" class="button" id="backup" value="Backup Data" style="width: 27%;" /></td>
</tr>
<tr><td>&nbsp;</td>
  <td align="center" >

      <a href="logout.php"><img src="../images/logout.gif"  border="0"></a>
  </td>
</tr>
 </table>

</div>
</div>


</div>



</div>
</div>
</body>

<script type="text/javascript">
function findValue(li) {
  	if( li == null ) return alert("No match!");

  	// if coming from an AJAX call, let's use the CityId as the value
  	if( !!li.data ) var sValue = li.data[0];

  	// otherwise, let's just display the value in the text box
  	else var sValue = li.selectValue;

  	//alert("The value you selected was: " + sValue);
  }

  function selectItem(li) {
    	findValue(li);
  }

  function formatItem(row) {
    	return row[0];
  }
  
  
      $("#billedto").autocomplete(
      "../billedto.php?",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
  			onItemSelect:selectItem,
  			onFindValue:findValue,
  			formatItem:formatItem,
  			autoFill:false
  		}
    );

</script>
</html>
