<?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 1 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($fromdate=='')  		$fromdate = date('d/m/Y');
if($todate=='')  		$todate	= date('d/m/Y');


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>Reports</title>

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

function ShowlistProject(str){
	window.open('List_SorProject.php?frm=45&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function ShowlistClient(str){
	var vLedger = '';
	if(str == 1)
		vLedger = encodeURIComponent(document.getElementById('fromclient').value);
	if(str == 2)
		vLedger = encodeURIComponent(document.getElementById('toclient').value);
	
	var vDate = document.getElementById('fromdate').value;
	
	window.open('List_SorClient.php?frm=20&item='+str+'&PLedger_number='+vLedger+'&TransDate='+vDate,'Clients','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function PrintPage(){
	var repNbr = '', str = '';
	
	for(i=0;i<document.repLog.rep.length;i++){
		if (document.repLog.rep[i].checked)
			repNbr = document.repLog.rep[i].value;
	}
	let fromdate 	= document.getElementById('fromdate').value;
	let todate	 	= document.getElementById('todate').value;
	let fromproject = document.getElementById('fromproject').value;
	let toproject 	= document.getElementById('toproject').value;
	let fromclient 	= document.getElementById('fromclient').value;
	let toclient 	= document.getElementById('toclient').value;
	let opStatus 	= document.getElementById('opStatus').value;
	let groupby		= document.getElementById('groupby').value;

	if (repNbr == 1)
		str = 'Rep_LogisticShipping.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject+'&fromclient='+fromclient+'&toclient='+toclient+'&opStatus='+opStatus;
	else if (repNbr == 2)
		str = 'Rep_LogisticTransporter.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject;
	else if (repNbr == 3)
		str = 'Rep_LogisticOperation.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject+'&fromclient='+fromclient
				+'&toclient='+toclient+'&opStatus='+opStatus+'&groupby='+groupby;
	
	window.open(str);
}

function PrintExcel(){
	var repNbr = '', str = '';
	
	for(i=0;i<document.repLog.rep.length;i++){
		if (document.repLog.rep[i].checked)
			repNbr = document.repLog.rep[i].value;
	}
	let fromdate 	= document.getElementById('fromdate').value;
	let todate	 	= document.getElementById('todate').value;
	let fromproject = document.getElementById('fromproject').value;
	let toproject 	= document.getElementById('toproject').value;
	let fromclient 	= document.getElementById('fromclient').value;
	let toclient 	= document.getElementById('toclient').value;
	let opStatus 	= document.getElementById('opStatus').value;
	let groupby		= document.getElementById('groupby').value;

	if (repNbr == 1)
		str = 'Exp_LogisticShipping.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject+'&fromclient='+fromclient+'&toclient='+toclient+'&opStatus='+opStatus;
	else if (repNbr == 2)
		str = 'Exp_LogisticTransporter.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject;
	else if (repNbr == 3)
		str = 'Exp_LogisticOperation.php?fromdate='+fromdate+'&todate='+todate+'&fromproject='+fromproject+'&toproject='+toproject+'&fromclient='+fromclient
				+'&toclient='+toclient+'&opStatus='+opStatus+'&groupby='+groupby;

	window.open(str);
}

function ClearPage(){
	var x = document.repLog;
	x.fromdate.value='';
	x.todate.value='';
	
	x.fromproject.value='';
	x.fromprojectdesc.value='';
	x.toproject.value='';
	x.toprojectdesc.value='';
	
	x.fromclient.value='';
	x.fromclientdesc.value='';
	x.toclient.value='';
	x.toclientdesc.value='';
	x.groupby.value = '';
	x.opStatus.value = '';
	x.action='Form_ReportsLogistic.php';
	x.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;
}
.style88 {
    font-size: 11px;
    color: #999999;
    font-weight: bold;
}

.selectStyle {
	font-size: 12px;
	width: 80%;
}
.selectStyle2 {
	font-size: 12px;
	width: 50%;
}
</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='repLog' 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'>Reports</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='btnPrint' name='btnPrint' onclick='PrintPage(); return false;' title='Print Page'><span><span>$Print</span></span></button>";
echo"		<button type='button' id='btnExcel' name='btnExcel' onclick='PrintExcel(); return false;' title='Print Excel'><span><span>$Excel</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=30%>";

//1st row	
echo"<tr bgcolor='#F7F7F7' height='25'>
		<td valign='center' align='left' style='padding-left: 30px;'><span class='style88'>Date</span>";
echo"	</td>";
echo"	<td >
		<td></td>
		<td rowspan='2' valign='top'><span class='style88'><input type='radio' name='rep' id='rep' value='1' checked>Shipping Report <br>
											<input type='radio' name='rep' id='rep' value='2'>Transporter Report <br>
											<input type='radio' name='rep' id='rep' value='3'>Operation Report
						</span>
		</td>
		<td rowspan='3' valign='top'>
			<table width=100% cellpadding=0 cellspacing=0><col width=50%><col width=50%>
				<tr><td>
				<span class='style88'>Status</span> 
				<select name='opStatus' id='opStatus' class='selectStyle2'>
					<option value=''></option>
					<option value='PENDING'>Pending</option>
					<option value='ACTIVE'>Active</option>
					<option value='COMPLETED'>Completed</option>
				</select>
				</td>
				<td><span class='style88'>Group By</span></td></tr>
				<tr><td></td><td><select name='groupby' id='groupby' class='selectStyle' multiple>
				<option value=''></option>
				<option value='1'>Client Code</option>
			</select></td>
			</table>
		</td>
	</tr>";
	
echo"<tr bgcolor='#F7F7F7' height='25'>
		<td valign='center' align='left'><span class='style88'>From</span>";
echo"	</td>";
echo"	<td ><input type='text' name='fromdate' id='fromdate' value='$fromdate' style='font-size:12px; width:120px; height:20px;' />
			<a href='#' onclick=\"displayCalendar(document.repLog.fromdate,'dd/mm/yyyy',this);  return false;\" name='anchor1' id='anchor1'><img src='./img/cal.gif' border='0' align='center'></a>
		</td>
		<td></td>
	</tr>";
	
echo"<tr bgcolor='#F7F7F7' height='25'>
		<td valign='center' align='left' ><span class='style88'>To</span>";
echo"	</td>";
echo"	<td ><input type='text' name='todate' id='todate' value='$todate' style='font-size:12px; width:120px; height:20px;' />
			<a href='#' onclick=\"displayCalendar(document.repLog.todate,'dd/mm/yyyy',this);  return false;\" name='anchor1' id='anchor1'><img src='./img/cal.gif' border='0' align='center'></a>
		</td>
		<td></td>
	</tr>";
// File from - To
echo"<tr bgcolor='#F7F7F7' height='25'>
		<td colspan='3' valign='center' align='left' style='padding-left: 30px;'><span class='style88'>File</span></td>
		<td></td>
		<td></td>
	</tr>";
		
echo"<tr>
		<td><span class='style88'>From</span></td>
		<td colspan='2'><input type='text' name='fromproject' id='fromproject' value='$fromproject' style='font-size:12px; width:150px; height:20px;' maxlength='20'  />
			<input type='text' name='fromprojectdesc' id='fromprojectdesc' value='".htmlspecialchars($fromprojectdesc,ENT_QUOTES)."' style='font-size:12px; width:180px; height:20px;' readonly/>	
			<img src='img/btnopen.jpg' weight='15' height='20' onclick=\"ShowlistProject('1');\" title='Select File' onmouseover=\"style.cursor='hand';\">			
		</td>
		<td></td><td></td>
	</tr>";
echo"<tr>
		<td><span class='style88'>To</span></td>
		<td colspan='2'><input type='text' name='toproject' id='toproject' value='$toproject' style='font-size:12px; width:150px; height:20px;' maxlength='20'  />
			<input type='text' name='toprojectdesc' id='toprojectdesc' value='".htmlspecialchars($toprojectdesc,ENT_QUOTES)."' style='font-size:12px; width:180px; height:20px;' readonly/>	
			<img src='img/btnopen.jpg' weight='15' height='20' onclick=\"ShowlistProject('2');\" title='Select File' onmouseover=\"style.cursor='hand';\">			
		</td>
		<td></td><td></td>
	</tr>";
	
// Client from - To	

echo"<tr>
		<td colspan='3' style='padding-left: 30px;'><span class='style88'>Client</span></td>
		<td></td><td></td>
	</tr>";

echo"<tr>
		<td><span class='style88'>From</span></td>
		<td colspan='2'><input type='text' name='fromclient' id='fromclient' value='".htmlspecialchars($fromclient,ENT_QUOTES)."' style='font-size:12px; width:150px; height:20px;' maxlength='10' />
			<input type='text' name='fromclientdesc' id='fromclientdesc' value='".htmlspecialchars($fromclientdesc,ENT_QUOTES)."' style='font-size:12px; width:180px; height:20px;' readonly/>
			<img src='img/btnopen.jpg' weight='15' height='20' onclick=\"ShowlistClient('1');\" title='Select Client' onmouseover=\"style.cursor='hand';\">	
		</td>
		<td></td><td></td>
	</tr>";
echo"<tr>
		<td><span class='style88'>To</span></td>
		<td colspan='2'><input type='text' name='toclient' id='toclient' value='".htmlspecialchars($toclient,ENT_QUOTES)."' style='font-size:12px; width:150px; height:20px;' maxlength='10' />
			<input type='text' name='toclientdesc' id='toclientdesc' value='".htmlspecialchars($toclientdesc,ENT_QUOTES)."' style='font-size:12px; width:180px; height:20px;' readonly/>
			<img src='img/btnopen.jpg' weight='15' height='20' onclick=\"ShowlistClient('2');\" title='Select Client' onmouseover=\"style.cursor='hand';\">	
		</td>
		<td></td><td></td>
	</tr>";

echo"</table>";
	
	
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;

?>