<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}
include("config.inc.php");
include("function.inc.php");
include("Functions_Synchro.php");

ini_set('max_execution_time', $config['ReportTimeExecution']);

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");



$query1="select grid_color1,grid_color2 from setup";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
extract($rows);

}

$str   = $_GET['str']; if ($str == ""){$str = $_POST["str"];}
$item  = $_GET['item'];if ($item == ""){$item = $_POST["item"];}
$mode  = $_GET['mode'];if ($mode == ""){$mode = $_POST["mode"];}
$post  = $_GET['post'];if ($post == ""){$post = $_POST["post"];}
$Category_code = $_GET['Category_code'];if ($Category_code == ""){$Category_code = $_POST["Category_code"];}
$category_name = $_GET['category_name'];if ($category_name == ""){$category_name = $_POST["category_name"];}

$PRef  = $_POST["PRef"]; if ($PRef == ""){$PRef = $_GET["PRef"];}

$category_code1  = $_POST["category_code1"]; if ($category_code1 == ""){$category_code1 = $_GET["category_code1"];}
$category_name1  = $_POST["category_name1"]; if ($category_name1 == ""){$category_name1 = $_GET["category_name1"];}
$category_price1 = $_POST["category_price1"]; if ($category_price1 == ""){$category_price1 = $_GET["category_price1"];}
$category_price2 = $_POST["category_price2"]; if ($category_price2 == ""){$category_price2 = $_GET["category_price2"];}
$category_price3 = $_POST["category_price3"]; if ($category_price3 == ""){$category_price3 = $_GET["category_price3"];}
$category_price4 = $_POST["category_price4"]; if ($category_price4 == ""){$category_price4 = $_GET["category_price4"];}
$category_price5 = $_POST["category_price5"]; if ($category_price5 == ""){$category_price5 = $_GET["category_price5"];}
$category_price6 = $_POST["category_price6"]; if ($category_price6 == ""){$category_price6 = $_GET["category_price6"];}



if($_GET['icode']!=""){

$query1="select ctrans_id, cashregister_name, ctrans_timein, ctrans_timeout, currency_code, ctrans_additionalcash, ctrans_totalcashstart, ctrans_totalcashclose
		from cashregistertrans where date_format(ctrans_timein,'%Y%m%d') = date_format('".$_GET['icode']."','%Y%m%d')";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
extract($rows);
//$iccode=$Item_Code.",".$Item_Description;

}
$post="1";
}



  
  

print <<<HERE
<!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>Select Categories</title>
<script type="text/javascript" language="javascript">

</script>
<script type="text/javascript" language="javascript">

function submitrecord(){
  document.form1.mode.value='insert';
  document.form1.action='List_Categories.php';
  document.form1.submit();
}


function selectrecord(vop,vin,vout){
var vin = vin.replace('%20',' ');
var vout = vout.replace('%20',' ');

if(vop==1)
	opener.form1.fromdate.value=vin;
	opener.form1.todate.value=vout;
self.close();
}

function clearform()
{
	document.form1.PRef.value='';
	document.form1.submit();
 

}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style1 {
	color: #333333;
	font-weight: bold;
}
.style2 {
	color: #999999;
	font-weight: bold;
	font-size: 12px;
}
.style3 {color: #999999}
.style4{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
-->
</style></head>
HERE;
echo'
<body>
<form id="form1" name="form1" method="post" action="">
  <table width="600" border="0" align="center">
    <tr>
      <th colspan="3" bgcolor="#DDDDDD"><span class="style1">Search</span></th>
    </tr>
  
   <tr>
   <td bgcolor="#DDDDDD" colspan="1" > <span style="font-size: 11px; color: #999999; font-weight: bold;">
		Search for 
		</span></td>
  
      
      <th bgcolor="#DDDDDD" align="left" colspan="2"> <input type="text" name="PRef" value="'.$PRef.'"> ';
	  
	  
	      echo"
	        <input type='submit' name='Submit' value='Find' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
			 <input type='button' name='Clear' value='Clear' onclick='clearform();'
			 style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		</tD><th>  </tr>";	



 
 echo"
    <tr bgcolor='#E5E5E5'>
      <td ><span class='style2'>CashRegister </span></td>
      <td  ><span class='style2'>Start Shift</span></td>
	  	<td  height='25' align='center'><span class='style2'>End Shift </span></td>  
    </tr>";
	
	 
	
 
$query1="select ctrans_id, cashregister_name, date_format(ctrans_timein,'%d/%m/%Y %k:%i:%s') ctrans_timein, date_format(ctrans_timeout,'%d/%m/%Y %k:%i:%s') ctrans_timeout, currency_code, ctrans_additionalcash, ctrans_totalcashstart, ctrans_totalcashclose
		from cashregistertrans ";

if ($PRef !='')
$query1 = $query1 ." where (ctrans_timein like '%".$PRef."%' or  ctrans_timeout like '%".$PRef."%')";

 $query1 = $query1 ." Order by cashregister_name asc,date_format(ctrans_timein,'%Y%m%d') desc,date_format(ctrans_timeout,'%Y%m%d') desc";
 

$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
extract($rows);

$ct+=1;

if($ct%2==0)
{
	$Color="style='font-size:12px;color:#0000FF;background-color:".$grid_color1."'";
	
	}else{
		
	$Color="style='font-size:12px;color:#0000FF;background-color:".$grid_color2."'";	
}

$onclick="onclick=selectrecord('".$op."','".htmlentities(str_replace(' ','%20',$ctrans_timein))."','".htmlentities(str_replace(' ','%20',$ctrans_timeout))."')";

 echo"<tr $onclick $Color><td  onMouseOver=\"style.cursor='pointer'\" >$cashregister_name</td><td  onMouseOver=\"style.cursor='pointer'\" >$ctrans_timein</td><td  onMouseOver=\"style.cursor='pointer'\" >$ctrans_timeout</td></tr>";
 
 
 
}

echo"</table>
</form>
</body>
</html>";

?>