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

<?php if($allPermissions['manifest']['read']=="1"){ ?>


<section class="content-header">
	<div class="content-header-left">
		<h1>View Manifest</h1>
	</div>
	<?php if($allPermissions['manifest']['create']=="1"){ ?>
	<div class="content-header-right" style="margin-right: 1%;">
		<a href="manifest-add.php" class="btn btn-danger btn-sm">Create Manifest</a>
	</div>
	<?php } ?>
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-info">
				<div class="box-body table-responsive">
					<table id="example1" class="table table-bordered table-striped">
						<thead>
							<tr>
								<th width="20">SL</th>
								<th>Action</th>
								<th>Manifest Number</th>
								<th>Reference Number</th>
								<th>Orgin</th>
								<th width="80">Date</th>
								<th>Transport Name</th>
								<th>Sending Through</th>
								<th>Number of Pickup Entry</th>
								
							</tr>
						</thead>
							<?php
							$i=0;
							if($clientType=="Admin"){
							$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");
							}else{
							$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.client_id=$clientId");
							}
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
							foreach ($result as $row) {
								$i++;
								?>
								<tbody>
						    <tr>
									<td><?php echo $i; ?></td>
									<td><a href="manifest-pickup-entry.php?id=<?php echo $row['id'];?>" class="btn btn-danger btn-xs">View</a></td>
									<td><?php echo $row['manifest_id']; ?></td>
									<td><?php if($row['ref_no']!=''){ echo $row['manifest_id'];}else{ echo 'N/A';} ?></td>
									<td><?php echo $row['origin']; ?></td>
									<td><?php 
									$day=date_create($row['entry_date']);
                                    $new_date=date_format($day,'d-m-Y');                        
                                     echo $new_date; 
									?></td>
									<td><?php if($clientType=="Admin"){  echo $row['courier']; } else{ echo "CSCS"; } ?></td>
									<td><?php echo $row['t_mode']; ?></td>
									<td><?php echo $row['no_of_entry']; ?></td>
									
						    </tr>
						    <?php }?>
						</tbody>
						
						
						
						
						
					</table>
				</div>
			</div>
		</div>
	</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 }else{ ?>
<center><h4 style="color:red;">You don't have permission to view manifest </h4></center>
<?php } ?>
<?php require_once('footer.php'); ?>