<div class="row">
		
	       
<section class="content">  
	        <div class="box box-success">
            <div class="box-body">
              <div class="table-responsive">
             	<div class="box-body">
             	    <div class="box-body">
             	    <div class="form-group">
                    <h1>Extrato de Conta Corrente</h1>
                </div><br>
<form method="post">
	<a class="btn btn-primary btn-flat" onclick="window.print();return false"><i class="fa fa-print"></i>&nbsp;Imprimir</a>
	<hr>
	<style>
	    @media print
{    
    .no-print, .no-print *
    {
        display: none !important;
    }
}
	</style>
			  <?php 
			    $id = $_GET['id'];
			    $mt = mysqli_query($link, "SELECT * FROM borrowers WHERE id = '$id' LIMIT 0,1") or die (mysqli_error($link));
			    while($dad = mysqli_fetch_array($mt)){
			        $mutuario = $dad['fname']." ".$dad['lname'];
			        $conta = $dad['account'];
			        $cell = $dad['phone'];
			  ?>
			  <div class="form-group">
                    <label for="" class="col-sm-2 control-label" style="color:#009900"> Mutuario</label>
                        <div class="col-sm-10">
                          <input  type="text" class="form-control" value="<?php echo $mutuario; ?>" readonly>
                        </div>
                </div><br>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label" style="color:#009900"> Numero de conta</label>
                        <div class="col-sm-10">
                          <input  type="text" class="form-control" value="<?php echo $conta; ?>" readonly>
                        </div>
                </div><br>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label" style="color:#009900"> Contacto</label>
                        <div class="col-sm-10">
                          <input  type="text" class="form-control" value="<?php echo $cell; ?>" readonly>
                        </div>
                </div><br>
			  <?php
			    }
			  ?>
			 <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Data</th>
                  <th>Descricao</th>
                  <th>Referencia</th>
                  <th>Debito</th>
                  <th>Credito</th>
                  <th>Saldo</th>
                 </tr>
                </thead>
                <tbody>
<?php
$id = $_GET['id'];
$data_inicial = $_GET['data_inicial'];
$data_final = $_GET['data_final'];


//var_dump($id." ".$data_inicial." ".$data_final);
        $select2 = mysqli_query($link, "SELECT * FROM transacoes WHERE mutuario = '$id' AND data BETWEEN '$data_inicial' AND '$data_final'") or die (mysqli_error($link));
        while($dados2 = mysqli_fetch_array($select2)){
            $data = $dados2['data'];
            $descricao = $dados2['descricao'];
            $referencia = $dados2['referencia'];
            $debito = $dados2['debito'];
            $valor_pagar = $dados2['credito'];
            $balance = $dados2['saldo'];
            echo "<tr>";
            echo "<td>$data</td>";
            echo "<td>$descricao</td>";
            echo "<td>$referencia</td>";
            echo "<td>$debito</td>";
            echo "<td>$valor_pagar</td>";
            echo "<td>$balance</td>";
            echo "</tr>";
        }
?>
<?php
        $select01 = mysqli_query($link, "SELECT sum(debito) as emp,sum(credito) as pay, sum(saldo) as saldo FROM transacoes WHERE mutuario = '$id' AND data BETWEEN '$data_inicial' AND '$data_final'") or die (mysqli_error($link));
        while($dados01 = mysqli_fetch_array($select01)){
            $emp = $dados01['emp'];
            $pay = $dados01['pay'];
            $saldo = $dados01['saldo'];
            echo "<tr>";
            echo "<td>Totais</td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td><b>$emp</b></td>";
            echo "<td><b>$pay</b></td>";
            echo "<td></td>";
            echo "</tr>";
        }
?>
    </tbody>
</table>  
</form>
</div>
</div>	
</div>
</div>	
</div>