<?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);
}




	
$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2,maxperpage from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
//Access Mode On Insert/Edit/Delete
$InsMode = '';


print <<<HERE
<!DOCTYPE HTML>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">

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

function openmanifestreport(exp){
	
	var billlading			= document.getElementById('billlading').value;
	var voyage_year			= document.Report.voyage_year.value;
	var bol_number			= document.Report.bol_number.value;
	var voyage_destination	= document.Report.voyage_destination.value;
	var voyage_number		= document.Report.voyage_number.value;
	var voyage_type			= [];
	var voyage_pagenumber	= document.Report.voyage_pagenumber.value;
	var manifest_auto		= document.Report.manifest_auto.value;
	var portofdischarge		= document.getElementById('portofdischarge').value;
	var withprice			= document.getElementById('withprice').checked;
	var withlocalprice		= document.getElementById('withlocalprice').checked;
	var shipperType			= document.getElementById('shipperType').value;
	
	if(withprice) withprice=1;
	else withprice=0;
	if(withlocalprice)withlocalprice=1;
	else withlocalprice=0;
	
	var portofloading		= document.getElementById('portofloading').value;
	var localagent_code		= document.getElementById('localagent_code').value;
	var grpby				= document.getElementById('grpby').value;
	
	var chkrep = 1;
	for (var i=0; i < document.Report.rep.length; i++)
	{
		if (document.Report.rep[i].checked)
		{
			chkrep = document.Report.rep[i].value;
		} 
	}
	
	for(var i=0; i<document.Report.voyage_type.length;i++){
		
		if (document.Report.voyage_type[i].selected)
			voyage_type.push(document.Report.voyage_type[i].value);
	}

	if(chkrep == 4 || chkrep == 5 || chkrep == 6 || chkrep == 7 || chkrep == 8 || chkrep == 10){
		if(document.Report.voyage_year.value == ''){
			alert("Voyage year is Empty!");
			document.Report.voyage_year.focus();
			return 0;			
		}
	}
	if(chkrep == 4 || chkrep == 5 || chkrep == 7 || chkrep == 10){
		if(document.Report.voyage_number.value == ''){
			alert("Voyage Number is Empty!");
			document.Report.voyage_number.focus();
			return 0;			
		} else if(voyage_type == ''){
			alert("Voyage Type is Empty!");
			document.Report.voyage_type.focus();
			return 0;			
		}	
	}
	
	
	var cntrtype = document.getElementById('cntrtype').value;
	
	var vOrderby = document.getElementById('vOrderby').value;
	
	var vOthers = 0;
	if (chkrep == 9)
		vOthers = 1;
	
	if (chkrep == 2){
		if (exp == 1)
			var rep_name = 'Exp_ListofContainers.php';	
		else
			var rep_name = 'Rep_ListofContainers.php';	
	}
	var str = '';
	if(chkrep == 1 || chkrep == 9)
		str="manifest_Report1.php?billlading="+billlading+"&withprice="+withprice+"&withlocalprice="+withlocalprice+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination
				+"&voyage_number="+voyage_number+"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto
				+"&localagent_code="+localagent_code+"&shipperType="+shipperType+"&cntrtype="+cntrtype+"&portofloading="+portofloading+"&vOrderby="+vOrderby+"&vOthers="+vOthers;
	else if(chkrep == 2)
		str = rep_name+"?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;
	else if(chkrep == 4)
		str = "Rep_RedManifest.php?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;
	else if(chkrep == 5)
		str = "Rep_ContainerDebarque.php?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;
	else if(chkrep == 6)
		str = "Rep_Recaptulation.php?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;
	else if(chkrep == 7)
		str = "Rep_Taahod.php?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;	
	else if(chkrep == 8)
		str = "Rep_DemurrageList.php?billlading="+billlading+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;	
	else if(chkrep == 10)
		str = "Rep_ManifestDetails.php?billlading="+billlading+"&withprice="+withprice+"&withlocalprice="+withlocalprice+"&voyage_year="+voyage_year+"&bol_number="+bol_number+"&voyage_destination="+voyage_destination+"&voyage_number="+voyage_number+
				"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&portofdischarge="+portofdischarge+"&manifest_auto="+manifest_auto+"&portofloading="+portofloading+
				"&localagent_code="+localagent_code+"&grpby="+grpby+"&cntrtype="+cntrtype+"&vOrderby="+vOrderby;					
	window.open(str);
}

