<?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">
				  
				  <?php
				$file_id = $_GET['i'];
				$assign_id = $_GET['assignId'];
				$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'];
							$dest_id = $data81['dest_id'];
							$goods = $data81['goods'];
							$fileStatus = $data81['fileStatus'];
							$expStatus = $data81['expStatus'];
							$uplStatus = $data81['uplStatus'];
				            }	

               $sql81w = "SELECT * FROM quotation	
					WHERE file_id = {$file_id}";

				$result81w = $conn->query($sql81w);
				//$data81 = $result81->fetch_row();
				
				while($data81w = mysqli_fetch_array($result81w))
							{
							$totalAmount = number_format($data81w['total_amount'],2);
							$totalAmount11 = $data81w['total_amount'];
				            }							
				      ?>
				  
                    <a href="pendingCustomerFiles.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
                    <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/updateCustFile.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="file_id" value="<?php echo $file_id; ?>">
				<input type="hidden" name="assign_id" value="<?php echo $assign_id; ?>">
				
				<div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Customer Name </label>
                 <select class="form-control" name="client_id" id="client_id" autocomplete="off">
			  						<?php
			  							$productSql = "SELECT * FROM clients where client_id='$client_id'";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['client_id']."'>".$row['client_fname'].'&nbsp&nbsp'.$row['client_mname'].'&nbsp&nbsp'.$row['client_lname']."</option>";
										 	} // /while 
											
										$productSql7 = "SELECT * FROM clients where client_id!='$client_id'";
			  							$productData7 = $conn->query($productSql7);
			  							while($row7 = $productData7->fetch_array()){									 		
			  								echo "<option value='".$row7['client_id']."'>".$row7['client_fname'].'&nbsp&nbsp'.$row7['client_mname'].'&nbsp&nbsp'.$row7['client_lname']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								
								<br/>
                         <label for="client_id" class="error" generated="true"></label>
                      
                </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">
			  						<?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="dest_id" id="dest_id" autocomplete="off">
			  						<?php
			  							$productSql22 = "SELECT * FROM destination where dest_id='$dest_id'";
			  							$productData22 = $conn->query($productSql22);
			  							while($row22 = $productData->fetch_array()){									 		
			  								echo "<option value='".$row22['dest_id']."'>".$row['dest_name']."</option>";
										 	} // /while 
											
										$productSql72 = "SELECT * FROM destination where dest_id!='$dest_id'";
			  							$productData72 = $conn->query($productSql72);
			  							while($row72 = $productData72->fetch_array()){									 		
			  								echo "<option value='".$row72['dest_id']."'>".$row72['dest_name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
               
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
			  
			  <div class="controls">
			  <div class="row">
			   <div class="col-sm-4">
			   <div class="form-group">
                 <label for="form_name">Currency Type </label>
				  <select class="form-control" name="currency_id" id="currency_id" autocomplete="off" required />
				              <option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql39 = "SELECT * from currency";
			  							$productData39 = $conn->query($productSql39);

			  							while($row39 = $productData39->fetch_array()){									 		
			  								echo "<option value='".$row39['currency_id']."'>".$row39['currencyName']."</option>";
										 	} // /while 

			  						?>
		  						</select>
                      
                 </div>
			     </div>
				 </div>
			     </div>
			  
			
			  
			   <div class="controls">
			  <div class="row">
			   
			    <div class="col-sm-4">
			  <div class="form-group">
			  
			  
                 <label for="form_name">Create Quotation: </label>
				 
				 
			 
                      
                </div>
			   </div>
				
				
			  </div>	  
              </div>
			  
			
			  
			     
              <table class="table" id="productTable">
			  	<thead>
			  		<tr>			  			
			  			<th style="width:5%;">S/NO.</th>		  			
			  			<th style="width:30%;">Description</th>
			  			<th style="width:30%;">Amount</th>
						<th style="width:30%;">Total</th>
						<th style="width:5%;"></th>
			  		</tr>
			  	</thead>
			  	
					<tbody>
			  		<?php
			  		$arrayNumber = 0;
					$no 	= 1;
			  		for($x = 1; $x < 2; $x++) { ?>
			  			<tr id="row<?php echo $x; ?>" class="<?php echo $arrayNumber; ?>">	
						
						   <td style="padding-left:20px;">
			  					<div class="form-group">
								<?php
								print $x;
								?>
			  					</div>
			  				</td>
							
							
							

                            
							
							 <td style="padding-left:20px;">
			  					<div class="form-group">
								<textarea rows="3" cols="50" name="item_desc[]" id="item_desc<?php echo $x; ?>" class="form-control" style="margin-left:0%;" autocomplete="off" required /> </textarea>
								
			  					</div>
			  				</td>	
							
							<td style="padding-left:20px;">			  					
			  					<input type="text" name="rate[]" id="rate<?php echo $x; ?>" onkeyup="getTotal(<?php echo $x ?>)" autocomplete="off"  class="form-control" required />			  					
			  					<input type="hidden" name="rateValue[]" id="rateValue<?php echo $x; ?>" autocomplete="off" class="form-control" />			  					
			  				</td>
							
							
			  				<td style="padding-left:20px;">			  					
			  					<input type="text" name="total[]" id="total<?php echo $x; ?>" autocomplete="off" class="form-control" disabled="true" required />			  					
			  					<input type="hidden" name="totalValue[]" id="totalValue<?php echo $x; ?>" autocomplete="off" class="form-control" />			  					
			  				</td>
							
							
						
							
							
			  				<td>

			  					<button class="btn btn-default removeProductRowBtn" type="button" id="removeProductRowBtn" onclick="removeProductRow(<?php echo $x; ?>)"><i class="glyphicon glyphicon-trash"></i></button>
			  				</td>
			  			</tr>
		  			<?php
		  			$arrayNumber++;
					$no++;
			  		} // /for
			  		?>
			  	</tbody>
				
				
			  </table>
			  
			   <div class="col-md-6">
			  
			       <div class="form-group">
				    <div class="col-sm-6">
				      <button type="button" class="btn btn-default" onclick="addRow()" id="addRowBtn" data-loading-text="Loading..."> <i class="glyphicon glyphicon-plus-sign"></i> Add Row </button>
				    </div>
				  </div> <!--/form-group-->	
				
			  	<div class="form-group">
				    <label for="subTotal" class="col-sm-3 control-label">Sub Total</label>
				    <div class="col-sm-9">
				      <input type="text" class="form-control" id="subTotal" name="subTotal" value="<?php echo $totalAmount; ?>" disabled="true" />
				      <input type="hidden" class="form-control" id="subTotalValue" name="subTotalValue" value="<?php echo $totalAmount11; ?>" />
				    </div>
				  </div> <!--/form-group-->	
				  
				    
	  		  
			  </div> <!--/col-md-6-->
			  
			 
			  
			  
			  
		
			   
			  <!--<div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Remarks: </label>
                 
			
			<textarea id="remarks" rows="10" cols="50" name="remarks" class="form-control" style="margin-left:0%;" autocomplete="off"> </textarea>
			
			
                      
                </div>
			   </div>
			   
			    <div class="col-sm-6">
			  <div class="form-group">
                 <label for="form_name">Return To: </label>
                 
			
			 <select class="form-control" name="returnedto_id" id="returnedto_id" autocomplete="off" />
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql412 = "SELECT staff.firstname,staff.lastname,users.user_id,designation.des_short_name,designation.des_name FROM users,staff,designation where role_id=1 and user_id!='$user_id' and  users.staff_id=staff.staff_id and staff.des_id=designation.des_id";
			  							$productData412 = $conn->query($productSql412);
			  							while($row412 = $productData412->fetch_array()){									 		
			  								echo "<option value='".$row412['user_id']."'>".$row412['firstname']."&nbsp&nbsp&nbsp&nbsp".$row412['lastname']."&nbsp&nbsp&nbsp&nbsp(".$row412['des_name'].")&nbsp&nbsp"."</option>";
										 	} // /while 

			  						?>
		  						</select>
			<br/>
                         <label for="returnedto_id" 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="quot_status"]').on('click', function(){
        if ($(this).val() == 'YES'){
			 $('#textboxes33').show();
			 
			
        }else {
			$('#textboxes33').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
            },
			
			
			
			
            "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/updateCustFile.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
}
?>