
<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">
	<!--<a href="dashboard.php?id=<?php echo $_SESSION['tid']; ?>"><button type="button" class="btn btn-flat btn-warning"><i class="fa fa-mail-reply-all"></i>&nbsp;Voltar</button> </a> -->
<?php
$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Tipo de Credito'") or die ("Error" . mysqli_error($link));
$get_check = mysqli_fetch_array($check);
$pdelete = $get_check['pdelete'];
$pcreate = $get_check['pcreate'];
$pupdate = $get_check['pupdate'];
?>
	<!--<?php echo ($pdelete == '1') ? '<button type="submit" class="btn btn-flat btn-danger" name="delete"><i class="fa fa-times"></i>&nbsp;Apagar Multiplos</button>' : ''; ?>-->
	
	<?php echo ($pcreate == '1') ? '<button data-target= "#b" data-toggle="modal" type="button" class="btn btn-flat btn-success"><i class="fa fa-plus"></i>&nbsp;Linha de Financiamento</button>' : ''; ?>
	<?php echo ($pcreate == '1') ? '<button data-target= "#c" data-toggle="modal" type="button" class="btn btn-flat btn-success"><i class="fa fa-plus"></i>&nbsp;Tipo de Credito</button>' : ''; ?>
	
</form>	
	<hr>
	
	<div class="form-group">
                
            <div class="col-sm-10">
				<h3>Linhas de Financiamento</h3>
		    </div>
		</div>
			  
			 <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <!--<th><input type="checkbox" id="select_all"/></th>-->
				  <th>Nº</th>
                  <th>Linha de Financiamento</th>
                  <th>Apagar</th>
                 </tr>
                </thead>
                <tbody> 
<?php
$tid = $_SESSION['tid'];
$select = mysqli_query($link, "SELECT * FROM tipo_credito") or die (mysqli_error($link));
if(mysqli_num_rows($select)==0)
{
echo "<div class='alert alert-info'>Sem Dados!.....Veja mas tarde!!</div>";
}
else{
while($row = mysqli_fetch_array($select))
{
$id = $row['id'];
$tipo = $row['tipo_credito'];
?>   
                <tr>
                <!--<td><input id="optionsCheckbox" class="checkbox" name="selector[]" type="checkbox" value="<?php echo $id; ?>"></td>-->
                <td><?php echo $id; ?></td>
				<td><?php echo $tipo; ?></td>
				<td>
				    <form method="post" action="">
				       <input type="hidden" name="id_credito" value="<?php echo $id; ?>">
				       <button type="submit" name="delete_credito" style="cursor: pointer;padding: 7px 10px;border: none;border-radius:2px;background-color: #428BCA;color: #fff;">
				           <i class="fa fa-trash" aria-hidden="true"></i>&nbsp;<span>Apagar</span>
				       </button>
				    </form>
				</td>

			    </tr>
<?php } } ?>
             </tbody>
                </table>  
                
<?php 
if(isset($_POST['delete_credito'])){
$id_credito = $_POST['id_credito'];
$sql = "DELETE FROM tipo_credito WHERE id = '$id_credito'";
$rs = mysqli_query($link, $sql);
	if($rs > 0){
	    echo "<script>alert('Apagou a linha de financiamento com sucesso!'); </script>";
		echo "<script>window.location='mywallet.php?tid=".$_SESSION['tid']."'; </script>";
	}else{
	    echo "<script>alert('Erro ao apagar!....Tente novamente!!'); </script>";
		echo "<script>window.location='mywallet.php?tid=".$_SESSION['tid']."'; </script>";
	}
}
?>               
                
                
                
               <div class="form-group">
                
            <div class="col-sm-10">
				<h3>Tipo de Credito por Linha de Financiamento</h3>
		    </div>
		</div> 
                
                
                <table id="example2" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <!--<th><input type="checkbox" id="select_all"/></th>-->
				  <th>Nº</th>
                  <th>Tipo de Credito</th>
				  <th>Linha de Financiamento</th>
				  <th>Apagar</th>
                 </tr>
                </thead>
                <tbody> 
<?php
$tid = $_SESSION['tid'];
$select = mysqli_query($link, "SELECT c.id, c.cadeia_valores as cadeia, t.tipo_credito as credito FROM cadeia_valores as c INNER JOIN tipo_credito as t ON c.tipo_credito = t.id") or die (mysqli_error($link));
if(mysqli_num_rows($select)==0)
{
echo "<div class='alert alert-info'>Sem Dados!.....Veja mas tarde!!</div>";
}
else{
while($row = mysqli_fetch_array($select))
{
$id = $row['id'];
$cadeia = $row['cadeia'];
$credito = $row['credito'];
?>   
                <tr>
                <!--<td><input id="optionsCheckbox" class="checkbox" name="selector[]" type="checkbox" value="<?php echo $id; ?>"></td>-->
                <td><?php echo $id; ?></td>
                <td><?php echo $cadeia; ?></td>
				<td><?php echo $credito; ?></td>
                <td>
				    <form method="post" action="">
				       <input type="hidden" name="id_cadeia" value="<?php echo $id; ?>">
				       <button type="submit" name="delete_cadeia" style="cursor: pointer;padding: 7px 10px;border: none;border-radius:2px;background-color: #428BCA;color: #fff;">
				           <i class="fa fa-trash" aria-hidden="true"></i>&nbsp;<span>Apagar</span>
				       </button>
				    </form>
				</td>
			    </tr>
<?php } } ?>
             </tbody>
                </table>  
                
<?php 
if(isset($_POST['delete_cadeia'])){
$id_cadeia = $_POST['id_cadeia'];
$sql = "DELETE FROM cadeia_valores WHERE id = '$id_cadeia'";
$rs = mysqli_query($link, $sql);
	if($rs > 0){
	    echo "<script>alert('Apagou o Tipo de Credito com sucesso!'); </script>";
		echo "<script>window.location='mywallet.php?tid=".$_SESSION['tid']."'; </script>";
	}else{
	    echo "<script>alert('Erro ao apagar!....Tente novamente!!'); </script>";
		echo "<script>window.location='mywallet.php?tid=".$_SESSION['tid']."'; </script>";
	}
}
?>
			

              </div>


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