<?php

$us = $con->query("SELECT * FROM `plans-md` order by id desc") or die(mysql_error());
?>
			<div class="confirm-question" style="display: none;" idMB="">
				<div class="container-question">
					Deseja realmente excluir o plano #<span class="F"></span>
					<button class="Confirm">Sim</button><button class="Nega">Não</button>
				</div>
			</div>
					
			<div class="content-box">
				
				<button class="add-user">Adicionar Plano</button>
				<table class="table-user" cellpadding="0" cellspacing="0">
					<thead>
						<tr class="tr-table table-header">
							<td>#</td>
							<td>Titulo</td>
							<td>Valor</td>
							<td>Tempo</td>
							<td>Telas</td>
							<td>Ações</td>
						</tr>
					</thead>
					<tbody>
						<?php
						while($user = $us->fetch(PDO::FETCH_ASSOC)){
							
						?>
						<tr class="tr-table">
							<td><?=$user['id']?></td>
							<td><?=$user['titulo']?></td>
							<td><?=number_format($user['valor'], 2, ',', '.')?></td>
							<td><?=$user['tempo']?></td>
							<td><?=$user['telas']?></td>
							<td><button class="exl-user-btn" idmb="<?=$user['id']?>" >Apagar</button></td>
						</tr>
						<? } ?>

					</tbody>
				</table>
				
			</div>	
			
			<script type="text/javascript">
				$('.add-user').click(function(){
				 	
					window.location.href="?action=pay-add";

					
				});
				$('.exl-user-btn').click(function(){
					var idUser = $(this).attr('idmb');
					$('.idUser').html(idUser);
					$('.confirm-question').attr('idMB',idUser);
					$('.confirm-question').css('display','block');
				});
				$('.Confirm').click(function(){
					var idmb = $('.confirm-question').attr('idMB');
					
					$.ajax({
					  type: "POST",
					  url: 'function/api.php?action=planexl',
					  data: {
					  	'idMB' : idmb
						},
					  success: function(data){
					  	if(data == 'E1'){
					  		$('.status').css('display','block');
					  		$('.status').css('color','white');
					  		$('.status').css('background','rgba(215,50,50,1)');
					  		$('.status p').html('Usuario Não Encotrado.');
					  		status_close();
					  	}else if(data == 'S1'){
					  		$('.status').css('display','block');
					  		$('.status').css('color','white');
					  		$('.status').css('background','rgba(50,215,50,1)');
					  		$('.status p').html('Excluido com sucesso.');
					  		status_close();
					  	}
					  },
					  
					});
					$('.confirm-question').css('display','none');
				});
				$('.Nega').click(function(){
					$('.confirm-question').css('display','none');
				});
				$('.edit-user-btn').click(function(){
					var idmb = $(this).attr('idmb');

					$.ajax({
					  type: "POST",
					  url: 'function/api.php?action=aproved',
					  data: {
					  	'idMB' : idmb
						},
					  success: function(data){
					  	if(data == 'E1'){
					  		$('.status').css('display','block');
					  		$('.status').css('color','white');
					  		$('.status').css('background','rgba(215,50,50,1)');
					  		$('.status p').html('Usuario Não Encotrado.');
					  		status_close();
					  	}else if(data == 'S1'){
					  		$('.status').css('display','block');
					  		$('.status').css('color','white');
					  		$('.status').css('background','rgba(50,215,50,1)');
					  		$('.status p').html('Excluido com sucesso.');
					  		status_close();
					  	}
					  },
					  
						  
						});
				});
			</script>
			<style type="text/css">
				.onoffswitch {
  position: relative;
  width: 78px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
.onoffswitch-checkbox {
  display: none;
}
.onoffswitch-label {
  display: block;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #999999;
  border-radius: 20px;
}
.onoffswitch-inner {
  width: 200%;
  margin-left: -100%;
  -moz-transition: margin 0.3s ease-in 0s;
  -webkit-transition: margin 0.3s ease-in 0s;
  -o-transition: margin 0.3s ease-in 0s;
  transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before,
.onoffswitch-inner:after {
  float: left;
  width: 50%;
  height: 30px;
  padding: 0;
  line-height: 30px;
  font-size: 15px;
  color: white;
  font-family: Trebuchet, Arial, sans-serif;
  font-weight: bold;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.onoffswitch-inner:before {
  content: "ON";
  padding-left: 11px;
  background-color: #00A600;
  color: #FFFFFF;
}
.onoffswitch-inner:after {
  content: "OFF";
  padding-right: 11px;
  background-color: #EEEEEE;
  color: #999999;
  text-align: right;
}
.onoffswitch-switch {
  width: 26px;
  margin: 2px;
  background: #FFFFFF;
  border: 2px solid #999999;
  border-radius: 20px;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 44px;
  -moz-transition: all 0.3s ease-in 0s;
  -webkit-transition: all 0.3s ease-in 0s;
  -o-transition: all 0.3s ease-in 0s;
  transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
  margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
  right: 0px;
}

			</style>