
 
 <div class="row">
  
   	 
<script>

 $(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" 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="8"><center>
			 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; }
			   $TIMEOFREPORT=date("d/m/Y H:i:s a");
			 ?>
</BR>
			 <B>CASH FLOW AND BALANCE REPORT</B></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");?>
									<br>Name----------------------Date--------------------Signature----------------</span>

			</th>
	
			 </center>
			 </tr>
         <tr>
     <th id="non-printable">Ref No</th>
     <th>Account Name</th>
	     <th>Description</th>
		      <th>Code/Chq. No.</th>
	    <th>Date</th>
	     <th>In flow</th>
<th>Out flow</th>	

       <th>Balance</th>	
	          <th>Branch</th>	

       <th id="non-printable">More</th>	

	   </tr>
             </thead><tbody>
<?php
	
 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=$previousbalance;
	echo formatMoney($prebalance , true);
	?>
	</b>
   </td>
  </tr>
             <?php 
			  $balance=0;
			  			  $mybalance=0;
						  

  $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 id="non-printable">
		 
		 
		 

		 
		 	<a  id="more"  target="_blank"  href="<?php echo base_url();?>user/searchJE?searchterm=<?php   {echo  $c->code;}  ?> ">
			 <?php  echo $c->code; ?>
                </a>
		 
		 
		 
		 
		 
		 </td>         

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


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

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

$branchs = $this->usermodel->populateallarray('branch','id',$c->branch );

			   
			   echo $branchs[0]['name']; 


			  ?></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 -->
                                      
									
                                     	  <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>
																<?php
										if($usertype=="admin"){
											
											?>
                                        <!--
										   <li class="divider"></li>


											  <li> 
										 <a class="btn btn-danger managebtn" 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
										}
										?>
                                      <li class="divider"></li>
                                        <li> 
				<a  id="more" class=" btn-success" target="_blank"  href="<?php echo base_url();?>user/searchJE?searchterm=<?php   {echo   $c->code;}  ?> ">
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
															View	GL Transactions
                                                </a>
																		
										</li>		

                                        
                                    </ul>
										
                                </div>
</td>
 
             </tr>

	<?php endforeach;} ?>
 <tr>
    <th colspan="4"><CENTER>TOTAL BALANCE</CENTER></th>
	<td id="non-printable"></td>    
	   <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($balance)) {echo formatMoney($balance, 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>


















