<?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>
	
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>
	
  
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<script type="text/javascript">
$(document).ready(function(){
    $('#client_id').on('change',function(){
        var regID = $(this).val();
        if(regID){
            $.ajax({
                type:'POST',
                url:'ajaxData11.php',
                data:'client_id='+regID,
                success:function(html){
                    $('#inv_id').html(html);
                }
            }); 
        }else{
            $('#inv_id').html('<option value="">Select Client First</option>');
        }
    });

});
</script>

	
  </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="collectedPayments.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$payment_id = $_GET['i'];
				$sql81 = "SELECT * FROM collected_payments,payment_mode WHERE collected_payments.payment_id = {$payment_id} and payment_mode.payment_mode_id=collected_payments.payment_mode_id";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$client_id = $data81['client_id'];
							$currency_id = $data81['currency_id'];
							$inv_id  = $data81['inv_id'];
							$amount_paid = $data81['amount_paid'];
							$payment_desc = $data81['payment_desc'];
							$cheque_no = $data81['cheque_no'];
							$payment_mode_id = $data81['payment_mode_id'];
							$payment_mode_name = $data81['name'];
				            }
							
				      ?>
					
					
					
                    <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/editPayment.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="payment_id" value="<?php echo $payment_id; ?>">
				<input type="hidden" name="amountPaid" value="<?php echo $amount_paid; ?>">
				<input type="hidden" name="currencyId" value="<?php echo $currency_id; ?>">
				
				<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Customer</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <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="item form-group">
                        <label for="password" class="control-label col-md-3">Invoice No</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						 <select class="form-control" name="inv_id" id="inv_id" autocomplete="off">
									<?php
									$productSql244 = "SELECT * FROM invoices where inv_id='$inv_id'";
			  							$productData244 = $conn->query($productSql244);
			  							while($row244 = $productData244->fetch_array()){									 		
			  								echo "<option value='".$row244['inv_id']."'>".$row244['inv_no']."</option>";
										 	} // /while 


                                    $productSql2441 = "SELECT * FROM invoices where inv_id!='$inv_id' and client_id='$client_id'";
			  							$productData2441 = $conn->query($productSql2441);
			  							while($row2441 = $productData2441->fetch_array()){									 		
			  								echo "<option value='".$row2441['inv_id']."'>".$row2441['inv_no']."</option>";
										 	} // /while 
			  						?>
			  						
		  						</select>
								
                         
                        </div>
                      </div>
					  
					  <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Payment Of (Description) </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<textarea id="payment_desc" rows="10" cols="50" name="payment_desc" class="form-control" style="margin-left:0%;" autocomplete="off"> <?php echo htmlspecialchars($payment_desc);  ?> </textarea>
			            <br/>
                         <label for="payment_desc" class="error" generated="true"></label>
                          
                       
						  
						</div>
                      </div>
					  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Account</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="currency_id" id="currency_id" autocomplete="off">
			  						<!--<option value="">~~SELECT~~</option>-->
			  						<?php
			  							$productSql4 = "SELECT * FROM currency where currency_id='$currency_id'";
			  							$productData4 = $conn->query($productSql4);
			  							while($row4 = $productData4->fetch_array()){									 		
			  								//echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."</option>";
											echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."&nbsp&nbsp".$row4['currencyName']."</option>";
										 	} // /while 
											
										$productSql4e = "SELECT * FROM currency where currency_id!='$currency_id'";
			  							$productData4e = $conn->query($productSql4e);
			  							while($row4e = $productData4e->fetch_array()){									 		
			  								//echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."</option>";
											echo "<option value='".$row4e['currency_id']."'>".$row4e['bank_name']."&nbsp&nbsp".$row4e['bank_account']."&nbsp&nbsp".$row4e['currencyName']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="currency_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Amount Paid</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						<input type="hidden" name="upl_status" value="<?php echo 'NO'; ?>">
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Amount Paid" name="amount" id = "amount" min="1" value="<?php echo $amount_paid; ?>" min="0" class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="amount" class="error" generated="true"></label>
						
						
						</div>
						</div>		  
					  
					  
					  
					  
				
		<div class="item form-group">
					  
                        <label for="password2" class="control-label col-md-3 col-sm-3 col-xs-12"> Payment Mode </label>
						
						
						
		<label class="radio-inline">
          <input type="radio" name="payment_mode_id" value="Cash" 
		  
		  <?php if($payment_mode_id==1){ echo "checked";}?> /> Cash
         </label>
		 
		 <label class="radio-inline">
          <input type="radio" name="payment_mode_id" value="Cheque" <?php if($payment_mode_id==2){ echo "checked";}?> /> Cheque
         </label>
		 
		 
		 <label class="radio-inline">
          <input type="radio" name="payment_mode_id" value="Bank Transfer" <?php if($payment_mode_id==5){ echo "checked";}?> /> Bank Transfer
         </label>
						
		
                      </div>
					  
								  <?php
			  if($payment_mode_id==1){  
			  ?>
			  
			  <div id="textboxes3">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Slip No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Slip No" name="bank_slip_no" id = "bank_slip_no" value="<?php echo $cheque_no; ?>" class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  
			  <?php
			  }else if($payment_mode_id==2){
			  ?>
			  
			   <div id="textboxes3" style="display: none">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Slip No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Slip No" name="bank_slip_no" id = "bank_slip_no"  class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  <?php
               }else{
			  ?>
			  
			  <div id="textboxes3" style="display: none">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Slip No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Slip No" name="bank_slip_no" id = "bank_slip_no"  class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  <?php
                }
			  ?>
					  
					  
					  <?php
			  if($payment_mode_id==1){  
			  ?>
			  
			  <div id="textboxes5" style="display: none">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Transfer Ref No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Transfer Ref No" name="bank_ref_no" id = "bank_ref_no"  class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  
			  <?php
			  }else if($payment_mode_id==2){
			  ?>
			  
			   <div id="textboxes5" style="display: none">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Transfer Ref No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Transfer Ref No" name="bank_ref_no" id = "bank_ref_no"  class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  <?php
               }else{
			  ?>
			  
			  <div id="textboxes5">
			  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Transfer Ref No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Bank Transfer Ref No" name="bank_ref_no" id = "bank_ref_no" value="<?php echo $cheque_no; ?>" class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
			  
			  
			  </div>
			  
			  <?php
                }
			  ?>
					  
		
		
		  <?php
			  if($payment_mode_id==1){  
			  ?>
			  
			  <div id="textboxes4" style="display: none">
						
						
						
					    <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Cheque No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Cheque No" name="cheque_no" id = "cheque_no"   class="form-control col-md-7 col-xs-12">
						 
						</div>
						</div>
						
						<!--<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Upload Cheque</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
						
						</div>
						</div>-->
						
						
						
						</div>
			  
			  <?php
			  }else if($payment_mode_id==2){
			  ?>
		
						
						<div id="textboxes4">
						
						<!--<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Account</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="currency_id1" id="currency_id1" autocomplete="off">
			  						
			  						<?php
			  							//$productSql41 = "SELECT * FROM currency where currency_id='$currency_id'";
			  							//$productData41 = $conn->query($productSql41);
			  							//while($row41 = $productData41->fetch_array()){									 		
			  								//echo "<option value='".$row41['currency_id']."'>".$row41['bank_name']."&nbsp&nbsp".$row41['bank_account']."&nbsp&nbsp".$row41['currencyName']."</option>";
										 	//} // /while 
											
											
										//$productSql41d = "SELECT * FROM currency where currency_id!='$currency_id'";
			  							//$productData41d = $conn->query($productSql41d);
			  							//while($row41d = $productData41d->fetch_array()){									 		
			  								//echo "<option value='".$row41d['currency_id']."'>".$row41d['bank_name']."&nbsp&nbsp".$row41d['bank_account']."&nbsp&nbsp".$row41d['currencyName']."</option>";
										 	//} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="currency_id1" class="error" generated="true"></label>
                         
                        </div>
                      </div>-->
						
						<!--<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Amount Paid</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						<input type="hidden" name="upl_status" value="<?php echo 'YES'; ?>">
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Amount Paid" name="amount1" id = "amount1" value="<?php echo $amount_paid; ?>" class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="amount1" class="error" generated="true"></label>
						
						
						</div>
						</div>-->
						
					    <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Cheque No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Cheque No" name="cheque_no" id = "cheque_no" value="<?php echo $cheque_no; ?>" class="form-control col-md-7 col-xs-12">
						  
						
						</div>
						</div>
						
						<!--<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Upload Cheque</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
						
						</div>
						</div>-->
						
						
						
						</div>
						
					<?php
			           }else{
                     ?>

                    <div id="textboxes4" style="display: none">
						
						
						
					    <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Cheque No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Cheque No" name="cheque_no" id = "cheque_no"  class="form-control col-md-7 col-xs-12">
						 
						
						</div>
						</div>
						
						<!--<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Upload Cheque</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
						
						</div>
						</div>-->
						
						
						
						</div>					 


                    <?php
                       }
                    ?>					
						
				
			 <div class="item form-group">
                        <label for="password" class="control-label col-md-3"></label>
					  	
                        <div class="form-group submitButtonFooter col-md-6 col-sm-6 col-xs-12">
						
						 <!--<input  type="number" style="width:100%;margin-left:0%;" placeholder="Cheque No" name="cheque_no" id = "cheque_no"  class="form-control col-md-7 col-xs-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>
			
			  <!--<div class="form-group submitButtonFooter">
			    <div class="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>
	$(document).ready(function(){
    $('input[name="payment_mode_id"]').on('click', function(){
        if ($(this).val() == 'Cash'){
			 $('#textboxes3').show();
			 $('#textboxes4').hide();
			 $('#textboxes5').hide();
        }else if($(this).val() == 'Cheque'){
			$('#textboxes4').show();
			$('#textboxes3').hide();
			$('#textboxes5').hide();
		}else if($(this).val() == 'Bank Transfer'){
			$('#textboxes5').show();
			$('#textboxes3').hide();
			$('#textboxes4').hide();
		}
	
		
    });
});


 $("#id_frm").validate({
        rules: {
			
			"client_id": {
                required: true
            },
			
			"currency_id": {
                required: true
            },
			
			"currency_id1": {
                required: true
            },
			
			"currency_id2": {
                required: true
            },
			
			"amount": {
                required: true
            },
			
			"amount1": {
                required: true
            },
			
			"amount2": {
                required: true
            },
			
			
			"payment_desc": {
                required: true
            },
			
			"bank_slip_no": {
                required: true
            },
			
			"payment_mode_id": {
                required: true
            }
		 
        },
        messages: {
			
			"client_id": {
                required: "Please Select Client."
            },
			
			"currency_id": {
                required: "Please Select Bank Account."
            },
			
			"currency_id1": {
                required: "Please Select Bank Account."
            },
			
			"currency_id2": {
                required: "Please Select Bank Account."
            },
			
			"amount": {
                required: "Please Enter Amount Paid"
            },
			
			"amount1": {
                required: "Please Enter Amount Paid"
            },
			
			"amount2": {
                required: "Please Enter Amount Paid"
            },
			
			
			
			"payment_desc": {
                required: "Please Enter Description"
            },
			
			"bank_slip_no": {
                required: "Please Enter Bank Slip Number"
            },
			
			"payment_mode_id": {
                required: "Please Select Payment Mode"
            }
			
			
			
        },
        // 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
}
?>