
 
 <div class="row">
  
   	 
<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/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" 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
   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%;"  >

             <thead>
			     <tr>
    <th colspan="2"><CENTER>Account Balance</CENTER></th>
  
                 </tr>
         <tr>

    
             </thead><tbody>
<?php
	$names="";
 if(is_array($cashflow)) 

 {


	$prebalance=0;
	$prebalance=$previousbalance;

			  $balance=0;
			  			  $mybalance=0;
						  

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

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


	$names=$accountdata[0]['accountname'];
		  
           
  $totaldebt=$totaldebt+$c->debit;
    $totalcredit= $totalcredit+$c->credit;
			  			  $mybalance=$mybalance+$c->debit-$c->credit;
						  $balance= ($prebalance+($totaldebt-$totalcredit));


	}
 }
	
	 ?>
 <tr>
    <th><CENTER><h3>TOTAL BALANCE FOR  :<?php if(isset($names)) {echo $names ;}?></h3></CENTER></th>
	  
	   	   <th> <h3><?php if(isset($balance)) {echo formatMoney($balance, true); }?></h3></th>

  
                 </tr>
         
</table>
	   
       
   
			
	</div>
						
									
							</div>
						</div>
				

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

 
</div>


















