<?php
      include("./bd/conexao.php");
      include("protege.php");
     protegePagina();
     error_reporting(0);
     ini_set("display_errors", 0);

?>

<!DOCTYPE html>

<html lang="en">



<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    

    <meta name="csrf-token" content="tOkvGAJe58nm5un1M6ktgQfNg1K1zPBqN1BxRFek">

    <title>Provedor Painel</title>

    

    <link rel="stylesheet" href="/painel/admin-assets/vendors/ti-icons/css/themify-icons.css">

    <link rel="stylesheet" href="/painel/admin-assets/vendors/css/vendor.bundle.base.css">

    <link rel="stylesheet" href="/painel/admin-assets/css/horizontal-layout-light/style.css">

    <link rel="shortcut icon" href="/painel/admin-assets/images/favicon.png" />

</head>



<body>

    <div class="container-scroller">

        <div class="horizontal-menu">

    <nav class="navbar top-navbar col-lg-12 col-12 p-0">

        <div class="container">

            <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">

                <a class="navbar-brand brand-logo" href="/">

                    <!--<img src="admin-assets/images/logo-white.svg" alt="logo" />-->

                    <span style="color: white;">Provedor Painel</span>

                </a>

                <a class="navbar-brand brand-logo-mini" href="/">

                    <!--<img src="admin-assets/images/logo-mini.svg" alt="logo" />-->

                    <span style="color: white; font-size: 18px;">Provedor Painel</span>

                </a>

            </div>

            <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end">

                <ul class="navbar-nav navbar-nav-right">

                    <li class="nav-item nav-profile dropdown">

                        <a class="nav-link" href="#" data-toggle="dropdown" id="profileDropdown">

                                                             Bem Vindo :<?php echo $_SESSION['email'];?>
       

       <?php

          if(isset($_GET['acao']) && $_GET['acao'] == 'sair'){
            sairPagina();
          }
       ?> <span class="caret"></span>

                                                    </a>

                        <div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="profileDropdown">

                            <a class="dropdown-item" href="?acao=sair" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">

                                <i class="ti-power-off text-primary"></i>

                                Logout

                            </a>

                            <form id="logout-form" action="?acao=sair" method="POST" style="display: none;">

                                <input type="hidden" name="_token" value="tOkvGAJe58nm5un1M6ktgQfNg1K1zPBqN1BxRFek">                            </form>

                        </div>

                    </li>

                </ul>

                <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button"

                    data-toggle="horizontal-menu-toggle">

                    <span class="ti-menu"></span>

                </button>

            </div>

        </div>

    </nav>

    <nav class="bottom-navbar">

        <div class="container">

            <ul class="nav page-navigation">

                <li class="nav-item">

                    <a class="nav-link" href="/painel/admin.php">

                        <i class="ti-settings menu-icon"></i>

                        <span class="menu-title">Config. Gerais</span>

                    </a>

                </li>

                <li class="nav-item">

                    <a href="/painel/pagina-inicial.php" class="nav-link">

                        <i class="ti-home menu-icon"></i>

                        <span class="menu-title">Página Inicial</span>

                    </a>

                </li>

                <li class="nav-item">

                    <a href="/painel/sobre-sobre.php" class="nav-link">

                        <i class="ti-info menu-icon"></i>

                        <span class="menu-title">Página Sobre</span>

                    </a>

                </li>

                <li class="nav-item">

                    <a href="/painel/pagina-planos.php" class="nav-link">

                        <i class="ti-money menu-icon"></i>

                        <span class="menu-title">Página Planos</span>

                    </a>

                </li>

                <li class="nav-item">

                    <a href="/painel/pagina-servicos.php" class="nav-link">

                        <i class="ti-bolt menu-icon"></i>

                        <span class="menu-title">Página Serviços</span>

                    </a>

                </li>

                <li class="nav-item">

                    <a href="/painel/pagina-contato.php" class="nav-link">

                        <i class="ti-email menu-icon"></i>

                        <span class="menu-title">Página Contato</span>

                    </a>

                </li>

                <li class="nav-item" style="visibility: hidden;">

                    <a href="/painel/pagina-contato.php" class="nav-link">

                        <i class="ti-email menu-icon"></i>

                        <span class="menu-title">Página Contato</span>

                    </a>

                </li>

            </ul>

        </div>

    </nav>

