
 
 <div class="row">
  
   	 
<script>



    function selectAllCheckBoxes(obj){
        $('input:checkbox:not(:disabled).checkBoxInLoop').prop('checked', jQuery(obj).prop('checked'));
    }

    function unselectCheckBoxUnik(){

        /*first you verify if the quantity of checkboxes equals number of checkboxes*/
        a = $('input:checkbox:not(:disabled).checkBoxInLoop:checked').size();
        b = $('input:checkbox:not(:disabled).checkBoxInLoop').size();

        /*if equals, mark a checkBoxUnik*/
        ((a == b)? $('#checkBoxUnik').prop("checked", true) : $('#checkBoxUnik').prop("checked", false));
    }

		
 $(document).on("click", "#managebtndelete", function()
        {
          var itemid1 = $(this).data('id');
		  $("#itemid1").val(itemid1); 
 
 
		   
        });
	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/cashflow";
		alert(" printing...........");
    }else {

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

		    // 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>

   	<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>

 <a href="<?php echo base_url();?>user/startsales"  id="non-printable" class="btn btn-info">  Go back</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('example')" value="print cashflow" />
</form></div>
 

 

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

			
	<div class="widget-content nopadding table_holder table-responsive">				
				<?PHP
				echo $this->session->flashdata('msg'); 
	 $session_data = $this->session->userdata('logged_in');

     $dateposted = date('Y-m-d H:i:a');
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
   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;
					}

								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
  <table cellpadding="0" cellspacing="0" border="1" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >
	<?php
			
			 	$myinvoice = $userid.time();

                 echo form_open('user/updatereconciliation' , 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;?>	
             <thead>
			     <tr>
    <th colspan="7"><CENTER>
	
	 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; }
	 
	 ?>

			 <B>BANK RECONCILITION REPORT <BR> 
			 FROM  <?php  if(isset($startdate)) {echo   date("d/m/Y H:i:s", strtotime($startdate)); }?>  TO  <?php  if(isset($enddate)) {echo     date("d/m/Y H:i:s", strtotime($enddate));; }?>   </B><br>
			 Report was run on <?php echo  date("d/m/Y H:i:s");?>
	
	
	
	
	
	
	</CENTER></th>
  
                 </tr>
         <tr>

     <th>Account Name</th>
	     <th>Description</th>
	    <th>Date</th>
	     <th>In flow</th>
<th>Out flow</th>	

       <th>Balance</th>	
	   	 <th> <input type="checkbox" onclick="selectAllCheckBoxes(this)" id="checkBoxUnik"/> (Verified)<br>All
</th>
       <th id="non-printable" colspan="2">
	   	 <input type="hidden" name="type" value="<?php   if(isset($type)) {echo $type; } ?> "  class="form-control" required placeholder="Enter type">

	 <input type="hidden" name="bankname" value="<?php   if(isset($bankname)) {echo $bankname; } ?> "  class="form-control" required placeholder="Enter bankname">
	 <input type="hidden" name="startdate" value="<?php   if(isset($startdate)) {echo $startdate; } ?> "  class="form-control" required placeholder="Enter startdate">

	 <input type="hidden" name="enddate" value="<?php   if(isset($enddate)) {echo $enddate; } ?> "  class="form-control" required placeholder="Enter enddate">
	 <input type="hidden" name="balance" value="<?php   if(isset($balance)) {echo $balance; } ?> "  class="form-control" required placeholder="Enter balance">
	 <input type="hidden" name="lastmonthbalance" value="<?php   if(isset($lastmonthbalance)) {echo $lastmonthbalance; } ?> "  class="form-control" required placeholder="Enter balance">

	   			         <button type="submit"  value="all" name="updatebakreconciliation" class="btn btn-success"> Update Selected  </button>
<br>
	   
	   More</th>	

	   </tr>
             </thead><tbody>
