

         <script type="text/javascript">
		
		
		              $(function () {
        $("#currency").change(function () {
            if ($(this).val() != "") {
            
			var tempcurrencytype = $("#currency").val() ;

 const getcurrencyvalue = tempcurrencytype.split(":=");
let toamount = getcurrencyvalue[0];
let mytocurrency = getcurrencyvalue[1];
  	 var myfinaltotals = document.getElementById('myfinaltotal').value;

  let finalcurrency= 0;
finalcurrency=toamount*myfinaltotals;
  finalcurrency = finalcurrency.toFixed(2);
            document.getElementById("tocurrencyamount").value = finalcurrency;
		document.getElementById("tocurrency").value = mytocurrency;
			













            } else {
             alert("No currency selected or set. Try again");
			$("#mytable").hide();

            
			
            }
        });
    });
	
		    </script>  

		
 

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </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"> Bank Transfer </span>
				 	  	  	  				 <a href="<?php echo base_url();?>user/viewbanks" class="btn btn-info"> Bank Deposits </a>

	  	  	  	  				 <a href="<?php echo base_url();?>user/viewjournalentry" class="btn btn-info"> Journal Entry </a>

				 				 	  	  	  	  				 <a href="<?php echo base_url();?>user/allaccounting" class="btn btn-info"> Charts of Accounts </a>
																 			 <a data-toggle='modal' data-target='#cashtransferModal' class="btn btn-primary">Bank Transfer Report</a>


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

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP
      $mydate=date("Y-m-d H:i:s");

 echo $this->session->flashdata('deletemsg'); 

				echo $this->session->flashdata('msg'); 
				
				$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
	 
	  $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 		$viewallcounters=$this->usermodel->populatuserpermissionsdataarray('cashiersales','viewallcounters',$userid);
						           		$configuration = $this->usermodel->populateallarray('smsconfig','id',$companyid);

$symbol=$configuration[0]["currencysymbol"];
$multicurrency=$configuration[0]["currency"];
								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
	
	
	
		


	<div id="cashtransferModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title"> Bank transfer deposits</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
 //$mydate=date("Y-m-d");
 					 // $mydate=date("Y-m-d H:i:s");
 $fromdate=date("Y-m-d 00:00:00");


				$month= Date('Y-m');
			$fromdate=$month."-01";
				$date=$month."-30";
				
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewaccounttransfer' , 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;?>

	
	
	 <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
		<option value=""  >---Select Branch/Counter Name--</option>

	
<?php
									 if( $viewallaction==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?php
									 }
							
	?>
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		

		
	</div>
  </div>
  
  
	      <div class="form-group">
    <label for="inputbankname" class="col-sm-2 control-label">Bank name?</label>
    <div class="col-sm-10">
	<select class="form-control" name="bankname" required>
	
	<option value=""  >---Select bank name---</option>
		<option value="all"  selected>---Select all banks--</option>

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

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
										$banking= $this->usermodel->populatealldatanoarraythree('glaccounts','companyid',$companyid,'accounttype','1','accountstatus <>','inactive');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
			<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number .")"; ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('bankname'); ?>

	</div>
  </div>
	
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$fromdate." 00:00"); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputenddate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="enddate" value="<?php echo set_value('enddate',$date." 23:59"); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
  
  
   
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="cash" name="btn_viewcash" class="btn btn-primary"> View report</button>

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

    

				</div>

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

				


    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new Bank Transfer </h4>
      </div>
      <div class="modal-body">
      
	  	

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



		
                 echo form_open('user/addbanktransfer' , 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="view" value="user/viewbanks" class="form-control" required placeholder="Enter view">

    
     			<div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchname"  id="branchname" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallcounters==true){
										 ?>
									<?php
									
							
				 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
 }