</div>



        <div class="container-fluid page-body-wrapper">

            <div class="main-panel">

                <div class="content-wrapper">


                        <div class="row">

        <div class="col-12 grid-margin stretch-card">

            <div class="card">

                <div class="card-body">

                    <p class="card-title">Lista de Planos</p>

                    <p class="text-muted font-weight-light mb-5">

                        Os planos aparecem no site na ordem que são criados. <a target="_blank" href="/#plano">Visualizar alterações. <i class="ti ti-arrow-top-right"></i></a>

                    </p>



                    <table class="table table-striped table-borderless">

                

   <thead>

                            <tr>

                                <th>Nome</th>

                                <th>Velocidade</th>

                                <th>Preço</th>

                                <th>Destaque</th>

                                <th></th>

                            </tr>

                        </thead>

      

    <tbody>

               <?php
                     
                     $server = $link->query("SELECT * FROM planos ORDER BY id");



                     if(mysqli_num_rows($server) == 0){

                        

                     }else{

                            require("./bd/conexao.php");

                            while($ln = mysqli_fetch_array($server)){
                            

                              $id            = $ln['id'];

                              $nome          = $ln['nome'];

                              $velocidade    = $ln['velocidade'];

                              $mensalidade   = $ln['mensalidade'];

                              $destaque      = $ln['destaque'];



                           echo '<tr>       

                                 <td>'.$nome.'</td>

                                 <td>'.$velocidade.'</td>

                                 <td >R$:<b/>'.$mensalidade.'</td>

                                 <td>'.$destaque.'</td>

                                 <td 

 <div class="float-right" role="group">

                                            <form id="delete-form" action="excluir.php?id='.$id.'" method="POST">

                                                <input type="hidden" name="_token" value="tOkvGAJe58nm5un1M6ktgQfNg1K1zPBqN1BxRFek">                                                <input type="hidden" name="_method" value="delete">                                                <a href="editar.php?id='.$id.'" class="btn btn-warning">Editar</a>

                                                <input type="submit" class="btn btn-danger" value="Excluir">

                                            </form>

                                        </div>



</td>

                              </tr>';

                        }

                     }

               ?>

    

     </tbody>

        </form>

  </table>



                </div>

            </div>

        </div>

    </div>

<?php


if(isset($_POST['acao']) && $_POST['acao'] == 'Editar_Produto'){

    $nome         = $_POST["nome"];
    $velocidade   = $_POST['velocidade'];
    $mensalidade  = $_POST['mensalidade'];
    $destaque     = $_POST['destaque'];


       $sql = "INSERT INTO planos (nome, velocidade, mensalidade, destaque) VALUES ('$nome', '$velocidade', '$mensalidade' , '$destaque')";
if(mysqli_query($link, $sql)){
    echo '<div class="content-wrapper">
                                            <div class="alert alert-success" role="alert">
                            Pagina sobre atualizada com sucesso.
                        </div>';
        }else{
            echo '<div class="content-wrapper">
                                            <div class="alert alert-warning" role="alert">
                            Ouve um erro ao Atualizar.
                        </div>';
}
    }
   ?>


    <div class="row">

        <div class="col-12 grid-margin stretch-card">

            <div class="card">

                <div class="card-body">

                    <p class="card-title">Criar Novo Plano</p>



                    <form action="" method="POST" enctype="multipart/form-data">

                        <input type="hidden" name="_token" value="tOkvGAJe58nm5un1M6ktgQfNg1K1zPBqN1BxRFek">

                        <div class="form-group">

                            <label for="nome">Nome</label>

                            <input type="text" name="nome" class="form-control"  placeholder="Ex: Basico, Inicial, Simples, etc.">

                        </div>

                        <div class="form-group">

                            <label for="velocidade">Velocidade (somente números)</label>

                            <input type="text" name="velocidade" class="form-control"  placeholder="Ex: 15, 30, 50, 100, etc.">

                        </div>

                        <div class="form-group">

                            <label for="mensalidade">Mensalidade (somente números)</label>

                            <input type="string" name="mensalidade" class="form-control"  placeholder="Ex: 69,90, 79,99, 95, etc.">

                        </div>


                        <div class="form-group">

                            <div class="form-check form-check-flat">

                                <label class="form-check-label">

                                    <input class="checkbox" type="checkbox" name="destaque" value="featured">

                                    Destacar

                                <i class="input-helper"></i></label>

                            </div>

                        </div>




                       



                        <button type="hidden" name="acao" value="Editar_Produto" class="btn btn-block btn-lg btn-success mt-5"><i class="ti ti-plus"></i> Adicionar Plano</button>

                    </form>

                </div>

            </div>

        </div>

    </div>

                </div>

                <footer class="footer">

    <div class="w-100 clearfix">

        <span class="text-muted d-block text-center text-sm-left d-sm-inline-block">Copyright © 2019. All rights reserved.</span>

    </div>

</footer>            </div>

        </div>

    </div>



    <script src="/painel/admin-assets/vendors/js/vendor.bundle.base.js"></script>

    <script src="/painel/admin-assets/vendors/chart.js/Chart.min.js"></script>

    <script src="/painel/admin-assets/js/off-canvas.js"></script>

    <script src="/painel/admin-assets/js/hoverable-collapse.js"></script>

    <script src="/painel/admin-assets/js/template.js"></script>

    <script src="/painel/admin-assets/js/settings.js"></script>

    <script src="/painel/admin-assets/js/todolist.js"></script>

    <script src="/painel/admin-assets/js/dashboard.js"></script>

    <script src="/painel/admin-assets/js/todolist.js"></script>

</body>



</html>