<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");

$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");
if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

$querylog="SELECT Login_FLClientTracking as loginaccess, user_account, Language from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
	$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlog)){
		extract($rows);
	}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");



$query_navigator = "SELECT LANGUAGE,
       ClearPage,
       Excel,
       Save,
       Print,
       Addd,
       SEARCH,
       Pending,
       CopyJV,
       PaymentRequests,
       ExportExcel
FROM ".$_SESSION['dbLabel'].".mainform_label
WHERE LANGUAGE = '".$Language."'";
$result_navigator = mysql_query($query_navigator, $connection);
$row_navigator    = mysql_fetch_array($result_navigator);
extract($row_navigator);

	
//Read From Setup Table							
$querysetup= " select grid_color1, grid_color2,maxperpage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
	

if($mainmode=='')  		$mainmode	= 'insert';
if($startrange=='') 	$startrange = 0;
if($perpage == '' ) 	$perpage 	= $config['trowlimit'][0];
if($lfDate=='')  		$lfDate		= date('Y-m-d');


print <<<HERE

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 

<title>Closing File</title>

<script type="text/javascript" language="javascript">
function ClearPage(){
	var x = document.clienttrack;
		x.lfProjectCode.value 	= '';	
		x.lfProjectDesc.value 	= '';	
		x.action='Form_ClientTrackingLogistic.php';
		x.submit();
		
}

function ShowlistProject(){
	var vProjectCode = encodeURIComponent(document.getElementById('lfProjectCode').value);
	window.open('List_SorProject.php?frm=45&item=&chkTrans=2','mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function showlist(){
	document.clienttrack.submit();
}

function SetNextPage(startrange,perpage){
	document.clienttrack.action='Form_ClientTrackingLogistic.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.clienttrack.submit();
}

function SetPrvPage(startrange,perpage){
	document.clienttrack.action='Form_ClientTrackingLogistic.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.clienttrack.submit();
}

function set_limit(){

	perpage=document.clienttrack.perpage.value;
	document.clienttrack.action='Form_ClientTrackingLogistic.php?perpage='+perpage+'&startrange=0';
	document.clienttrack.submit();
}

</script>
<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style1 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

input:focus, select:focus {
	border: 2px solid #008b8b;
}
input:hover, select:hover {
	border: 1px solid #008b8b;
}

.span1{
	font-size: 13px;
    font-weight: bold;
    font-family: monospace;
}
.span2{
	font-size: 12px;
    font-family: monospace;
}
</style>
<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
</head>
<body >
<form name='clienttrack' method='post' enctype='multipart/form-data' >

HERE;


echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>";

	echo "<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title' style='text-transform: uppercase'>Client Tracking</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";


echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='38'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px'>";
echo"		<button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>$ClearPage</span></span></button>";

echo"		<button type='button' id='btnSearch' name='btnSearch' onclick='showlist(); return false;' title='Search'><span><span>Search</span></span></button>";

echo"   </td><td align='left' width='240px'></td><td align='left'>";
	
		
echo "</td></tr>";
echo"	</table>";
echo"</td></tr>";

echo"<tr><td id='content-body'>";	

echo"<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
	<col width=100%>";
		
	echo"   <tr bgcolor='#F7F7F7'><td valign='top'  align='left'>";	  
	
echo"<table border='0' style='table-layout:fixed' align='left' valign='top' width='100%'>
      <col width=10%><col width=20%><col width=10%><col width=20%><col width=10%><col width=20%>";

echo"<tr>
		<td><span class='style1'>File</span></td>
		<td colspan='3'><input type='text' name='lfProjectCode' id='lfProjectCode' value='$lfProjectCode' style='font-size:12px; width:150px; height:20px;' maxlength='20' readonly />
			<input type='text' name='lfProjectDesc' id='lfProjectDesc' value='".htmlspecialchars($lfProjectDesc,ENT_QUOTES)."' style='font-size:12px; width:200px; height:20px;' readonly/>	
			<img src='img/btnopen.jpg' weight='15' height='20' onclick=\"ShowlistProject();\" title='Select File' onmouseover=\"style.cursor='hand';\">			
		</td>
		<td></td>
		<td></td>
	</tr>";
echo "<tr height=30px><td colspan='6'></td></tr>";
$query = "select LO_id, date_format(LO_ETDDate,'%d-%m-%Y'), date_format(LO_ETADate,'%d-%m-%Y')
		from logistic_operations
		where client_code = '".$_SESSION['useraccount']."' and project_code='$lfProjectCode';";	
$result = mysql_query($query,$connection);
$row = mysql_fetch_row($result);

if ($lfProjectCode != ''){
echo "<tr><td colspan=6><span class='style1'>Results</span></td></tr>";
echo "<tr><td colspan=6><hr></td></tr>";
echo "<tr><td><span class='span1'>File:</span> </td><td><span class='span2'>$lfProjectCode</span></td>
		<td><span class='span1'>ETD:</span></td><td> <span class='span2'>$row[1]</span> </td>
		<td><span class='span1'>ETA:</span></td><td><span class='span2'> $row[2]</span></td>
	</tr>";
echo "<tr height=30px><td colspan='6'></td></tr>";	
echo "<tr><td colspan=6><div style='height:400px;overflow-x:hidden;overflow-y:scroll;'><table cellpadding=5 cellspacing=5 border=2 width=50% style='border: 2px solid darkgray;border-collapse: collapse;'>
		<col width=70%><col width=30%>";
$tempdate = '*';
$querydt = "select date_format(LR_RemarkDate,'%W, %M %d, %Y'), date_format(LR_RemarkDate,'%h:%i %p'),LR_Remark
			from Logistic_Remark where lo_id=$row[0] and (LR_type='BOTH' or LR_type='CLIENT')
			order by LR_RemarkDate;";
$resdt = mysql_query($querydt, $connection);
while ($rowdt = mysql_fetch_array($resdt)){
	if($tempdate != $rowdt[0])
		echo "<tr height='25px' bgcolor='#d3d3d3'><td><span class='span1'>$rowdt[0]</span></td><td><span class='span1'>Time</span></td></tr>";
	echo "<tr bgcolor='#f5f5dc'><td><span class='span2'>$rowdt[2]</span></td><td><span class='span2'>$rowdt[1]</span></td></tr>";
	
	$tempdate = $rowdt[0];
	
}			
echo "</table></div></td></tr>";	
}


echo"</table>";
	
	
echo "</td></tr>";



echo"<tr><td >&nbsp;</td><td align='center'>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.jpg' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center'>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.jpg' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr>";
echo "</table></td></tr>";		
  
echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	

print <<< HERE
      
	  </table>
	  </form>
HERE;

print <<<HERE

</body>

HERE;

?>