
<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	
 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script>


 

<script type="text/javascript">
  
	 $(document).on("click", "#managebtndelete", function()
        {
          var itemid2 = $(this).data('id');
		  $("#itemid2").val(itemid2); 
		  
		  
		   
        });
				    $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
	
		 $(this).ready( function() {  
            $("#phone").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
					   url: "<?php echo base_url(); ?>Systemusers/branchlookupmpesa",  

                      //  url: "<?php echo base_url(); ?>Systemusers/branchlookupmpesadebts",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });  
		
		
		var util = { };

document.addEventListener('keydown', function(e){

    var key = util.key[e.which];
    if( key ){
        e.preventDefault();
    }
  if( key === 'F1' ){        
      $("#id").focus();
    }
    if( key === 'F2' ){        
      $("#qty").focus();
	   $("#qty").focus().value = "";
	  document.getElementById("qty").value = "";
    }
	 if( key === 'F3' ){        
      $("#cash").focus();
	   $("#cash").focus().value = "";
	  document.getElementById("cash").value = "";
    }
	 if( key === 'F4' ){        
      $("#mpesa").focus();
    }
	 if( key === 'F5' ){        
      $("#card").focus();
    }
	 if( key === 'F6' ){        
      $("#credit").focus();
    }
	 if( key === 'F7' ){        
      $("#voucher").focus();
    }
	 if( key === 'F8' ){        
      $("#cheque").focus();
    }
	 if( key === 'F9' ){        
      $("#points").focus();
    }
	if( key === 'F10' ){        
      	  	  document.getElementById("phone").value = "";
$("#phone").focus();

	  	  document.getElementById("phone").value = "2547";

    }
		 if( key === 'right' ){        
      $("#btn_dontprint").focus();
    }
		 if( key === 'left' ){        
      $("#btn_savesales").focus();
    }
	
	if( key === 'alt' ){        
      $("#cardnumber").focus();
    }
	
	
	

	 if( key === 'enter' ){        
return true;
    }
	
})


  
util.key = { 
  9: "tab",
  //13: "enter",
  16: "shift",
  18: "alt",
  27: "esc",
  33: "rePag",
  34: "avPag",
  35: "end",
  36: "home",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  112: "F1",
  113: "F2",
  114: "F3",
  115: "F4",
  116: "F5",
  117: "F6",
  118: "F7",
  119: "F8",
  120: "F9",
  121: "F10",
  122: "F11",
  123: "F12"
}
		
		
		
		
		
		
		
		
    </script> 
  <script type="text/javascript" language="Javascript">
		var sum=0;


	price = document.sales.total.value;
	document.sales.change.value = price;
    function OnChange(value){
				var mpesa = document.sales.mpesa.value;
				var credit = document.sales.credit.value;
				var voucher = document.sales.voucher.value;
				var cheque = document.sales.cheque.value;
				var points = document.sales.points.value;
				var card = document.sales.card.value;
								var maindiscount = document.sales.maindiscount.value;

								var creditnote = document.sales.creditnote.value;

				//var total=mpesa+credit+voucher+cheque+points+card;

		payable = document.sales.total.value - mpesa-credit-voucher-cheque-points-card-creditnote-maindiscount;
		var cash = document.sales.cash.value;
        sum = cash - payable;
		
		document.sales.change.value = sum;
    }
	
	



	
		
			
		    
		
	
	
	
	
	
	
</script>

  <script type="text/javascript">
 
          $(function () {
        $("#type").change(function () {
			var totalmoney = document.sales.total.value;
            if ($(this).val() == "Mpesa") {
            
	
			//var totalmoney = document.sales.total.value;

              		  document.getElementById("mpesa").value =totalmoney;
					  
              		  document.getElementById("cash").value =0;
					    $("#phone").focus();
                //  $("#mpesa").focus();

            }else     if ($(this).val() == "Cash") {
			
		
               
	
			//var totalmoney = document.sales.total.value;

              		  document.getElementById("cash").value =totalmoney;
					  
              		  document.getElementById("mpesa").value =0;
                  $("#cash").focus();


            
			
            }
        });
    });
		
 </script>
 
 
  <script type="text/javascript">
 
		              $(function () {
        $("#type").change(function () {
						var myfinaltotal = document.sales.total.value;

            if ($(this).val() == "Cash") {
             $("#due").hide();
		   $("#accountno").hide();
              						$("#idno").hide();

$("#name").hide();

								$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
            } else if ($(this).val() == "Mpesa") {
              $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
              $("#name").hide();

								$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
$("#mpesa").focus().value = "";
  	// var myfinaltotal = document.getElementById('total').value;

            document.getElementById("mpesa").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;



            }else if ($(this).val() == "Bank") {
             $("#accountno").show();
				$("#name").hide();
										$("#idno").hide();

               $("#due").hide();
			   $("#cheque").focus().value = "";

			     	 //var myfinaltotal = document.getElementById('total').value;

                 document.getElementById("cheque").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("mpesa").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;


            }else if ($(this).val() == "Voucher") {
            $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
			   $("#name").hide();
						$("#idno").hide();

								$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
                     $("#voucher").focus().value = "";
  	// var myfinaltotal = document.getElementById('total').value;

            document.getElementById("voucher").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

            }else if ($(this).val() == "Creditnote") {
             $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
			   $("#name").hide();
						$("#idno").hide();

								$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
               $("#creditnotee").focus().value = "";
  	/// var myfinaltotal = document.getElementById('total').value;

            document.getElementById("creditnotee").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("voucher").value = 0;

            }else if ($(this).val() == "Points") {
           $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
						$("#idno").hide();

								$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
              
         $("#points").focus().value = "";
  	// var myfinaltotal = document.getElementById('total').value;

            document.getElementById("points").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("creditnotee").value = 0;
			document.getElementById("voucher").value = 0;
            }else if ($(this).val() == "Card") {
           $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
			   	$("#myphone").hide();
										$("#idno").hide();

							  $("#station").hide();
								 $("#destination").hide();
								 	$("#ourcompany").hide();
              $("#card").focus().value = "";
  	 //var myfinaltotal = document.getElementById('total').value;

            document.getElementById("card").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

            }else  if ($(this).val() == "Delivery") {
           						$("#idno").hide();

				             $("#accountno").show();
							  $("#name").show();
								$("#myphone").show();
							  $("#station").show();
								 $("#destination").show();
							  	$("#ourcompany").show();
								$("#credit").focus().value = "";
								
  	 //var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("credit").value = myfinaltotal;
						
						  document.getElementById("cash").value = 0;
			document.getElementById("mpesa").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

							 
				$("#due").show();
            }
			
			
			
			else  if ($(this).val() == "Credit") {
           						$("#idno").hide();

				             $("#accountno").hide();
							 	$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
				$("#ourcompany").hide();

				$("#credit").focus().value = "";
  	// var myfinaltotal = document.getElementById('total').value;

            document.getElementById("credit").value = myfinaltotal;
						
						  document.getElementById("cash").value = 0;
			document.getElementById("mpesa").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

							 
				$("#due").show();
            }else  if ($(this).val() == "Invoice") {
              $("#accountno").hide();
			 $("#name").show(); 
				           						$("#idno").hide();
     
				$("#due").show();
					$("#myphone").hide();
							  $("#station").hide();
								 $("#destination").hide();
								 				$("#ourcompany").hide();

					$("#credit").focus().value = "";
  	 //var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("credit").value = myfinaltotal;
						
						  document.getElementById("cash").value = 0;
			document.getElementById("mpesa").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;
            
			
			   }else  if ($(this).val() == "Savedata") {
           						$("#idno").show();

				             $("#accountno").show();
							  $("#name").show();
								$("#myphone").show();
							  $("#station").show();
								 $("#destination").show();
							  	$("#ourcompany").show();
								$("#cash").focus().value = "";
	

							 
				$("#due").show();
            }
			else {
					$("#myphone").show();
								
						$("#ourcompany").show();
						$("#idno").show();

               $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
            }
        });
    });
	   
              



 </script>
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> Update Payment methods</span>
									<a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/searchinvoice?code=<?php   if(isset($itemid)) {echo $itemid; } ?>"> Go back  </a>
									<a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/mysales"> Go to cashier   </a>
									<a  id="more" class="btn btn-success" href="<?php echo base_url();?>user/allinvoices"> Go to all invoices   </a>

									
									<a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/viewsales"> Go to new sales  </a>
									<a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/clearsales"> Go to Clear sales  </a>

            	</div>
            </div>
			<div class="panel-body">


			<?php
 
 
 
   $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
     $mpesaaction=$this->usermodel->populatuserpermissionsdataarray('sales','mpesa',$userid);
	      $chequeaction=$this->usermodel->populatuserpermissionsdataarray('sales','cheque',$userid);
 $voucheraction=$this->usermodel->populatuserpermissionsdataarray('sales','voucher',$userid);
	      $creditaction=$this->usermodel->populatuserpermissionsdataarray('sales','credit',$userid);
		   $pointsaction=$this->usermodel->populatuserpermissionsdataarray('sales','points',$userid);
	      $cardaction=$this->usermodel->populatuserpermissionsdataarray('sales','card',$userid);
	      $orderaction=$this->usermodel->populatuserpermissionsdataarray('sales','order',$userid);
		  	   $updatesalesaction=$this->usermodel->populatuserpermissionsdataarray('sales','backdatesales',$userid);
$view="user/mergebill";
		  $productdiscountaction=$this->usermodel->populatuserpermissionsdataarray('sales','productdiscount',$userid);
		  	      $creditnoteeaction=$this->usermodel->populatuserpermissionsdataarray('sales','creditnote',$userid);
						           		$configuration = $this->usermodel->populateallarray('smsconfig','id',$companyid);
$multicurrency=$configuration[0]["currency"];
					$symbol=$configuration[0]["currencysymbol"]; 

				echo $this->session->flashdata('msg'); 
			?>
			
			
			
			
			
	
	<form name ="mpesa" id="sales"action="getpaymentsdkpush" method="post">

<input type="hidden" name="invoice" value="<?php echo $itemid; ?>"  id="itemid" class="form-control" required placeholder="Enter itemid">
	
													<?php
  $allbalance=$allsalesdetails[0]['total'];
 if( $mpesaaction==true){
	 

	 ?>
<input type="text" name="phone" id="sdkphone" placeholder="Enter Phone No to verify" style="margin-bottom:0: "value="<?php if(isset($_GET['sdkphone'])) {echo $_GET['sdkphone']; }else{ echo "254";}?>"" class="form-control" />
								SDK Push

			
			
	 	<?php	
		
		}
  ?>
 <input type="hidden" id="myview"name="myview" class="view" placeholder="view" value="user/changepayment?invoice=<?php echo $itemid; ?>">


								<input type="hidden" name="total"  id="myfinaltotal"   placeholder="Cash" value="<?php if(isset($allbalance)) {echo ($allbalance); }?>" />




	</form>
			
			
			
			
			
			
				
										<form name = "sales" id="sales" action="updatepayments" method="post" class="form-horizontal form-groups-bordered validate">

<?php 
		
                // echo form_open('user/updatepayments' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
<input type="hidden" name="invoice" value="<?php echo $itemid; ?>"  id="itemid" class="form-control" required placeholder="Enter itemid">


		  		<input type="hidden"   id="houseno"   name="houseno" value="<?php echo set_value('houseno',$allsalesdetails[0]['houseno']); ?>" class="form-control"  placeholder="Enter house no">




  	<div class="form-group">
    <label for="inputdateposted" class="col-sm-2 control-label">	Date Sold <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
	<?php
 if( $updatesalesaction==true){
	 ?>
			  		<input type="text"  name="dateposted" style="width:30%;background:gray; padding:10px; font-size:20px;" id="dateposted"  value="<?php echo set_value('dateposted',$allsalesdetails[0]['dateposted']); ?>" class="form-control2" required placeholder="Enter cash e.g 500">
 
	<?php	 
 }else{
	 

  ?>
  
  		  		<input type="text"  name="dateposted" style="width:30%;background:gray; padding:10px; font-size:20px;" readonly id="dateposted"  value="<?php echo set_value('dateposted',$allsalesdetails[0]['dateposted']); ?>" class="form-control2" required placeholder="Enter cash e.g 500">

  
  	<?php	 

	 
 }
  ?>
	RECIPT NO	 <input type="TEXT" style="width:60%;background:gray; padding:10px; font-size:20px;" readonly name="myid" value="<?php echo set_value('id',$allsalesdetails[0]['id']); ?>" id="itemid" class="form-control2" required placeholder="Enter id">

				
		<span class="text-danger"> <?php echo form_error('dateposted'); ?>
		
		</span>
	</div>
  </div>











	<div class="form-group">
    <label for="inputcash" class="col-sm-2 control-label">	TOTAL MONEY EXPECTED <span style="color:red;">*</span></label>
    <div class="col-sm-10">
			
	<select name="type" id="type" class="form-control2" style="width:30%;background:orange; padding:10px; font-size:20px;">
<option value="" >-Select Mode-</option>
					<option selected="selected" required value="<?=  $allsalesdetails[0]['type'] ; ?>"><?=  $allsalesdetails[0]['type'] ; ?></option>

	<option value="Cash" selected="selected">Cash</option>

	









<?php
 if( $mpesaaction==true){
	 ?>
<option value="Mpesa">Mpesa</option>
		<?php	
		}
  ?>


<?php
 if( $cardaction==true){
	 ?>
<option value="Card">Card</option>
		<?php	
		}
  ?>
  
  
  
<?php
 if( $creditaction==true){
	 ?>
<option value="Invoice">Invoice / Credit</option>
		<?php	
		}
  ?>
  
  

  
<?php
 if( $chequeaction==true){
	 ?>
<option value="Bank">Bank</option>
		<?php	
		}
  ?>
  
  
  <?php
 if( $voucheraction==true){
	 ?>
<option value="Voucher">Voucher/Complimentary</option>
		<?php	
		}
  ?>
  
  
<?php
 if( $pointsaction==true){
	 ?>
<option value="Points">Bonga Points</option>
		<?php	
		}
  ?>
  
  
  
<?php
 if( $creditnoteeaction==true){
	 ?>
<option value="Creditnote">Credit Note</option>
		<?php	
		}
  ?>
  
<option value="Delivery">Cash On Delivery</option>


<option value="Savedata">Save Customer</option>

</select>
		  	TT AMOUNT	<input type="total" readonly  onkeyup='OnChange(this.value)' name="total" id="total"  value="<?php echo set_value('total',$allsalesdetails[0]['total']); ?>" class="form-control2" style="width:60%; background:orange; padding:10px;font-size:20px" required placeholder="Enter total e.g 500">
		 
				
		<span class="text-danger"> <?php echo form_error('total'); 
		echo  $allsalesdetails[0]['type'] ;
		
		
		?>
		
		</span>
		
		
				
	</div>
  </div>


 	<div class="form-group">
    <label for="inputcash" class="col-sm-2 control-label">	Payment status	<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  	<select class="form-control" style="width:60%;background:orange; padding:10px; font-size:13px;" name="paymentstatus" >

	

<option    value="<?php  echo  $allsalesdetails[0]['paymentstatus'];    ?>"><?php echo  $allsalesdetails[0]['paymentstatus'];   ?></option>

	
										<option value="">--Select status--</option>
			                         <option value="Cleared" selected="selected"  >Cleared</option>
									 																 <option value="No">No(Not cleared)</option>

									   <option value="Pending">Pending</option>

																	   <option value="Rejected">Rejected</option>																	   <option value="Rejected">Rejected</option>
																	   <option value="Shipped">Shipped</option>
																		<option value="Confirmed">Confirmed</option>
																		<option value="Delivered">Delivered</option>


							
</select>
	</div>
  </div>




  	<div class="form-group">
    <label for="inputcash" class="col-sm-2 control-label">	CASH (F3)<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="cash"  id="cash"  value="<?php echo set_value('cash',$allsalesdetails[0]['cash']); ?>" class="form-control" required placeholder="Enter cash e.g 500">
		 
				
		<span class="text-danger"> <?php echo form_error('cash'); ?>
		
		</span>
	</div>
  </div>

	<?php
 if( $mpesaaction==true){
	 ?>
<div class="form-group">
    <label for="inputmpesa" class="col-sm-2 control-label">	MPESA(F4)</label>
    <div class="col-sm-10">
		  		<input type="text"  onkeyup="OnChange(this.value)" name="mpesa"  id="mpesa"  value="<?php echo set_value('mpesa',$allsalesdetails[0]['mpesa']); ?>" class="form-control" required placeholder="Enter mpesa e.g 500">

			
		<span class="text-danger"> <?php echo form_error('mpesa'); ?>
		
		</span>
	</div>
  </div>
			 	<?php	
		}else{
?>
		  		<input type="hidden"  onkeyup="OnChange(this.value)" name="mpesa"  id="mpesa"  value="<?php echo set_value('mpesa',$allsalesdetails[0]['mpesa']); ?>" class="form-control" required placeholder="Enter mpesa e.g 500">

<?php

		}
  ?>
	


	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">Transaction Code(F10)<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"   id="phone"   name="cashier" value="<?php echo set_value('cashier',$allsalesdetails[0]['cashier']); ?>" class="form-control"  placeholder="Enter MPESA code e.g X3232">
		 
				
		<span class="text-danger"> <?php echo form_error('cashier'); ?>
		
		</span>
	</div>
  </div>
  






	
    <?php
 if( $creditaction==true){
	 ?>
  	<div class="form-group">
    <label for="inputcredit" class="col-sm-2 control-label">	CREDIT (F6)<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly onkeyup='OnChange(this.value)' name="credit"  id="credit"  value="<?php echo set_value('credit',$allsalesdetails[0]['credit']); ?>" class="form-control"  placeholder="Enter cash e.g  300">
		 
				
		<span class="text-danger"> <?php echo form_error('credit'); ?>
		
		</span>
	</div>
  </div>
  
  
  <div class="form-group">
    <label for="inputcreditnote" class="col-sm-2 control-label">	CREDIT-NOTE<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="creditnote"  id="creditnotee"  value="<?php echo set_value('creditnote',$allsalesdetails[0]['creditnote']); ?>" class="form-control"  placeholder="Enter creditnote e.g  300">
		 
				
		<span class="text-danger"> <?php echo form_error('creditnote'); ?>
		
		</span>
	</div>
  </div>
   	<?php	
		}else{  
		?>
		  		<input type="hidden"  onkeyup='OnChange(this.value)' name="creditnote"  id="creditnote"  value="<?php echo set_value('creditnote',$allsalesdetails[0]['creditnote']); ?>" class="form-control"  placeholder="Enter creditnote e.g  300">

		  		<input type="hidden"  onkeyup='OnChange(this.value)' name="credit"  id="credit"  value="<?php echo set_value('credit',$allsalesdetails[0]['credit']); ?>" class="form-control"  placeholder="Enter cash e.g  300">

<?php

		}
  ?>
			

					<?php
 if( $voucheraction==true){
	 ?>
 <div class="form-group">
    <label for="inputvoucher" class="col-sm-2 control-label">	COMPLIMENTARY <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="voucher"  id="voucher" value="<?php echo set_value('voucher',$allsalesdetails[0]['voucher']); ?>" class="form-control"  placeholder="Enter cash e.g  300">
		 
				
		<span class="text-danger"><?php echo form_error('voucher'); ?>
		
		</span>
	</div>
  </div>
  
  	 	<?php	
		}else{  
		?>
		  		<input type="hidden"  onkeyup='OnChange(this.value)' name="voucher"  id="voucher" value="<?php echo set_value('voucher',$allsalesdetails[0]['voucher']); ?>" class="form-control"  placeholder="Enter cash e.g  300">


<?php

		}
  ?>
				<?php
 if( $chequeaction==true){
	 ?>
    	<div class="form-group">
    <label for="inputcheque" class="col-sm-2 control-label">	CHEQUE <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="cheque"  id="cheque" value="<?php echo set_value('cheque',$allsalesdetails[0]['cheque']); ?>" class="form-control"  placeholder="Enter cash e.g  300">
		 
				
		<span class="text-danger"><?php echo form_error('cheque'); ?>
		
		</span>
	</div>
  </div>
  
   	 	<?php	
		}else{  
		?>
				  		<input type="hidden"  onkeyup='OnChange(this.value)' name="cheque"  id="cheque" value="<?php echo set_value('cheque',$allsalesdetails[0]['cheque']); ?>" class="form-control"  placeholder="Enter cash e.g  300">



<?php

		}
  ?>
  				<?php
 if( $pointsaction==true){
	 ?>
  	<div class="form-group">
    <label for="inputpoints" class="col-sm-2 control-label">L POINTS <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="points" id="points"  value="<?php echo set_value('points',$allsalesdetails[0]['points']); ?>" class="form-control"  placeholder="Enter cash e.g  300">
		 
				
		<span class="text-danger"><?php echo form_error('points'); ?>
		
		</span>
	</div>
  </div>
  	<?php	
		}else{  
		?>
				  		<input type="hidden"  onkeyup='OnChange(this.value)' name="points" id="points"  value="<?php echo set_value('points',$allsalesdetails[0]['points']); ?>" class="form-control"  placeholder="Enter cash e.g  300">




<?php

		}
  ?>
  							<?php
 if( $cardaction==true){
	 ?>

    	<div class="form-group">
    <label for="inputcard" class="col-sm-2 control-label">	CARD <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="card"   id="card" value="<?php echo set_value('card',$allsalesdetails[0]['card']); ?>" class="form-control"  placeholder="Enter cash e.g  300">
		 
				
		<span class="text-danger">E.g Visa card <?php echo form_error('card'); ?>
		
		</span>
	</div>
  </div>
  	 	<?php	
		}else{
?>		  		<input type="hidden"  onkeyup='OnChange(this.value)' name="card"   id="card" value="<?php echo set_value('card',$allsalesdetails[0]['card']); ?>" class="form-control"  placeholder="Enter cash e.g  300">


<?php

		}
  ?>
	
    							<?php
 if( $productdiscountaction==true){
	 ?>

    	<div class="form-group">
    <label for="inputdiscount" class="col-sm-2 control-label">	Discount </label>
    <div class="col-sm-10">
	
		  		<input type="text"  onkeyup='OnChange(this.value)' name="maindiscount"   id="maindiscount" value="<?php echo set_value('maindiscount',$allsalesdetails[0]['maindiscount']); ?>" class="form-control"  placeholder="Enter discount e.g  300">
		 
				
		<span class="text-danger"> <?php echo form_error('maindiscount'); ?>
		
		</span>
	</div>
  </div>
  	 	<?php	
		}else{
?>		  		<input type="hidden"  onkeyup='OnChange(this.value)' name="maindiscount"   id="maindiscount" value="<?php echo set_value('maindiscount',$allsalesdetails[0]['maindiscount']); ?>" class="form-control"  placeholder="Enter discount  e.g  300">


<?php

		}
  ?>
	
  
  	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Delivery Message<span style="color:red;">*</span></label>
    <div class="col-sm-10">
						<textarea name="description"  id="mydescription"value=""  class="form-control" style="margin-bottom:0: " placeholder="Enter Delivery/Chief Message"><?php echo set_value('description',$allsalesdetails[0]['description']); ?></textarea>

		 
				
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
    
  	<div class="form-group">
    <label for="inputmytable" class="col-sm-2 control-label">REF NO </label>
    <div class="col-sm-10">
	
		  		<input type="text"    name="mytable" value="<?php echo set_value('mytable',$allsalesdetails[0]['mytable']); ?>"  id="mytable"class="form-control"  placeholder="Enter Reference No">
		 
				
		<span class="text-danger"> <?php echo form_error('mytable'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputchange" class="col-sm-2 control-label">	BALANCE/CHANGE </label>
    <div class="col-sm-10">
	
		  		<input type="text"    name="change" value="<?php echo set_value('balance',$allsalesdetails[0]['balance']); ?>"  id="change"class="form-control" required placeholder="balance">
		 
				
		<span class="text-danger"> <?php echo form_error('change'); ?>
		
		</span>
	</div>
  </div>
  
  
  

  
  
  
  <div class="form-group">
    <label for="inputnewproduct" class="col-sm-2 control-label">Customers</label>
    <div class="col-sm-10">
	

		
		
		<select class="chzn-select" name="customer" style="width:30%" >
	
	<option value=""   >---Select customer </option>

	
	<?php 
	$supplier=$allsalesdetails[0]['customer'];
			 $child = $this->usermodel->populateall('people','id',$supplier);

					 


							


if(is_array($child)) {

   foreach($child as $childrow){
	
   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $childrow->id;   ?>"><?=  $childrow->company. " - ".$childrow->firstname; ?></option>



	<?php

}} else {
	

	
}

//$main = $this->usermodel->populateall('people','category','customer','companyid',$companyid);
			 $main = $this->usermodel->populateall('people','companyid',$companyid);

if(is_array($main)) {

   foreach($main as $mainrow){
											// $myproducts = $this->usermodel->populateallarray('productlist','code', $childrow->code);

   //echo $courserow->coursename;
    ?>
					<option  value="<?=  $mainrow->id;   ?>"><?=  $mainrow->company. " - ".$mainrow->firstname; ?></option>



	<?php

}} else {
	

	
}





	
?>
</select>
		
		
		
		
	</div>
  </div>
  
  <?php
   if( $multicurrency=="yes"){
	$countbranch=$this->usermodel->countbranches($companyid);
 if( $countbranch >1){
 $mybranches= $this->usermodel->populateallarray('branch','id',$branchid);
if(isset($mybranches[0]['currency']) !=""){
	$symbol=$mybranches[0]['currency'];

}else{
$symbol=$configuration[0]["currencysymbol"]; 
	
}
			 
 }else{
$symbol=$configuration[0]["currencysymbol"]; 
	



 }	 
			 
					 
				
  ?>
    <div class="form-group">
    <label for="inputothercurrencyamount" class="col-sm-2 control-label">	Other Currency </label>
    <div class="col-sm-10">
	
		  		<input type="text"    name="othercurrencyamount" value="<?php echo set_value('othercurrencyamount',$allsalesdetails[0]['othercurrencyamount']); ?>"  id="change"class="form-control1" required placeholder="other currency amount">
		 
				<input type="text"    name="othercurrency" value="<?php echo set_value('othercurrency',$allsalesdetails[0]['othercurrency']); ?>"  id="change"class="form-control1" required placeholder="other currency ">

		<span class="text-danger"> <?php echo form_error('othercurrencyamount'); ?>
		
		</span>
	</div>
  </div>
  
    
  <?php
  }
  
  ?>
  
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"   value="user/changepayment?invoice=<?php echo $itemid; ?>" name="btn_updatepaymetmode" class="btn btn-primary"> Update payment   </button>
	        
				         <button type="submit"   value="<?php echo base_url();?>user/printpending?invoice=<?php   if(isset($itemid)) {echo $itemid; } ?>&view=<?php   {echo  $view;}  ?>&receipt=receipts" name="btn_updatepaymetmode" class="btn btn-primary"> Update and Receipt   </button>

	         <button type="submit"  value="user/clearsales" name="btn_updatepaymetmode" class="btn btn-primary"> Update and go back to Clear sales   </button>




			<button type="submit"  value="user/viewsales" name="btn_updatepaymetmode" class="btn btn-primary"> Update and go back to new  sales   </button>
	         <button type="submit"  value="user/mysales" name="btn_updatepaymetmode" class="btn btn-primary"> Update and go back to cashier  sales   </button>
			<a  id="more" class="btn btn-default" href="<?php echo base_url();?>user/printbill?invoice=<?php   if(isset($itemid)) {echo $itemid; } ?>&view=<?php   {echo  $view;}  ?>">  Print Bill   </a>
<a  id="more" class="btn btn-default" href="<?php echo base_url();?>user/printpending?invoice=<?php   if(isset($itemid)) {echo $itemid; } ?>&view=<?php   {echo  $view;}  ?>&receipt=both">  Receipt & Bill   </a>
<a  id="more" class="btn btn-default" href="<?php echo base_url();?>user/printpending?invoice=<?php   if(isset($itemid)) {echo $itemid; } ?>&view=<?php   {echo  $view;}  ?>&receipt=receipt">  Print Receipt   </a>

    </div>
  </div>
  					<?php echo form_close();?>
  
  
			
			
			<div class="modal-footer">

    

				</div>
			
			
			
			
			
			
			
			
			
			
			
			
			
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>


















