
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/allinvoices";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/allinvoices";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>

      
	  
   <style type="text/css">
  
  

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; 


}

#sale{  	


    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
		    	#myprint { display: block; font-size:16; width:100%; }

    }
    </style>

 

         <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" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> View bank Deposits </span>
	  <a data-toggle='modal' data-target='#addModal' class="btn btn-default">Add Bank Deposits </a>
	  	  	  	  				 <a href="<?php echo base_url();?>user/viewbanktransfer" class="btn btn-default"> Bank transfer </a>

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

				 	  	  	  	  				 <a href="<?php echo base_url();?>user/allaccounting" class="btn btn-default"> Charts of Accounts </a>
			 <a data-toggle='modal' data-target='#cashflowModal' class="btn btn-default"> 	Search  Bank Deposits</a>
 <div class="pull-right"  id="non-printable">
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('sortable_table')" value="print receipt!" />
</form></div>
            	</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'); 
				function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						
						return $number;
					}
					
					$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'];	
	   $balance=$this->usermodel->populatuserpermissionsdataarray('sales','mpesabalance',$userid);

				
					
					
					
					  $balance=$this->usermodel->populatuserpermissionsdataarray('sales','mpesabalance',$userid);

				$smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
	  $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
					
					
					
								?>	
					<div class="row">
						<div class="col-md-12">
												<div class="panel-body">
		<div class="col-md-12" id="non-printable">
        <?php 
		 echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchbanks", $attr);?>
            <div class="form-group">
			
                <div class="col-md-5">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for bank deposits.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                <div class="col-md-4">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/viewbanks"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>
        </div>
		
							<div class="panel-body">
	
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
		   							<th id="non-printable">View  </th>

  							<th>Bank Name  </th>
		<th> Recorded by </th>
		<th>Responsible Person  </th>
			<th> Description </th>
			<th> Amount </th>
			<th> Date Deposited</th>
				
		<th id="non-printable">More</th>
		


                 </tr>
             </thead>
<?php
 if(!is_array($viewbanks)) {
				    echo '<div class="alert alert-danger text-center">There was no record found in the system</div>';

	
    }else {
?>
    
             <?php 
    $ttpay=0;

  	foreach ($viewbanks as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>



<td id="non-printable"><?php 
 $invoice_number=$c->invoice;
	
	  ?>
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/viewnewbanking?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">More  </a>

  </td>






 <td>
												 
	<?php 
					// $branch="";
					 $branch=$c->bankname;

					 $branch= $this->usermodel->populateall('glaccounts','number',$branch);



if(is_array($branch)) {

   foreach($branch as $branchrow){

   echo $branchrow->accountname;
 
 
}} else {
   // echo 'General.';
	echo $c->bankname ;
}
	
?>
												 
	 </td>											 
												 
			
              

	 <td><?php  $userids= $c->userid ;

$myuser=$this->usermodel->geteuser($userids);
   echo $myname=$myuser[0]['firstname'];

  ?></td>
    <td><?php echo $c->incharge ; ?></td>
   <td><?php echo $c->description ; ?></td>
	  <td><?php echo $c->amount ;
  $ttpay=  $ttpay+$c->amount ;

	  ?></td>
	  <td><?php echo $c->paiddate ; ?></td>
   	 	 <td id="non-printable"> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										<!--
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									-->
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
     	
                  
             </tr>

	<?php endforeach;} ?>

          
            		<tr border="1" background="green">
					   	 	 <td id="non-printable"> </TD>

									<td colspan="4"><center><b>Total   Amount :

			<td>  <b><?php if(isset($ttpay)) {echo formatMoney($ttpay, true);  }?><b></td>

				<td></td>

	
	<td id="non-printable"  colspan=""></td>
</tr>

        </table>
		<div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Bank deposits (s) in the system. " ;?>    </span>

        
        </div>
	</div>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	<div id="cashflowModal" 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 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/viewbaks' , 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"  >---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->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');


	
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 bank deposits</button>

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

    

				</div>

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


		<div id="deleteModal" 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">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

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

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="banks">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewbanks">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>		
	<div id="addModal" 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">Add new Bank Deposits </h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addbanks' , 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/viewnewbanking?randomitemidentifier=" class="form-control" required placeholder="Enter view">
	     								<input type="hidden" name="myview" value="user/viewbanks" class="form-control" required placeholder="Enter view">

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

	      <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>
	
	<?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');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

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

				<?php

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

					<?php

				}
				
    ?>



	<?php

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

	</div>
  </div>
  
	 
	 
	 

	<div class="form-group">
    <label for="inputincharge" class="col-sm-2 control-label">Person incharge </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="incharge" value="<?php echo set_value('incharge'); ?>" class="form-control" required placeholder="Enter Person incharge ">
		 
				
		<span class="text-danger"> <?php echo form_error('incharge'); ?>
		
		</span>
	</div>
  </div>
<div class="form-group" style="display:none">
    <label for="inputamount" class="col-sm-2 control-label">Amount :  </label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly  name="amount" value="0.00" class="form-control" required placeholder="Enter  amount used">
		 										<input type="hidden" name="invoice" value="<?php echo set_value('invoiceno',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoiceno">

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

  
  
  
    <label for="inputpaiddate" class="col-sm-2 control-label">Banking Deposit 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:s:i")); ?>" 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"></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_bank" class="btn btn-primary"> NEXT >>   </button>

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

    

				</div>

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

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

 
</div>


















