<?php
session_start();
error_reporting(0);
include('phpaccess/linkme.php');
if(strlen($_SESSION['alogin'])==0)
	{	
header('location:index.php');
}
else{
date_default_timezone_set('Africa/Lagos');// change according timezone
$currentTime = date( 'd-m-Y h:i:s A', time () );

//<!-- sn	type	detial	file	date		  -->
  

if(isset($_POST['submit']))
{
$cid=$_SESSION['sn'];
$title=$_POST['title'];
$type=$_POST['type'];
$detial=$_POST['detial'];
$date=date("d-M-Y");


$query=mysqli_query($con,"insert into berth (title,type,detial,file,date) values('$title','$type','$detial','$docnewfile','$date')");

// code for show complaint number
$sql=mysqli_query($con,"select sn from berth order by sn desc limit 1");
while($row=mysqli_fetch_array($sql))
{
 $cmpn=$row['sn'];
}
$complainno=$cmpn;
echo '<script> alert("Your Registration has been successfully Submitenmited )</script>';
echo "<script type='text/javascript'> document.location = 'berthing.php'; </script>";
}

if(isset($_GET['del']))
		  {
		  mysqli_query($con,"delete from berth where sn = '".$_GET['sn']."'");
         $_SESSION['delmsg']="Berth deleted !!";
		  }
		  

?>



<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="favicon.ico">
    <title>Bearthing Update - ENL Consortium Limited</title>
    <!-- Simple bar CSS -->
    <link rel="stylesheet" href="css/simplebar.css">
    <!-- Fonts CSS -->
    <link href="https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,100;0,200;0,300;0,400;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
    <!-- Icons CSS -->
    <link rel="stylesheet" href="css/feather.css">
    <link rel="stylesheet" href="css/dataTables.bootstrap4.css">
    <!-- Date Range Picker CSS -->
    <link rel="stylesheet" href="css/daterangepicker.css">
    <!-- App CSS -->
    <link rel="stylesheet" href="css/app-light.css" id="lightTheme" disabled>
    <link rel="stylesheet" href="css/app-dark.css" id="darkTheme">
 
</head>
  </head>
  <body class="vertical  light ">
    <div class="wrapper">
      
        <?php include("phpaccess/topnav_fin.php");?>
		
	  <!--Insert NAV Here-->
      <aside class="sidebar-left border-right bg-white shadow" id="leftSidebar" data-simplebar>
        
        <?php include("phpaccess/nav_fin.php");?>
      
	  </aside>
	  <!--End Insert NAV Here-->
		  
      <main role="main" class="main-content">
        <div class="container-fluid">
          <div class="row justify-content-center">
            <div class="col-12">
              <h2 class="page-title">Berthing Update</h2>
              <p class="text-muted"> <h5><a href="new_berthing">Add New Berthing Update</a></h5><p>
              <div class="row">
			  
			  
                <div class="col-md-12">
                  <div class="card shadow mb-4">
                    <div class="card-body">
                     


					  
					  <table class="table datatables" id="dataTable-1">
									<?php if(isset($_POST['submit']))
{?>
									<div class="alert alert-success">
										<button type="button" class="close" data-dismiss="alert">×</button>
									<strong>Well done!</strong>	<?php echo htmlentities($_SESSION['msg']);?><?php echo htmlentities($_SESSION['msg']="");?>
									</div>
<?php } ?>


									<?php if(isset($_GET['del']))
{?>
									<div class="alert alert-error">
										<button type="button" class="close" data-dismiss="alert">×</button>
									<strong>Oh snap!</strong> 	<?php echo htmlentities($_SESSION['delmsg']);?><?php echo htmlentities($_SESSION['delmsg']="");?>
									</div>
<?php } ?>

									<br />
									
									

<!-- DATE POSTED	VESSEL	STATUS		  -->
                        <thead>
                          <tr>			
							<th>SN</th>				
							<th>DATE POSTED</th>				
						    <th>VESSEL</th>
							<th>STATUS</th>
							<th>Action</th>
                           </tr>
                        </thead>
                        <tbody>
						<?php 
$query=mysqli_query($con,"SELECT * FROM `berth` ORDER BY `berth`.`sn` DESC");
while($row=mysqli_fetch_array($query))
{
?>	  
                          <tr>
							<td><?php echo htmlentities($row['sn']);?></td>
							<td><?php echo htmlentities($row['date']);?></td>
							
							 <td>6  - <?php echo htmlentities($row['6_vessel']);?><br>7  - <?php echo htmlentities($row['7_vessel']);?><br>7A - <?php echo htmlentities($row['7A_vessel']);?><br>8  - <?php echo htmlentities($row['8_vessel']);?><br>9  - <?php echo htmlentities($row['9_vessel']);?><br>10  - <?php echo htmlentities($row['10_vessel']);?><br>10A  - <?php echo htmlentities($row['10A_vessel']);?><br>11  - <?php echo htmlentities($row['11_vessel']);?><br>12  - <?php echo htmlentities($row['12_vessel']);?><br>13  - <?php echo htmlentities($row['13_vessel']);?><br>14  - <?php echo htmlentities($row['14_vessel']);?></td> 
    
    
     <td>6 - <?php echo htmlentities($row['6_status']);?><br>7 - <?php echo htmlentities($row['7_status']);?><br>7A - <?php echo htmlentities($row['7A_status']);?><br/>8 - <?php echo htmlentities($row['8_status']);?><br/>9 - <?php echo htmlentities($row['9_status']);?><br/>10 - <?php echo htmlentities($row['10_status']);?><br/>10A - <?php echo htmlentities($row['10A_status']);?><br/>11 - <?php echo htmlentities($row['11_status']);?><br/>12 - <?php echo htmlentities($row['12_status']);?><br/>13 - <?php echo htmlentities($row['13_status']);?><br/>14 - <?php echo htmlentities($row['14_status']);?></td> 
     
							
                          
							<td>
							<a class="btn btn-info" href="modify_berth.php?cid=<?php echo htmlentities($row['sn']);?>" target="_blank">Modify</a>

			
							  </td>
							
                          </tr>
						  
						  <?php } ?>
							
							</tbody>
                      </table>
					  
					  
					  
                    </div> <!-- /.card-body -->
                  </div> <!-- /.card -->
                </div> <!-- /.col -->
                
				
				
				
              </div> <!-- end section -->
              
		
            </div> <!-- .col-12 -->
          </div> <!-- .row -->
        </div> <!-- .container-fluid -->
        
		
		
        
      </main> <!-- main -->
	  
    </div> <!-- .wrapper -->
    <script src="js/jquery.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/moment.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/simplebar.min.js"></script>
    <script src='js/daterangepicker.js'></script>
    <script src='js/jquery.stickOnScroll.js'></script>
    <script src="js/tinycolor-min.js"></script>
    <script src="js/config.js"></script>
    <script src='js/jquery.dataTables.min.js'></script>
    <script src='js/dataTables.bootstrap4.min.js'></script>
    <script>
      $('#dataTable-1').DataTable(
      {
        autoWidth: true,
        "lengthMenu": [
          [5, 10, 20, -1],
          [5, 10, 20, "All"]
        ]
      });
    </script>
   
  </body>
</html>
<?php } ?>