<?php defined('BASEPATH') OR exit('No direct script access allowed');
$billing = array();
$shipping = (count($address)==1)?$address[0]:array();
if (!$shipping && count($address)) {
	$billing = $address[0];
	$shipping = $address[1];
}
$tNo_text 		= 'Payment Number';
$tDate_text 	= 'Payment Date';
$dueDate_text 	= 'Due Date';
function mylang($lbl)
{
	global $label;  
    return (!empty($label) && !empty($label[$lbl])) ? $label[$lbl] : lang($lbl);
}
?>
<page footer="page" pagegroup="new">
<?php 
	if (isset($download) && $download==-1){
		echo '<bookmark title="'.$tNo.'" level="0" ></bookmark>';
	}
?>
	<div class="trans">
		<table border="0" cellspacing="0" cellpadding="0" style="width:100%">
			<tr>
				<td style="width:33%;text-align:left;padding-left:10px;"> 
					<div class="customer"><?php echo lang($tType); ?> </div>
				</td>
				<td style="width:33%">
					<!--<table style="width:80%">
						<tr>
							<td class="label"><?php echo $tNo_text;?></td>
							<td class="label"><?php echo '#'.$tNo;?></td>
						</tr>
						<tr>
							<td class="label"><?php echo $tDate_text;?></td>
							<td><?php echo $tDate;?></td>
						</tr>
						<?php if ($ref) { ?>
							<tr>
								<td class="label"><?php echo $dueDate_text;?></td>
								<td><?php echo $dueDate;?></td>
							</tr>
						<?php } ?>
						<?php if ($ref) { ?>
							<tr>
								<td class="label"><?php echo 'Reference No';?></td>
								<td><?php echo $ref;?></td>
							</tr>
						<?php } ?>
					</table> -->
				</td>
				<td style="width:33%;">
					<h4><?php echo get_company('name');?> </h4>
					<div><?php echo get_company('address1');?></div>
					<?php if (get_company('address2')) {
						echo '<div>'.get_company('address2').'</div>';
					} ?> 
					<div><?php echo get_company('city');?></div>
					<div><?php echo get_company('zip');?></div>
					<div><?php echo get_company('phone');?></div>
				</td>
			</tr>
			<tr><td style="padding:20px 0pc 20px 0px;" colspan="3">
				<div style="border-bottom:1px solid #eeeeee;"></div>
			</td></tr>
			<?php if (!empty($contact)) { ?> 
			<tr>
				<td style="width:33%;" valign="top">
					<h4><?php echo 'Name';?> </h4>
					<div><?php echo $contact['name'];?></div>
					<?php if (!empty($contact['taxNo'])) {
						echo '<h4>Tax No</h4>'
						.'<div>'.$contact['taxNo'].'</div>';
					} ?>
				</td>
				<td style="width:33%;">
					<h4><?php echo mylang("BillingAddress"); ?> </h4>
					<div><?php echo $billing['address1'];?></div>
					<?php if ($billing['address2']) {
						echo '<div>'.$billing['address2'].'</div>';
					} ?>
					<div><?php echo $billing['city'];?></div>
					<div><?php echo $billing['zip'];?></div>
					<div><?php echo $billing['phone'];?></div>
				</td>
				<td style="width:33%;">
					<h4><?php echo mylang("ShippingAddress");?> </h4>
					<div><?php echo $shipping['address1'];?></div>
					<?php if ($billing['address2']) {
						echo '<div>'.$billing['address2'].'</div>';
					} ?>
					<div><?php echo $shipping['city'];?></div>
					<div><?php echo $shipping['zip'];?></div>
					<div><?php echo $shipping['phone'];?></div>
				</td>			
			</tr>
			<?php } ?>
			<tr>
				<td colspan="3" align="center">
					<table align="center" cellspacing="10" cellpadding="0" style="width:50%">
						<tr>
							<td class="label" align="left" ><?php echo $tNo_text;?></td>
							<td class="label" align="left"><?php echo '#'.$tNo;?></td>
						</tr>
						<tr>
							<td class="label" align="left"><?php echo $tDate_text;?></td>
							<td align="right"><?php echo $tDate;?></td>
						</tr>
						<?php if ($dueDate) { ?>
							<tr>
								<td class="label" align="left"><?php echo $dueDate_text;?></td>
								<td align="center"><?php echo $dueDate;?></td>
							</tr>
						<?php } ?>
						<?php if ($ref) { ?>
							<tr>
								<td class="label" align="left"><?php echo mylang("Reference");?></td>
								<td align="left">><?php echo $ref;?></td>
							</tr>
						<?php } ?>
						<?php if ($totAmount) { ?>
							<tr style = "padding:10px 0px;">
								<td class="label" valign="middle" align="left"><?php echo 'Amount Received';?></td>
								<td class="label" style="font-size:20px;" align="left"><?php echo $totAmount;?></td>
							</tr>
						<?php } ?>

					</table>
				</td>
			</tr>
			<tr>
				<td colspan="3" style="padding-top:20px;" >
					<table border="0" cellspacing="0" cellpadding="0" style="width:100%;border-color:#EEEEEE;" class="middlecol">
						<thead>
							<tr>
								<th style="width:25%;border-left:1px solid #999999;">Invoice Number</th>
								<th style="width:25%">Invoice Date</th>
								<th style="width:25%">Invoice Amount</th>
								<th style="width:25%">Payment Amount</th>								
							</tr>
						</thead>
						<tbody><?php
							foreach ($payments as $row) {
								echo '<tr>'
								.'<td style="border-left:1px solid #999999;">'.$row['tNo'].'</td>'
								.'<td>'.$row['tDate'].'</td>'
								.'<td>'.$row['totAmount'].'</td>'
								.'<td>'.$row['allotAmt'].'</td>'
								.'</tr>';
							} ?>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
	</div>
	<?php if ($notes) {?>
	<div class="notes">
		<div><?php echo mylang("Notes"); ?></div>
		<div style="color: #666666;padding-left: 10px;padding-top: 5px;width: 100%;"><?php echo $notes;?></div>
	</div>
	<?php } ?>
	<page_footer>
		<table align="center" border="0" cellspacing="0" cellpadding="0" style="width:100%;">
			<tr>
				<td style="text-align:right;width:70%;"></td>
				<td style="text-align:center;width:30%;border-top:1px solid #000000;"><?php echo mylang("AuthorizedSignature"); ?></td>
			</tr>
		</table>
	</page_footer>
