<?php
session_start();
if(!isset ($_SESSION['user_id'])){
	header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('includes/session.php');
    include('../Server/connection.php');
	echo "<div class='div-request div-hide'>editOrd</div>";
    	
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	
	 <?php
  include 'title.php';
         ?>
	
	
	<link type = "image/png" rel="icon" href="images/brvision.png" />

    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
  <!-- jquery ui -->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<style>
  .error {
    color: #F00;
}  

</style>
	
	<script type="text/javascript">
$(document).ready(function(){
    $('#entryId').on('change',function(){
        var regID = $(this).val();
        if(regID){
            $.ajax({
                type:'POST',
                url:'ajaxData2.php',
                data:'entryId='+regID,
                success:function(html){
                    $('#entryNameId').html(html);
                }
            }); 
        }else{
            $('#entryNameId').html('<option value="">Select EntryPoint Type First</option>');
        }
    });

});
</script>

<style>
        
        h1,h2,h3,h4,h5,h6{
            margin: 0;
            padding: 0;
        }
        p{
            margin: 0;
            padding: 0;
        }
        .container7{
            width: 100%;
            margin-right: auto;
            margin-left: auto;
			background-color: #F6F6F6;
        }
        .brand-section{
           background-color: #0d1033;
           padding: 10px 40px;
		   border: 1px solid gray;
        }
		.brand-section1{
           background-color: #F6F6F6;
           padding: 10px 40px;
		   font-size:7px;
		   border: 1px solid gray;
        }
        .logo{
            width: 50%;
        }
		.tbl{
		background-color: #F6F6F6;	
		}

        .row{
            display: flex;
            flex-wrap: wrap;
        }
        .col-6{
            width: 50%;
            flex: 0 0 auto;
			/*background-color: #F6F6F6;*/
        }
        .text-white{
            color: #fff;
			font-size:18px;
        }
		.text-black{
			font-size:20px;
        }
        .company-details{
            float: right;
            text-align: right;
        }
        .body-section{
            padding: 16px;
            border: 1px solid gray;
			background-color: #F6F6F6;
        }
        .heading{
            font-size: 15px;
            margin-bottom: 08px;
        }
        .sub-heading{
            color: #262626;
            margin-bottom: 05px;
			font-size:12px;
			text-align:left;
        }
        table{
            background-color: #fff;
            width: 100%;
            border-collapse: collapse;
        }
        table thead tr{
            border: 1px solid #111;
            background-color: #f2f2f2;
        }
        table td {
            vertical-align: middle !important;
            text-align: center;
        }
        table th, table td {
            padding-top: 08px;
            padding-bottom: 08px;
        }
        .table-bordered{
            box-shadow: 0px 0px 5px 0.5px gray;
        }
        .table-bordered td, .table-bordered th {
            border: 1px solid #dee2e6;
        }
        .text-right{
            text-align: end;
        }
        .w-20{
            width: 20%;
        }
        .float-right{
            float: right;
        }
    </style>
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
             <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>


           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="clientFiles.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$file_id = $_GET['i'];
				$sql81 = "SELECT * FROM client_files WHERE file_id = {$file_id}";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$client_id = $data81['client_id'];
							$entryId = $data81['entryId'];
							$entryName_id = $data81['entryName_id'];
							$b_lNo = $data81['b_lNo'];
							$tra_RefNo = $data81['tra_RefNo'];
							$consignee = $data81['consignee'];
							$vessel_flight = $data81['vessel_flight'];
							$sline = $data81['sline'];
							$eta = $data81['eta'];
							$destination = $data81['dest_id'];
							$goods = $data81['goods'];
							$fileStatus = $data81['fileStatus'];
							$expStatus = $data81['expStatus'];
							$uplStatus = $data81['uplStatus'];
				            }
                 $sql812 = "SELECT * FROM clients WHERE client_id = {$client_id}";
				$result812 = $conn->query($sql812);
				while($data812 = mysqli_fetch_array($result812))
							{
							$clientName = $data812['client_fname']." ".$data812['client_lname'];
                            }							
				      ?>
					
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
				  
				
				<div class="x_content" style="overflow: auto;">
				
				<?php if (isset($_SESSION['success_message']) && !empty($_SESSION['success_message'])) { ?>
                        <div class="success-message" style="margin-bottom: 20px;font-size: 20px;color: green;"><?php echo $_SESSION['success_message']; ?></div>
                        <?php
                        unset($_SESSION['success_message']);
                    }
                    ?>	
				 
				  <div class="success-messages"></div> <!--/success-messages-->

               <form class="form-horizontal" id="id_frm" method="POST" action="php_action/editClientFile.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="file_id" value="<?php echo $file_id; ?>">
				<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
				
				
				<div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Customer Name </label>
						<input type="text" class="form-control"  value="<?php echo $clientName; ?>" readonly="readonly"  autocomplete="off"/> 
								
								
                      
                </div>
			   </div>
			   
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name">Entry Point Type </label>
                 <select class="form-control" name="entryId" id="entryId" autocomplete="off" required>
			  						<?php
			  							$productSql2 = "SELECT * FROM entrypoint_type where entryId='$entryId'";
			  							$productData2 = $conn->query($productSql2);
			  							while($row2 = $productData2->fetch_array()){									 		
			  								echo "<option value='".$row2['entryId']."'>".$row2['name']."</option>";
										 	} // /while 
											
											
									  $productSql24 = "SELECT * FROM entrypoint_type where entryId!='$entryId'";
			  							$productData24 = $conn->query($productSql24);
			  							while($row24 = $productData24->fetch_array()){									 		
			  								echo "<option value='".$row24['entryId']."'>".$row24['name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								
								<br/>
                         <label for="entryId" class="error" generated="true"></label>
                      
                </div>
			   </div>
			   
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name">Entry Point Name </label>
                 <select class="form-control" name="entryNameId" id="entryNameId" autocomplete="off">
									<?php
									$productSql244 = "SELECT * FROM entrypoint_name where entryName_id='$entryName_id'";
			  							$productData244 = $conn->query($productSql244);
			  							while($row244 = $productData244->fetch_array()){									 		
			  								echo "<option value='".$row244['entryName_id']."'>".$row244['ent_name']."</option>";
										 	} // /while 


                                    $productSql2441 = "SELECT * FROM entrypoint_name where entryName_id!='$entryName_id' and entryId='$entryId'";
			  							$productData2441 = $conn->query($productSql2441);
			  							while($row2441 = $productData2441->fetch_array()){									 		
			  								echo "<option value='".$row2441['entryName_id']."'>".$row2441['ent_name']."</option>";
										 	} // /while 
			  						?>
			  						
		  						</select>
                      
                </div>
			   </div>
			 
			  
			  	</div>	  
                </div>
				
				
			  <div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">B/L NO: </label>
                 
			<input type="text" class="form-control" id="b_lNo" name="b_lNo" value="<?php echo $b_lNo; ?>" autocomplete="off"/>
			<br/>
                         <label for="b_lNo" class="error" generated="true"></label>
                      
                </div>
			   </div>
			   
			   
			    <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">TRA Ref.Number: </label>
                
				<input type="text" class="form-control" id="tra_RefNo" name="tra_RefNo" value="<?php echo $tra_RefNo; ?>" autocomplete="off"/>
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
			  
			  
			  <div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">CONSIGNEE: </label>
                 
			<input type="text" class="form-control" id="consignee" name="consignee" value="<?php echo $consignee; ?>" autocomplete="off" />
			
			<br/>
                         <label for="consignee" class="error" generated="true"></label>
                      
                </div>
			   </div>
			   
			   
			    <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">GOODS: </label>
                
				<input type="text" class="form-control" id="goods" name="goods" value="<?php echo $goods; ?>" autocomplete="off" />
				
				<br/>
                         <label for="goods" class="error" generated="true"></label>
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
			  
			  
			  <div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">VESSEL/FLIGHT/TRUCK: </label>
                 
			<input type="text" class="form-control" id="vesselFlight" name="vesselFlight" value="<?php echo $vessel_flight; ?>" autocomplete="off"/>
			
			<br/>
                         <label for="vesselFlight" class="error" generated="true"></label>
                      
                </div>
			   </div>
			   
			   
			    <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Shipping Line/Transporter/Airline: </label>
                
				<input type="text" class="form-control" id="sline" name="sline" value="<?php echo $sline; ?>" autocomplete="off"/>
				
				 <br/>
                         <label for="sline" class="error" generated="true"></label>
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
				
				 <div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Estimated Time Arrival - E.T.A: </label>
                 
			<input type="text" class="form-control" id="eta" name="eta" value="<?php echo $eta; ?>" autocomplete="off" />
			
			<br/>
                         <label for="eta" class="error" generated="true"></label>
                      
                </div>
			   </div>
			   
			   
			    <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">DESTINATION: </label>
				 
				  <select class="form-control" name="destination" id="destination" autocomplete="off">
			  						<?php
			  							$productSql24 = "SELECT * FROM destination where dest_id='$destination' ORDER BY dest_name";
			  							$productData24 = $conn->query($productSql24);
			  							while($row24 = $productData24->fetch_array()){									 		
			  								echo "<option value='".$row24['dest_id']."'>".$row24['dest_name']."</option>";
										 	} // /while 
											
									    $productSql242 = "SELECT * FROM destination where dest_id!='$destination' ORDER BY dest_name";
			  							$productData242 = $conn->query($productSql242);
			  							while($row242 = $productData242->fetch_array()){									 		
			  								echo "<option value='".$row242['dest_id']."'>".$row242['dest_name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
                
				
				
				<br/>
                         <label for="destination" class="error" generated="true"></label>
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
			  
			
			
			  <div class="form-group submitButtonFooter">
			    
				 <div class="col-sm-offset-0 col-sm-12">
			      <button type="submit" id="createOrderBtn" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Save Changes</button>
			    </div>
			  </div>
			  
			  
			</form>                  
					
				</div>  
               
				
				
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
				<script>
//$(function(){
$(document).ready(function(){
    $('input[name="exp_status"]').on('click', function(){
        if ($(this).val() == 'YES'){
			 $('#textboxes33').show();
			 
			
        }else {
			$('#textboxes33').hide();
			
		}
	
		
    });
});


$(document).ready(function(){
    $('input[name="upl_status"]').on('click', function(){
        if ($(this).val() == 'Yes'){
			 $('#textboxes3').show();
			 //$('#textboxes34').show();
        }else {
			$('#textboxes3').hide();
			//$('#textboxes34').hide();
		}
	
		
    });
});


 $("#id_frm").validate({
        rules: {
			
			"client_id": {
                required: true
            },
			
			"entryId": {
                required: true
            },
			
			"b_lNo": {
                required: true
            },
			
			"consignee": {
                required: true
            },
			
			"goods": {
                required: true
            },
			
			
			"vesselFlight": {
                required: true
            },
			
			
			"sline": {
                required: true
            },
			
			"file": {
                required: true
            },
			
			"message": {
                required: true
            },
			
			"exp_status": {
                required: true
            },
			
			
            "eta": {
                required: true,
                //minlength: 10,
                // minlength: 10 // same rule twice
            },
			
			"message": {
                required: "Please Compose Message."
            },
			
			"destination": {
                required: true
            }
			
			
            
        },
        messages: {
			
			"client_id": {
                required: "Please Select Client."
            },
			
			"entryId": {
                required: "Please Select Entry Point Type"
            },
			
			"b_lNo": {
                required: "Please Enter B/L NO"
            },
			
            "consignee": {
                required: "Please Enter CONSIGNEE"
            },
			
			"goods": {
                required: "Please Enter Goods"
            },
			
			"vesselFlight": {
                required: "Please Enter Vessel/Flight/Truck."
            },
			
			"sline": {
                required: "Please Enter Shipping Line/Transporter/Airline"
            },
			
			"file": {
                required: "Please Upload at least one document."
            },
			
			"exp_status": {
                required: "Please Select Yes Or No."
            },
			
			
			"eta": {
                required: "Please Enter Estimated Time Arrival - E.T.A"
            },
			
			
			"destination": {
                required: "Please Enter Destination"
            }
			
			
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });


</script>
	
	<script>
	// order date picker
		$("#eta").datepicker();
		
		// delivery date picker
		//$("#dueDate").datepicker();
	
	</script>

   <!-- Must -->
    <script src="custom/js/editClientFiles.js"></script>
	
    <!-- Must Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	<!-- file input -->
	<script src="assests/plugins/fileinput/js/plugins/canvas-to-blob.min.js'); ?>" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/sortable.min.js" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/purify.min.js" type="text/javascript"></script>
	<script src="assests/plugins/fileinput/js/fileinput.min.js"></script>	


	<!-- DataTables -->
	<script src="assests/plugins/datatables/jquery.dataTables.min.js"></script>

  </body>
</html>



<?php
}
?>