function clearPage(){
	var x = document.Report;
	
	x.billlading.value = '';
	x.manifest_auto.value = '';
	x.voyage_year.value = '';
	x.voyage_number.value = '';
	x.voyage_destination.value = '';
	x.bol_number.value = '';
	x.voyage_type.value = '';
	x.voyage_pagenumber.value = '';
	x.portofloading.value = '';
	x.portofdischarge.value = '';
	x.localagent_code.value = '';
	x.rep.value = '';
	x.grpby.value = '';
	x.withprice.value = '';
	x.withlocalprice.value = '';
	x.cntrtype.value='';
	x.action='Form_Manifest_Reports.php';
	x.submit();
	
}

function openAgent(str){
	win = window.open('list_agent.php?str='+str, 'agentlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1250,height=500,top=100');		
	win.focus();
}

</script>
<title>Add Report</title>

<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;}

</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="tabs.css">

<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
</head>
<body >
<form name='Report' method='post' >
<input type=hidden name='mode' value='$mode'>
<input type=hidden name='message' value='$message'>
<input type=hidden name='Port_Auto' value='$Port_Auto'>
HERE;



if($mode==''){
$status='disabled';
$dis='disabled';

}

if($mode=='view'){

$status='readonly';
$dis='disabled';

}

if($mode=='insert')
$status='';

//$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

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'>
			<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'>Report</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='clrpage' name='clrpage' onclick='clearPage(); return false;' title='Clear Page' ><span><span>Clear Page</span></span></button>";
					echo "<button type='button' id='viewreport' name='viewreport' onclick='openmanifestreport(); return false;' title='Print' ><span><span>Print</span></span></button>";
					echo "<button type='button' id='viewreport' name='viewreport' onclick=\"openmanifestreport('1'); return false;\" title='Print Excel' ><span><span>Excel</span></span></button>";
				echo"</td>
				
				
			</tr>
			
	</table>
	</td>
</tr>
				<tr>
					<td id='content-body'>
						<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=65%>
							<tr bgcolor='#F7F7F7' >
								<td valign='top' align='left'>
									<table border='0' style='table-layout:fixed' align='left' valign='top' width=100%>
										<col width=100>
										<col width=100>
										<col width=200>
										
										";
					echo "
										<tr bgcolor='#F7F7F7' height='25'>
										
											<td valign='center' align='left' ><span class='style1'>BOL Identification&nbsp;<span class='style26'>*</span></span>
											<td align='left'><input type='text' name='billlading' id='billlading' value='' style='font-size:12px; width:200px; height:18px;'    /></td>
											<td align='left'>
											&nbsp;<span class='style1'>Manifest Number </span>&nbsp;&nbsp;
											<input type='text' name='manifest_auto' id='manifest_auto' value='' style='font-size:12px;  height:18px;' size=3   />
										&nbsp;&nbsp;&nbsp;&nbsp;
											<span class='style1' ><input type='checkbox' name='withprice' id='withprice'     /> with TARROS Price
											<input type='checkbox' name='withlocalprice' id='withlocalprice'     /> with Local Price</span>
											</td>
											
											</tr>";
											
											
											
										ECHO "	<tr><td><table border=0 ><tr><td>
										<span class='style1'>voyage year</span> </td>
										<td><input type='text' name='voyage_year'  size=2 maxlength='2' value='".htmlspecialchars($voyage_year, ENT_QUOTES)."'>
									</td></tr>
									<tr><td>
									<span class='style1'>BOL Number </span></td>
										<td><input type='text' name='bol_number' size=3  maxlength='3' value='".htmlspecialchars($bol_number, ENT_QUOTES)."'>
										
										</td></tr>";
										echo "<tr>
										</tr></table></td>
										
										<td valign='top'>
										<table border=0><tr><td>
										<span class='style1'>voyage number  </span></td>
										<td>
										<input type='text' name='voyage_number'  size=3 maxlength='3' value='".htmlspecialchars($voyage_number, ENT_QUOTES)."'>
										</td></tr>
										<tr><td><span class='style1'>BOL Type </span></td>
										<td><select name='voyage_type[]' id='voyage_type'  multiple style='width:55px;'>
										<option value=''></option>
										<option value='I'>I</option>
										<option value='E'>E</option>
										<option value='G'>G</option>
										<option value='T'>T</option>
										<option value='S'>S</option>
										</select></td></tr>
										<tr><td>
										</tr></table></td>
										
										<td valign='top' >
										<table><tr><td>
										
										<span class='style1'>voyage destination </span>
										</td>
										<td>
										<input type='text' name='voyage_destination' size=3 maxlength='3' value='".htmlspecialchars($voyage_destination, ENT_QUOTES)."'>
										</td></tr>
										<tr><td>
										<span class='style1' >BOL Page Number </span></td>
										<td><input type='text' name='voyage_pagenumber' value='".htmlspecialchars($voyage_pagenumber, ENT_QUOTES)."' maxlength='2' size=2>
										</td>
										</tr>
										<tr>
										</tr>
										
										
										</td></tr></table>";
				
