<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php

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



print <<< HERE
<HTML>
<HEAD>
<TITLE> Waybill Report </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css" >

.header1 {
	font-size: 14px;
	font-weight: bold;
	font-family: sans-serif;
}

.detail1 {
	font-size: 14px;
	font-family: sans-serif;
}
.table1{
	border: 1px solid black;
    padding-left: 10px;
    padding-bottom: 10px;
	padding-top: 10px;
}

table.table2 tr:first-child td {
	border-top: 1px solid black;
	border-bottom: 1px solid black;
	border-left: 1px solid black;
}
table.table2 tr:first-child td:last-child {
	border-right: 1px solid black;
}
.table3 {
	border: 1px solid black;
	padding-left: 5px;
	padding-top: 5px;
	padding-bottom: 5px;
}

.table3 tr td div {
	border-bottom: 1px dotted black;
    width: 80%;
    height: 10px;
}

.table5 tr td div {
	border-bottom: 1px solid black;
    width: 80%;
    height: 10px;
}
</style>
</HEAD>

HERE;



include("config.inc.php");
include 'function.inc.php';

set_time_limit(0);

$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");

$querylog="SELECT print as printaccess 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);
}

$id = $_GET['id'];

$query = "select company_name, Company_memo, COMPANY_TELEPHONE from setup";
$result = mysql_query($query, $connection);
$row = mysql_fetch_row($result);
$companyname = $row[0];
$companymemo = $row[1];
$companytel = $row[2];

if ($printaccess==0 or $printaccess=='')
echo'<BODY oncontextmenu="return false;">';
else
echo'<BODY>';

$now=current_server_time($connection);
$dt=split(" ",$now[0]);
$printdate=split("-",$dt[0]);

$query = "select date_format(LW_date,'%d-%m-%Y')as lwDate, date_format(LW_date,'%h:%i %p') as lwTime, Logistic_Waybill.project_code as project_code, LW_ContainerSize, LW_ContainerNb, LW_Reference, 
			LW_BLNumber, LW_DeliveryAddress, LW_ContactPhone, ledger_name, LW_ClientReference, LW_Remark, LW_DSLNumber
			from Logistic_Waybill 
			left join clients on clients.ledger_number = Logistic_Waybill.client_code
			where LW_id = $id";
$result = mysql_query($query, $connection);
$row = mysql_fetch_array($result);
extract($row);
			
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table1'>
		<col width=15%><col width=2%><col width=50%><col width=13%><col width=2%><col width=18%>";
// header
echo "<tr>
		<td colspan='3'><span style='font-size: 18px;font-weight: bold; font-family: sans-serif;'>$companyname</span></td>
		<td  colspan='3'><span style='font-size: 16px;font-weight: bold; font-family: sans-serif;'>Waybill/Delivery Note</span></td>
	</tr>";
echo "<tr>
		<td colspan='3'><span style='font-size: 12px;font-weight: bold; font-family: sans-serif;'>$companymemo</span></td>
		<td ><span class='header1'>Waybill #</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$LW_Reference - [$LW_ContainerSize' ft]</span></td>
	</tr>";
echo "<tr>
		<td colspan='3'><span style='font-size: 12px;font-weight: bold; font-family: sans-serif;'>$companytel</span></td>
		<td ><span class='header1'>Date</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$lwDate <br>$lwTime</span></td>
	</tr>";
echo "<tr>
		<td></td><td></td><td></td>
		<td ><span class='header1'>File</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$project_code</span></td>
	</tr>";

echo "<tr>
		<td><span class='header1'>Client</span></td>
		<td><span class='header1'>:</span></td>
		<td><span class='detail1'>$ledger_name</span></td>
		<td ><span class='header1'>Client Ref</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$LW_ClientReference</span></td>
	</tr>";		
echo "<tr>
		<td><span class='header1'>Delivery Address</span></td>
		<td><span class='header1'>:</span></td>
		<td><span class='detail1'>$LW_DeliveryAddress</span></td>
		<td ><span class='header1'>Container #</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$LW_ContainerNb</span></td>
	</tr>";	
