<?php
include("conexao.php");
include_once("functions.php");
include_once(Idioma(1));
if (ProtegePag() == true) {
    global $_TRA;

    $ColunaAcesso = array('TemplateInfo');
    $VerificarAcesso = VerificarAcesso('template', $ColunaAcesso);
    $TemplateInfo = $VerificarAcesso[0];

    if ($TemplateInfo == 'S') {

        $SQL = "SELECT NomePainel, LegendaPainel FROM site_config";
        $SQL = $painel_geral->prepare($SQL);
        $SQL->execute();
        $TotalPainel = count($SQL->fetchAll());
        ?>
        <ul class="breadcrumb">
            <li><?php echo $_TRA['template']; ?></li>
            <li class="active"><?php echo $_TRA['info']; ?></li>
        </ul>

        <div class="page-title">
            <h2><span class="fa fa-info"></span> <?php echo $_TRA['info']; ?></h2>
        </div>

        <div class="page-content-wrap">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-danger">
                        <div class="panel-heading">
                            <?php
                            if ($TotalPainel > 0) {
                                echo "<a type=\"button\" class=\"AdicionarEditar btn btn-info active\">" . $_TRA['editar'] . "</a>";
                            } else {
                                echo "<a type=\"button\" class=\"AdicionarEditar btn btn-danger active\">" . $_TRA['Adicionar'] . "</a>";
                            }
                            ?>
                            <ul class="panel-controls">
                                <li><a href="#" class="panel-fullscreen"><span class="fa fa-expand"></span></a></li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="fa fa-cog"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span> <?php echo $_TRA['esconder']; ?></a></li>
                                        <li><a href="#" class="panel-refresh"><span class="fa fa-refresh"></span> <?php echo $_TRA['atualizar']; ?></a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>

                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="Tabela" class="table datatable">
                                    <thead>
                                        <tr>
                                            <th width="150"><?php echo $_TRA['nome']; ?></th>
                                            <th><?php echo $_TRA['slogan']; ?></th>
                                            <th><?php echo $_TRA['opcoes']; ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $SQL->execute();
                                        while ($Ln = $SQL->fetch()) {
                                            echo "
                                            <tr>
                                            <td>" . $Ln['NomePainel'] . "</td>
                                            <td>" . $Ln['LegendaPainel'] . "</td>
                                            <td><div class=\"form-group\">";
                                            echo "<a class=\"AdicionarEditar label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"\" data-original-title=\"" . $_TRA['editar'] . "\"><i class=\"fa fa-pencil\"></i></a>&nbsp;";
                                            echo "</div>
                                            </td>
                                            </tr>
                                            ";
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-danger">
                        <div style="text-align: center;">
                            <p><strong>Avisos importantes</strong></p>
                            <?php
                            $pagina = "xtreamui.php";
                            if (isset($_POST['submit1'])) {
                                if (isset($_POST["conteudo"])) {
                                    $fopen = fopen($pagina, "w+");
                                    fwrite($fopen, $_POST["conteudo"]);
                                    fclose($fopen);
                                }
                            }
                            ?>
                            <form method="post">
                                <textarea name="conteudo" rows="5" cols="50" resize="none"><?= file_get_contents($pagina); ?></textarea>
                                <input type="submit" name="submit1" value="Salvar" />
                            </form>
                            </div>
                    </div>

                    <div class="panel panel-danger">
                        <div style="text-align: center;">
                            <p><strong>Aviso </strong></p>
                            <?php
                            $pagina1 = "xtreamui1.php";
                            if (isset($_POST['submit2'])) {
                                if (isset($_POST["conteudo1"])) {
                                    $fopen = fopen($pagina1, "w+");
                                    fwrite($fopen, $_POST["conteudo1"]);
                                    fclose($fopen);
                                }
                            }
                            ?>

                            <form method="post">
                                <textarea name="conteudo1" rows="5" cols="50" resize="none"><?= file_get_contents($pagina1); ?></textarea>
                                <input type="submit" name="submit2" value="Salvar" />
                            </form>
                        </div>
                    </div>  
                </div>
            </div>
        </div>
        <div id="StatusGeral"></div>

        <script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery/jquery-ui.min.js"></script>
        <script type="text/javascript" src="js/plugins/bootstrap/bootstrap.min.js"></script>

        <script type='text/javascript' src='js/plugins/icheck/icheck.min.js'></script>
        <script type="text/javascript" src="js/plugins/mcustomscrollbar/jquery.mCustomScrollbar.min.js"></script>
        <script type='text/javascript' src='js/plugins/maskedinput/jquery.maskedinput.min.js'></script>
        <script type="text/javascript" src="js/plugins/datatables/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="js/DataTables<?php echo Idioma(2); ?>.js"></script>


        <?php include_once("js/settings" . Idioma(2) . ".php"); ?>
        <script type="text/javascript" src="js/plugins.js"></script>
        <script type="text/javascript" src="js/actions.js"></script>

        <script type='text/javascript'>
            $(function() {
                $("a.AdicionarEditar").click(function() {

                    $.post('ScriptModalInformacoesPainel.php', function(resposta) {
                        $("#StatusGeral").html('');
                        $("#StatusGeral").html(resposta);
                    });

                });
            });
        </script>
        <?php
    } else {
        echo Redirecionar('index.php');
    }
} else {
    echo Redirecionar('login.php');
}
?>