echo "<tr height='30px'><td><span class='style1' >Port of Loading </span><select name='portofloading' id='portofloading' style='width:130px;'>";
$query="select port_name from port order by port_name";
$res=mysql_query($query,$connection);
echo "<option value=''></option>";

while($row=mysql_fetch_array($res)){
	echo "<option value='$row[0]' ".($row[0]==$portlading?'selected':'')." >$row[0]</option>";
}
echo "</select>";  
echo "</td><td><span class='style1' >Port of Discharge </span><select name='portofdischarge' id='portofdischarge' style='width:130px;'>";
echo "<option value=''></option>";
$query="select port_name from port order by port_name";
$res=mysql_query($query,$connection);
while($row=mysql_fetch_array($res)){
	echo "<option value='$row[0]' ".($row[0]==$portofdischarge?'selected':'')." >$row[0]</option>";
}
echo "</select></td>";
echo "<td><span class='style1' >Local Agent Code &nbsp;</span>";
echo " <input type='text' name='localagent_code' id='localagent_code' value='$localagent_code' style='width:70px;'>
		<input type='text' name='localagent_name' id='localagent_name' value='$localagent_name' style='width:150px;'>
		<img src='img/btnopen.jpg' title='Select Agent ' width='15' height='17' border='0' onmouseover=\"style.cursor='hand';\" onclick=\"openAgent(4); return false;\" style='cursor: pointer;'>";
echo "</td>";
echo "</tr>";
echo "<tr height='30px'><td><span class='style1' >Shipper Type</span>&nbsp;&nbsp;&nbsp;&nbsp;
	<select name='shipperType' id='shipperType' style='width:130px;'>";
echo "<option value='0'></option>";
echo "<option value='1'>Local Agent</option>";
echo "<option value='2'>Agent</option>";
echo "</select></td><td></td><td></td></tr>";	 
echo "<tr height='30px'><td colspan='3'><hr></td></tr>";	 

echo "<tr><td><div style='float:left;width:120px;'><span class='style1' >Show Container</span></div>
<div style='float:left;width:120px;'><select name='cntrtype' id='cntrtype' style='width:95px;'>
	<option value=''></option>
	<option value='1'>FULL</option>
	<option value='2'>EMPTY</option>
	</select></div></td></tr>";
	
echo "<tr><td><div style='float:left;width:120px;'><span class='style1' >Order By</span> </div>
	<div style='float:left;width:120px;'><select name='vOrderby' id='vOrderby' style='width:95px;'>
	<option value=''></option>
	<option value='1'>Agent Code</option>
	</select></div></td></tr>";
	
echo "<tr><td><span class='style1' >Group by &nbsp;</span> <select name='grpby' id='grpby' style='width:130px;'>";
echo "<option value=''></option>";
echo "<option value='1'>Port of Loading</option>";
echo "<option value='2'>BL Type</option>";
echo "<option value='3'>Local Agent Code</option>";
echo "</select></td><td align='right'>";
echo "<span class='style1' >Reports: </span></td>";
echo "<td><span class='style1' ><input type='radio' name='rep' value='1' checked> Manifest Report";
echo "<br><input type='radio' name='rep' value='2' > List of Container Report";
//echo "<br><input type='radio' name='rep' value='3' > Cargo Manifest Report";
echo "<br><input type='radio' name='rep' value='4' > Red / Blue / Green Manifest Report";
echo "<br><input type='radio' name='rep' value='5' > Conteneurs Debarques Report";
echo "<br><input type='radio' name='rep' value='6' > Recaptulation ";
echo "<br><input type='radio' name='rep' value='7' > Taahod ";
echo "<br><input type='radio' name='rep' value='8' > Demurrage ";
echo "<br><input type='radio' name='rep' value='9' > Bahri ";
echo "<br><input type='radio' name='rep' value='10' > Manifest Cash Flow ";
echo "</span></td></tr>";	

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



echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	
echo" </table>  ";//end of last table menu		 



print <<<HERE
</form>
</body>

HERE;

?>