echo "<tr>
		<td><span class='header1'>Contact Phone</span></td>
		<td><span class='header1'>:</span></td>
		<td><span class='detail1'>$LW_ContactPhone</span></td>
		<td ><span class='header1'>BL #</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$LW_BLNumber</span></td>
	</tr>";	
echo "<tr>
		<td><span class='header1'></span></td>
		<td><span class='header1'></span></td>
		<td><span class='detail1'></span></td>
		<td ><span class='header1'>DSL #</span></td>
		<td><span class='header1'>:</span></td>
		<td ><span class='detail1'>$LW_DSLNumber</span></td>
	</tr>";		
echo "</table>";

echo "<div style='width:100%;height:30px;'> </div>";
//table 2
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table2'>
		<col width=10%><col width=35%><col width=15%><col width=20%><col width=20%>";

echo "<tr height='25px'>
		<td align='center'><span class='header1'>Items</span></td>
		<td align='center'><span class='header1'>Details</span></td>
		<td align='center'><span class='header1'>Type / Unit</span></td>
		<td align='center'><span class='header1'>Qty.</span></td>
		<td align='center'><span class='header1'>Qty. Rcvd.</span></td>
	</tr>";		
echo "<tr height='25px'>
		<td colspan='3' style='border-left:1px solid black;border-right:1px solid black;padding-left:5px;'><span class='header1'>Additional Remarks: </span></td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;padding-left:5px;'><span class='header1'>Missing Quantity</span></td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;'></td>
	</tr>";	
echo "<tr height='25px'>
		<td colspan='3' rowspan='3' valign='top' style='border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding-left:5px;'>$LW_Remark</td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;padding-left:5px;'><span class='header1'>Damaged Quantity</span></td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;'></td>
	</tr>";		
echo "<tr height='25px'>
		
		<td style='border-bottom:1px solid black;border-right:1px solid black;padding-left:5px;'><span class='header1'>SON Quantity</span></td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;'></td>
	</tr>";	
echo "<tr height='25px'>
	
		<td style='border-bottom:1px solid black;border-right:1px solid black;padding-left:5px;'><span class='header1'>NAFDAC Quantity</span></td>
		<td style='border-bottom:1px solid black;border-right:1px solid black;'></td>
	</tr>";		
echo "</table>";

echo "<div style='width:100%;height:30px;'> </div>";

//table 3
echo "<table cellspacing='0' cellpadding='0' width='100%'><col width=45%><col width=10%><col width=45%>";
echo "<tr><td valign='top'>";
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='25px'>
		<td colspan='2'><span class='header1'>Tranport:</span></td>
	</tr>";			
echo "<tr height='25px'>
		<td><span class='detail1'>Vehicle Reg. #:</span></td>
		<td><div></div></td>
	</tr>";		
echo "<tr height='25px'>
		<td><span class='detail1'>DSL Seal #</span></td>
		<td><div style='height:14px;'><span>$LW_DSLNumber</span></div></td>
	</tr>";
echo "<tr height='25px'>
		<td><span class='detail1'>Driver's Name</span></td>
		<td><div></div></td>
	</tr>";	
echo "<tr height='25px'>
		<td><span class='detail1'>Driver's Signature</span></td>
		<td><div></div></td>
	</tr>";		
echo "</table>";
echo "</td><td></td><td valign='top'>";		
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='30px'>
		<td colspan='2'><span class='header1'>INFORMATION IS ACKNOWLEDGE and VERIFED BY:</span></td>
	</tr>";			
echo "<tr height='30px'>
		<td><span class='detail1'>Driver's Name</span></td>
		<td><div></div></td>
	</tr>";		
echo "<tr height='30px'>
		<td><span class='detail1'>Date</span></td>
		<td><div></div></td>
	</tr>";
echo "<tr height='30px'>
		<td><span class='detail1'>Mobile / GSM</span></td>
		<td><div></div></td>
	</tr>";	
echo "<tr height='5px'>
		<td></td>
		<td></td>
	</tr>";		
