<?php require_once('header.php');
							
$statement = $pdo->prepare("SELECT courier_company.company_name as courier,manifest.*,tbl_mode_transport.transport_mode as t_mode FROM manifest inner join tbl_mode_transport inner join courier_company on manifest.sending_through=tbl_mode_transport.id AND  manifest.transport_name=courier_company.id WHERE manifest.id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
								?>
<style>
    table {
  border-collapse: collapse;
}

table, td, th {
  border: 1px solid black;
}
</style>
<script>
    function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>

<section class="content-header">
	<div class="content-header-left">
		<h1>View Manifest</h1>
	</div>
	<div class="content-header-right" style="margin-right: 1%;">
		<a href="manifest.php" class="btn btn-danger btn-sm">Back</a>
	</div>
	
</section>
<section class="content">
<div id="printableArea">
    <?php foreach ($result as $row) { 
        $mani_fest=$row['manifest_id'];
        ?>
    <table  style="width: 100%;line-height: 34px;">
                     <tr>
						<th colspan=3><b><center><h4>MAINFEST</h4></center></th>
				    </tr>
				     <tr>
				         <td style="text-align:left;padding-left: 2%;">MANIFEST NO :&emsp;<?php echo $row['manifest_id']; ?></td>
			            <td style="text-align:left;padding-left: 2%;" rowspan=2>ORIGIN / PICKUP HUB :&emsp;<?php echo $row['origin']; ?> </td>
			            
			            <td style="text-align:left;padding-left: 2%;" rowspan=2>LOGISTICS PARTNER :&emsp;<?php if($clientType=="Admin"){  echo $row['courier']; } else{ echo "CSCS"; } ?></td>
	            	</tr>
                    <tr>
                        <!--<td style="text-align:left;padding-left: 2%;">DESTINATION :&emsp;<?php echo $row['destination']; ?></td>-->
			            
			            <td style="text-align:left;padding-left: 2%;">DATE :&emsp;  <?php $day=date_create($row['entry_date']); $new_date=date_format($day,'d-m-Y');  echo $new_date; ?></td>
			            <!--<td style="text-align:left;padding-left: 2%;">SENDING THROUGH :&emsp;<?php echo $row['t_mode']; ?> </td>-->
            		</tr>
            		
    </table>
     <?php } ?>  
  
	<div class="row">
		<div class="col-md-12">
		    <div >
				<div >
			  
					<table style="width: 100%;line-height: 34px;" border=1>
			        	<thead>
			        <tr>
			            <th style="text-align:center" rowspan=2>S.No</th>
			            <th style="text-align:center" rowspan=2>AWB</th>
			            <th style="text-align:center" rowspan=2>Origin</th>
			            <th style="text-align:center" rowspan=2>Destination</th>
			            <th style="text-align:center" colspan=3>Weight</th>
			            <th style="text-align:center" rowspan=2>Actual Weight</th>
			            <th style="text-align:center" rowspan=2>No.of Boxes</th>
			            <th style="text-align:center" rowspan=2 >Quantity</th>
			            <th style="text-align:center" rowspan=2>Mode</th>
			            <th style="text-align:center" rowspan=2>Remark</th>
			        </tr>
			        <tr>
			            <th style="text-align:center">L</th>
			            <th style="text-align:center">B</th>
			            <th style="text-align:center">H</th>
			        </tr>
			        	</thead>
			        <tbody>
			       <?php 
			       $i=0;$n_pics=0;$n_weight=0;
			                $statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name FROM pickup_entry INNER JOIN tbl_user on tbl_user.id=pickup_entry.client_id and pickup_entry.manifest_id=?");
							$statement->execute(array($mani_fest));
							$result = $statement->fetchAll(PDO::FETCH_ASSOC); 
							foreach ($result as $row) {
							    $i++;
							    $n_pics=$n_pics+$row['quantity'];
							    $n_weight=$n_weight+$row['c_weight'];
							?>
			        <tr>
			            <td style="text-align:center"><?php echo $i; ?></td>
			            <td style="text-align:center"><?php echo $row['3pl_awb']; ?></td>
			            <td style="text-align:center"><?php echo $row['shipper_city']; ?></td>
			            <td style="text-align:center"><?php echo $row['consignee_city']; ?></td>
			            <td style="text-align:center"><?php echo $row['vw_length']; ?></td>
			            <td style="text-align:center"><?php echo $row['vw_breadth']; ?></td>
			            <td style="text-align:center"><?php echo $row['vw_height']; ?></td>
			            <td style="text-align:center"><?php echo $row['a_weight']; ?></td>
			            <td style="text-align:center"><?php echo $row['boxes']; ?></td>
			            <td style="text-align:center"><?php echo $row['quantity']; ?></td>
			            <td style="text-align:center"><?php echo strtoupper($row['business_mode']); ?></td>
			            <td style="text-align:center"></td>
			        </tr>
			        <?php } ?>
			         <tr>
			            <td style="text-align:left" colspan="7">&ensp;HUB incharge / Security Sign</td>
			            <td style="text-align:left" colspan="5">&ensp;Picker Sign</td>
			           
			        </tr>
			       
			        </tbody>
			    </table>
			    

			</div>
			</div>
	</div>
	</div>
</div>
	

	<br><br>

	<div class="content-footer-right" style="margin-left:45%">
		<input type="button" class="btn btn-success" onclick="printDiv('printableArea')" value="Print" />
	</div>
</section>



<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
            </div>
            <div class="modal-body">
                <p>Are you sure want to delete this item?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-success btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>


<?php require_once('footer.php'); ?>