<div class="row">
    
		    <section class="content">  
	        <div class="box box-success">
            <div class="box-body">
              <div class="table-responsive">
             <div class="box-body">
<form method="post">
	 <button type="submit" class="btn btn-flat btn-danger" name="delete"><i class="fa fa-times"></i>&nbsp;Delete</button>
	<a href="newpoupanca.php?id=<?php echo $_SESSION['tid']; ?>&&mid=<?php echo base64_encode("408"); ?>"><button type="button" class="btn btn-flat btn-info"><i class="fa fa-dollar"></i>&nbsp;Nova Poupanca</button></a>
	
	<a href="printpoupanca.php" target="_blank" class="btn btn-primary btn-flat"><i class="fa fa-print"></i>&nbsp;Imprimir</a>
	<a href="excelpoupanca.php" target="_blank" class="btn btn-success btn-flat"><i class="fa fa-send"></i>&nbsp;Exportar Excel</a>
	
	<hr>
			<table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th><input type="checkbox" id="select_all"/></th>
                  <th>ID</th>
                  <th>Cliente</th>
                  <th>N<sup>o</sup> de Conta</th>
				  <th>Valor a Poupar(Mtn)</th>
                  <th>Usuario</th>
				  <th>Observacoes</th>
				
                  
                 </tr>
                </thead>
                <tbody>
<?php
$tid = $_SESSION['tid'];
$select = mysqli_query($link, "SELECT * FROM savings order by data DESC") or die (mysqli_error($link));
if(mysqli_num_rows($select)==0)
{
echo "<div class='alert alert-info'>Sem dados!.....Veja mais tarde!!</div>";
}
else{
while($row = mysqli_fetch_array($select))
{
$id = $row['id'];
$customer = $row['id_borrowers'];
$getin = mysqli_query($link, "SELECT fname, lname, account FROM borrowers WHERE id = '$customer'") or die (mysqli_error($link));
$have = mysqli_fetch_array($getin);
$nameit = $have['fname'].'&nbsp;'.$have['lname'];
//$accte = $have['account'];
$amount_to_save = $row['amount'];
$user = $row['user'];
$account = $row['account'];
$remarks = $row['remarks'];
$select1 = mysqli_query($link, "SELECT * FROM systemset") or die (mysqli_error($link));
while($row1 = mysqli_fetch_array($select1))
{
$currency = $row1['currency']; 
?>    
                <tr>
                <td><input id="optionsCheckbox" class="checkbox" name="selector[]" type="checkbox" value="<?php echo $id; ?>"></td>
                <td><?php echo $id; ?></td>
				<td><?php echo $nameit; ?></td>
				<td><?php echo $account; ?></td>
				<td><?php echo "".number_format($amount_to_save,2,".",","); ?></td>
				
				
				<td><?php echo $user; ?></td>
				
				<td><?php echo $remarks; ?></td>
				
				
			   
<?php } } } ?>
             </tbody>
                </table>  
		
<?php
						if(isset($_POST['delete'])){
						$idm = $_GET['id'];
							$id=$_POST['selector'];
							$N = count($id);
						if($id == ''){
						echo "<script>alert('Sem linhas Selecionadas!!!'); </script>";	
						echo "<script>window.location='listpoupancas.php?id=".$_SESSION['tid']."&&mid=".base64_encode("408")."'; </script>";
							}
							else{
							for($i=0; $i < $N; $i++)
							{
								$result = mysqli_query($link,"DELETE FROM savings WHERE id ='$id[$i]'");
								echo "<script>alert('Poupanca(s) apagadas(s) com sucesso!!!'); </script>";
								echo "<script>window.location='listpoupancas.php?id=".$_SESSION['tid']."&&mid=".base64_encode("408")."'; </script>";
							}
							}
							}
?>			
				
</form>
                </div>

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




<!--<script>
jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        window.location = $(this).data("href");
    });
});

</script>-->




<style>
    .clickable-row {
    cursor: pointer;
}
</style>