echo "</table>";
echo "</td></tr>";
echo "</table>";	

echo "<div style='width:100%;height:30px;'> </div>";

//table 4
echo "<table cellspacing='0' cellpadding='0' width='100%'><col width=45%><col width=10%><col width=45%>";
echo "<tr><td valign='top'>";
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='25px'>
		<td colspan='2'><span class='header1'>Loading Details:</span></td>
	</tr>";			
echo "<tr height='25px'>
		<td><span class='detail1'>Date Loaded at Port:</span></td>
		<td><div></div></td>
	</tr>";		
echo "<tr height='25px'>
		<td><span class='detail1'>Time Loaded at port</span></td>
		<td><div></div></td>
	</tr>";
echo "<tr height='25px'>
		<td><span class='detail1'>Place of Delivery</span></td>
		<td><div></div></td>
	</tr>";	
echo "</table>";
echo "</td><td></td><td valign='top'>";		
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='25px'>
		<td colspan='2'><span class='header1'>Off-Loading Details:</span></td>
	</tr>";			
echo "<tr height='25px'>
		<td><span class='detail1'>Date/Time Arrival Dest.</span></td>
		<td><div></div></td>
	</tr>";		
echo "<tr height='25px'>
		<td><span class='detail1'>Date/Time Offloading</span></td>
		<td><div></div></td>
	</tr>";
echo "<tr height='25px'>
		<td><span class='detail1'>Receiver Name</span></td>
		<td><div></div></td>
	</tr>";		
echo "</table>";
echo "</td></tr>";
echo "</table>";	

//table 5
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table5' >
		<col width=45%><col width=10%><col width=45%>";
echo "<tr height='50px'><td colspan='3'></td></tr>";		
echo "<tr><td align='center'><div></div></td><td></td><td align='center'><div></div></td></tr>";		
echo "<tr><td align='center'><span class='detail1'>D.S.L - (Staff) Signature</span></td><td></td><td align='center'><span class='detail1'>Client - Signature</span></td></tr>";		
echo "</table>";

echo "<div style='width:100%;height:30px;'> </div>";

//table 6
echo "<table cellspacing='0' cellpadding='0' width='100%'><col width=45%><col width=10%><col width=45%>";
echo "<tr><td valign='top'>";
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='25px'>
		<td colspan='2'><span class='header1'>DSL Staff Comments:</span></td>
	</tr>";	
echo "<tr height='25px'>
		<td><span class='detail1'>Seal Intact</span></td>
		<td><div></div></td>
	</tr>";
echo "<tr height='25px'>
		<td><span class='detail1'>Seal Broken</span></td>
		<td><div></div></td>
	</tr>";
echo "<tr height='25px'>
		<td><span class='detail1'>Staff/Escort</span></td>
		<td><div></div></td>
	</tr>";	
echo "<tr height='25px'>
		<td><span class='detail1'>Contact #</span></td>
		<td><div></div></td>
	</tr>";		
echo "</table>";
echo "</td><td></td><td valign='top'>";		
echo "<table cellspacing='0' cellpadding='0' width='100%' class='table3'>
		<col width=40%><col width=60%>";
echo "<tr height='25px'>
		<td colspan='2'><span class='header1'>Clients Remarks:</span></td>
	</tr>";			
echo "<tr height='100px'>
		<td></td>
		<td></td>
	</tr>";				
echo "</table>";
echo "</td></tr>";
echo "</table>";		
function current_server_time($connection){

  $string="Select date_format(NOW(),'%Y-%m-%d %h:%i %p') ";
  $result=mysql_query($string,$connection) or die(mysql_error());
  $now=mysql_fetch_row($result);

  return $now;
}

function explodeword($date)
{

$trim = explode('/',$date);
$trim = "$trim[2]"."-"."$trim[1]"."-"."$trim[0]";
return $trim;
}




if ($printaccess==1)
print <<< HERE

<script language=javascript>
if (typeof(window.print) != 'undefined')
{
    window.print();
}
</script>
</BODY>
</HTML>
HERE;
