<?php $currency_symbol = $this->customlib->getSchoolCurrencyFormat(); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            <i class="fa fa-mortar-board"></i> Supplier Statement</h1>
								 <a href="<?php  echo base_url(); ?>expenses_history" class="col-md pull-right">Expense History</a>
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>	
								 <a href="<?php  echo base_url(); ?>expenses_report" class="col-md pull-right">Expense Statement</a>
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>	
								 <a href="<?php  echo base_url(); ?>supplier/supplier_statement" class="col-md pull-right">Statement</a>
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>											 
								 <a href="<?php  echo base_url(); ?>supplier/supplier_receipt" class="col-md pull-right">Receipts</a>
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>supplier/supplier_invoice" class="col-md pull-right">Invoice</a> 
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>supplier" class="col-md pull-right">Add Supplier</a>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header ptbnull">
                        <h3 class="box-title titlefix"><?php echo $title_list; ?></h3>
                        <div class="box-tools pull-right">
						 <a href="<?php echo base_url(); ?>supplier/supplier_statement" class="btn btn-primary btn-sm pull-right">
								Return Back</a>
                        </div><!-- /.box-tools -->
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <div class="table-responsive mailbox-messages">
                            <h4  class="box-title titlefix"><?php 	// foreach ($supplier_results->result() as $row){ echo "<b style='font-zise:10px;'>CURRENCY : ".$row->currency."</b>";}?></h4 >
							<table class="table table-striped table-bordered table-hover example">
                                <thead>
                                    <tr>
                                        <th>Date</th> <?php// echo $selected_details; ?>
                                        <th>Reference</th>
                                        <th>Description</th>
                                        <th>Currency</th>
                                        <th>Deposits</th>
                                        <th>Payments</th>
                                        <th>Balance</th>
                                       
                                    </tr>
                                </thead>
                                <tbody>
                                <?php  
													$balance=0;
													$buffer =$balance;		
										 foreach ($supplier_results->result() as $row)  
										 {   

													$balance=($balance + $row->debit)-( $row->credit);
													$buffer =$balance;
													if($balance<0)
													{
													 $balance=$balance - ($balance*2);

													?>

																		<tr>
																			<td class="mailbox-name"><?php echo $row->date;?></td>
																			<td class="mailbox-name"><?php echo $row->reference;?></td>
																			<td class="mailbox-name"><?php echo $row->description;?></td>
																			<td class="mailbox-name"><?php echo $row->currency;?></td>
																			<td class="mailbox-name"><?php if($row->debit == 0){echo "";} else{ echo $row->debit;}?></td>
																			<td class="mailbox-name"><?php if($row->credit == 0){echo "";} else{ echo $row->credit;}?></td>                                        
																			<td class="mailbox-name"><?php echo "(".$balance.")";?></td>                                        
																		</tr>					
													
													
												<?php
												$balance=$buffer;
												   }
												   else{
														?>
														

																		<tr>
																			<td class="mailbox-name"><?php echo $row->date;?></td>
																			<td class="mailbox-name"><?php echo $row->reference;?></td>
																			<td class="mailbox-name"><?php echo $row->description;?></td>
																			<td class="mailbox-name"><?php echo $row->currency;?></td>
																			<td class="mailbox-name"><?php if($row->debit == 0){echo "";} else{ echo $row->debit;}?></td>
																			<td class="mailbox-name"><?php if($row->credit == 0){echo "";} else{ echo $row->credit;}?></td>                                        
																			<td class="mailbox-name"><?php echo $balance;?></td>                                        
																		</tr>					
													
												  
													<?php
												   }												
											} ?>
                                </tbody>
                            </table><!-- /.table -->



                        </div><!-- /.mail-box-messages -->
                    </div><!-- /.box-body -->
                </div>
            </div><!--/.col (left) -->
            <!-- right column -->

        </div>
        <div class="row">
            <!-- left column -->

            <!-- right column -->
            <div class="col-md-12">

            </div><!--/.col (right) -->
        </div>   <!-- /.row -->
    </section><!-- /.content -->
</div><!-- /.content-wrapper -->