<?php
	  $currentbalance=0;
			  			  $mybalance=0;
 if(!is_array($cashflow)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='13'>";
    
       echo '<div class="alert alert-warning text-center">There is no record found. Try again.</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>

   <tr  style="margin-bottom:0px;margin-top:0px;">;
      <td colspan='3'>
    
   </td>
    <td colspan='2'>
    <b> Balance  Carried forward:</b>
   </td>
    <td>
	<b>
    <?php
	$prebalance=0;
	$prebalance=0;
	echo formatMoney($prebalance , true);
	?>
	</b>
   </td>
  </tr>
             <?php 
			
						  

  $totaldebt=0;
    $totalcredit=0;
  	foreach ($cashflow as $c): 

		

		  
             ?>



             <tr>
                
            <?php 
$id=$c->id;
  $totaldebt=$totaldebt+$c->debit;
    $totalcredit= $totalcredit+$c->credit;
			  			  $mybalance=$mybalance+$c->debit-$c->credit;;

?>

              

  <td><?php 
  
  $accountdata=$this->usermodel->populateallarray('glaccounts','number', $c->account);

echo$accountname=$accountdata[0]['accountname'];
		
  
  ?></td>
   <td><?php echo $c->mydescription ; ?></td>
      <td><?php echo $c->crateddate ; ?></td>
    <td><?php echo formatMoney($c->debit , true); ?></td>
	 <td><?php echo formatMoney($c->credit , true); ?></td>

	  <td><?php 

$currentbalance= ($prebalance+($totaldebt-$totalcredit));
	echo formatMoney($currentbalance , true);
	  ?></td>
	 
	 
	  <td>

			<input name="selector[]" type="checkbox" onclick="unselectCheckBoxUnik()" class="checkBoxInLoop" value="<?php echo $c->id ; ?>">
			</td>
   <td><?php echo $c->confirm ; ?></td>

				</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>
									
									
				
								
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
											<?php
										if($usertype=="admin"){
											
											?>
                                        
                                     	  <li> 

	  	  	  	 <a  id="more" class="btn btn-info" target="_blank" href="<?php echo base_url();?>user/editjournalentry?randomitemidentifier=<?php   {echo  $id;}  ?>">

                                                <i class="glyphicon glyphicon-pencil"></i>
																Reconcile/Update
                                                </a>
                                                        </li>
										   <li class="divider"></li>


											  <li> 
										 <a class="btn btn-danger managebtn" target="_blank" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModel<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Cancel
                                                </a>
                                                        </li>
														
									
										<?php
										}
										?>
                                     
                                        
                                    </ul>
										
                                </div>
</td>
 
             </tr>
		

	<?php endforeach;
	
	?>
	   
	
	<?PHP
$CURRENTBALANCE=($balance-$currentbalance)-$lastmonthbalance;

echo	"<b>Difference:</b>";
	if(isset($CURRENTBALANCE)) {echo formatMoney($CURRENTBALANCE, true); }
	?>
	
		 
	
	<?php
	} ?>
		<?php echo form_close();?>
 <tr>
    <th colspan="3"><CENTER>TOTAL BALANCE</CENTER></th>
	   <th> <h3><?php if(isset($totaldebt)) {echo formatMoney($totaldebt, true); }?></h3></th>
	   <th> <h3><?php if(isset($totalcredit)) {echo formatMoney($totalcredit, true); }?></h3></th>
	   	   <th> <h3><?php if(isset($currentbalance)) {echo formatMoney($currentbalance, true); }?></h3></th>
<th></th>
  
 </tr>
         <tr>
    <th colspan="3"><CENTER> BALANCE DIFFERENCE</CENTER></th>
	
	<?PHP
$CURRENTBALANCE=($balance-$currentbalance)-$lastmonthbalance;
	
	?>
	
		   <th colspan="2"> Last month closing balance      :<?php if(isset($lastmonthbalance)) {echo formatMoney($lastmonthbalance, true); }?></br>
		   
		  Current Month Endind balance      : <?php if(isset($balance)) {echo formatMoney($balance, true); }?></br>
		   
		   
		   </h3></th>

	 		   <th colspan="4"> Difference:<h3><?php if(isset($CURRENTBALANCE)) {echo formatMoney($CURRENTBALANCE, true); }?></h3></th>
	  
<th></th>
  
 </tr> 

       <tbody> 
	         
	   
	   
	   </table>
	
       
   
			
	</div>
						
									
							</div>
						</div>
				

			
			</div>
		</div>
  
  </div>
			
			
			
					
<div id="deleteModel" 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="table" value="debitcredit">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/startsales">
 <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>


