?>
</select>
		

		
	</div>
  </div>
	



				<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter invoiceno">

	      <div class="form-group">
    <label for="inputfrombankname" class="col-sm-2 control-label">From bank?</label>
    <div class="col-sm-10">
	<select class="form-control" name="frombankname" required>
	
	<option value=""  >---Select bank name---</option>
							<option selected="selected" value="<?php echo "1000";  ?>">Acc No:1000 -Acc Name: Control Account </option>

	<?php 
	
	 
	 
	 
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	   $balance=$this->usermodel->populatuserpermissionsdataarray('sales','mpesabalance',$userid);

				
					 
										//$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');
										$banking= $this->usermodel->populatealldatanoarraythree('glaccounts','companyid',$companyid,'accounttype','1','accountstatus <>','inactive');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

 	if($balance==true){
		?>
							<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname."" ?></option>

				<?php

				}else{
					?>
										<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname.")"; ?></option>

					<?php

				}
				
    ?>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('frombankname'); ?>

	</div>
  </div>
  
	 
	 
	 

 <div class="form-group">
    <label for="inputtobankname" class="col-sm-2 control-label">To bank?</label>
    <div class="col-sm-10">
	<select class="form-control" name="tobankname" required>
	
	<option value=""  >---Select bank name---</option>

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

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
									///	$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');

										$banking= $this->usermodel->populatealldatanoarraythree('glaccounts','companyid',$companyid,'accounttype','1','accountstatus <>','inactive');

	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

 	if($balance==true){
		?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname.")"; ?></option>

				<?php

				}else{
					?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname.")"; ?></option>

					<?php

				}
				
    ?>




	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('tobankname'); ?>

	</div>
  </div>
  
	 
<div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">Amount To transfer :  </label>
    <div class="col-sm-10">
	
		  		<input type="text" id="myfinaltotal" name="amount" value="<?php echo set_value('amount'); ?>" class="form-control" required placeholder="Enter  amount to transfer">

				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</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="inputamount" class="col-sm-2 control-label">Currency To transfer :  </label>
    <div class="col-sm-10">
				 <select class="chzn-select" name="newcurrency" id="currency" style="width:100%" style="margin:0px; padding:0px;" >
	
	<option value="" selected="selected"  >---Select Other Currency---</option>
								   
									   
		<?php 

      $currency = $this->usermodel->populateall('currency','companyid', $companyid);


if(is_array($currency)) {

   foreach($currency as $currencyrow){

  


  
   ?>
	    <option  value="<?php echo $currencyrow->toamount.":=". $currencyrow->basecurrency; ?> "><?=$currencyrow->basecurrency." => ". $currencyrow->name."(".$currencyrow->toamount.")";?></option>

   
    <?php   


   
   
  

}} else {
    echo 'There is no any  currency for this house.... PLease add charges first.';
}

?>
</select>	
		<br><br>			
	<input type="text" readonly    name="tocurrencyamount" value=""  id="tocurrencyamount" style="background:#FFF0F5" class="form-control1" required placeholder="to currency">
	<input type="text" readonly   id="tocurrency"  name="tocurrency"  value="<?php if(isset($symbol)) {echo $symbol; }?>" style="background:#FFF0F5"class="form-control1" required placeholder="to currency">
	<input type="text" readonly     name="currency"  value="<?php if(isset($symbol)) {echo $symbol; }?>" style="background:#FFF0F9"class="form-control1" required placeholder="base currency">

	
			
	</div>
  </div>
  			
					
  			<?php	
			}else{
			?>
	<input type="hidden" readonly    name="tocurrencyamount" value="0"  id="tocurrencyamount" style="background:#FFF0F5" class="form-control1" required placeholder="to currency">
	<input type="hidden" readonly   id="tocurrency"  name="tocurrency"  value="<?php if(isset($symbol)) {echo $symbol; }?>" style="background:#FFF0F5"class="form-control1" required placeholder="to currency">
	<input type="hidden" readonly     name="currency"  value="<?php if(isset($symbol)) {echo $symbol; }?>" style="background:#FFF0F9"class="form-control1" required placeholder="base currency">

			
				
			<?php	
			}
			?>
	
  
  
  
  

  
    <label for="inputpaiddate" class="col-sm-2 control-label">Transfer Date</label>

				<div class="col-sm-5">
					<div class="form-group">

                     		  		<input type="date" name="paiddate" value="<?php echo set_value('fromdate',date("Y-m-d", strtotime($mydate))); ?>" class="form-control" required placeholder="Enter start date">

					</div>
				</div>
				<div class="col-sm-5">
					<div class="form-group">
					

							  		<input type="time"  name="paiddatefrotime" value="<?php echo set_value('frotime',date("H:i:s")); ?>" class="form-control" required placeholder="Enter start time">

					</div>
				</div>
			

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

				<textarea name="description" value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter remarks">Transfer</textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="bank" name="btn_banktransfer" class="btn btn-primary"> Add Bank  Transfer   </button>

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

    

				</div>

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

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

 
</div>


