<style>
.trans {
	color:#666666;
	font-size:15px;
	width: 100%;
	min-height: 30%;
	margin: 0px;
}
table td {
	color:#000000;
}

table td.label {
	color:#000000;
	font-weight:bold;
}
table td h4 {
	color:#000000;
	margin-top:0px;
	margin-bottom:5px;
}
.customer {
	width:40%; 
	height: 15px;
	background:#208ED3;
	color:#FFF;
	font-weight: bold;
	padding: 7px 17px 7px 7px;
	text-align: right;
	margin-left: -30px;
}

table.middlecol tr th, table.middlecol tr td {
	border-right:1px solid #999999;
	border-bottom:1px solid #999999;
}
.middlecol{
	color:#666666;
	font-size:13px;
	width: 100%;
	height: 60%;
}
.middlecol th{
	background:#208ED3;
	text-align:center;
	color:#FFF;
	font-size:13px;
	font-weight:bold;
	vertical-align: middle;
	padding: 5px;
}
.middlecol tr.odd{
	background: #EAEAEA;
}
.middlecol tr.even{
	background: #FFFFFF;
}
.middlecol td{
	padding-right:10px;
	padding: 8px;
}
.tax_disable{
	display:none;
}
.notes{
	font-size: 12px;
	color: #000000;
    width: 100%;
}	
</style>
</page>
