<?php
require_once("admin/inc/protecao-final.php");

@mysqli_query($conexao,"CREATE TABLE `djs_logs` ( `codigo` INT(10) NOT NULL AUTO_INCREMENT , `codigo_stm` INT(10) NOT NULL , `codigo_dj` INT(10) NOT NULL , `data` DATETIME NOT NULL , `status` INT(1) NOT NULL DEFAULT '0', PRIMARY KEY (`codigo`)) ENGINE = MyISAM;");

$total_avisos_ativos = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos WHERE area = 'streaming'"));
$checar_status_aviso = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos_desativados WHERE area = 'streaming' AND codigo_usuario = '".$dados_stm["porta"]."'"));
$total_avisos_exibir = ($total_avisos_ativos > $checar_status_aviso) ? $total_avisos_ativos-$checar_status_aviso : 0;

if($_POST["cadastrar_dj"]) {

if(isset($_POST["dj_login"]) && isset($_POST["dj_senha"])) {

// Verifica se o DJ ja existe
$verifica_dj = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM djs where codigo_stm = '".$dados_stm["codigo"]."' AND login = '".$_POST["dj_login"]."'"));

if($verifica_dj > 0) {

// Cria o sessão do status das ações executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-warning text-center" role="alert">'.$lang['lang_acao_gerenciador_djs_resultado_alerta'].'</div>';

header("Location: /gerenciar-djs");
exit();
}

mysqli_query($conexao,"INSERT INTO djs (codigo_stm,login,senha) VALUES ('".$dados_stm["codigo"]."','".$_POST["dj_login"]."','".$_POST["dj_senha"]."')");

// Cria o sessão do status das ações executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-success text-center" role="alert">'.$lang['lang_acao_gerenciador_djs_resultado_ok'].'</div>';

} else {

// Cria o sessão do status das ações executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-danger text-center" role="alert">'.$lang['lang_acao_gerenciador_djs_resultado_erro'].'</div>';

}

header("Location: /gerenciar-djs");
exit();

} // Fim cadastra DJ

if($_POST["cadastrar_restricao"]) {

if(!$_POST["dias_semana"]) {

// Cria o sessão do status das ações executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-warning text-center" role="alert">'.$lang['lang_acao_gerenciador_djs_resultado_alerta_restricao_dias_semana'].'</div>';

header("Location: /gerenciar-djs");
exit();
}

if(count($_POST["dias_semana"]) > 0){
  $dias_semana = implode(",",$_POST["dias_semana"]);
}

mysqli_query($conexao,"INSERT INTO djs_restricoes (codigo_stm,codigo_dj,hora_inicio,hora_fim,dias_semana) VALUES ('".$dados_stm["codigo"]."','".$_POST["codigo_dj"]."','".$_POST["hora_inicio"].":".$_POST["minuto_inicio"]."','".$_POST["hora_fim"].":".$_POST["minuto_fim"]."','".$dias_semana."')");

// Cria o sessão do status das ações executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-success text-center" role="alert">'.$lang['lang_acao_gerenciador_djs_resultado_ok'].'</div>';

header("Location: /gerenciar-djs");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Streaming <?php echo $dados_stm["porta"]; ?></title>
  <link rel="stylesheet" href="/inc/materialdesignicons.min.css">
  <link rel="stylesheet" href="/inc/font-awesome.min.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.base.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.addons.css">
  <link rel="stylesheet" href="/inc/theme.css">
  <link rel="shortcut icon" href="/img/favicon.ico">
  <script type="text/javascript" src="/inc/ajax-streaming.js"></script>
  <script type="text/javascript" src="/inc/javascript.js"></script>
  <script type="text/javascript">function copy_text_dj(texto) {
    var textArea = document.createElement("textarea");
    textArea.value = texto;
    document.body.appendChild(textArea);
    textArea.select();
    document.execCommand("Copy");
    textArea.remove();
}</script>
</head>

<body>
  <div class="container-scroller">
      <nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
      <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
        <?php if($dados_revenda["url_logo"]) { ?>
        <a class="navbar-brand brand-logo" href="/dashboard"><img id="logo" src="<?php echo $dados_revenda["url_logo"]; ?>" title="Painel" height="60" border="0"></a>
        <?php } else { ?>
        <a class="navbar-brand brand-logo" href="/dashboard"><span>Painel Streaming</span></a>
        <?php } ?>
        <a class="navbar-brand brand-logo-mini" href="/dashboard"><img src="/img/icones/img-icone-logo.png" title="Painel" width="32" height="32" border="0"></a>
      </div>
      <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end justify-content-lg-start">
        <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
        <ul class="navbar-nav navbar-nav-right">
          <li class="nav-item nav-profile dropdown show">
            <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="profileDropdown" aria-expanded="true">
              <i class="fa fa-power-off f-18 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_botao_titulo_ligar']; ?>/<?php echo $lang['lang_botao_titulo_desligar']; ?>"></i>
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="profileDropdown">
              <a class="dropdown-item text-success" href="javascript:ligar_streaming('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> Streaming</a>
              <a class="dropdown-item text-danger" href="javascript:desligar_streaming('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_desligar']; ?> Streaming</a>
              <div class="dropdown-divider"></div>              
              <a class="dropdown-item text-success" href="javascript:carregar_opcoes_ligar_autodj('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> AutoDJ</a>
              <a class="dropdown-item text-danger" href="javascript:desligar_autodj('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_desligar']; ?> AutoDJ</a>
            </div>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link count-indicator dropdown-toggle d-flex align-items-center justify-content-center" id="notificationDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
              <i class="mdi mdi-bell f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?>"></i>
              <?php if($total_avisos_exibir > 0) { ?><span class="count bg-success"><?php echo $total_avisos_exibir; ?></span><?php } ?>           
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="notificationDropdown">
              <a class="dropdown-item">
                <p class="mb-0 font-weight-normal float-left"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></p>
              </a>
              <div class="dropdown-divider"></div>
              <?php carregar_avisos_streaming($conexao,$dados_stm["porta"],$dados_servidor["codigo"]); ?>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/sair"><i class="mdi mdi-logout f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="Sair/logout"></i></a>
          </li>
          <li>
            <button type="button" class="btn btn-info" id="status-streaming" onClick="status_streaming('<?php echo $porta_code; ?>');" style="margin: 10px;min-width: 150px; min-height: 40px"><i class="fa fa-refresh"></i></button>
          </li>
        </ul>
        <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
      </div>
    </nav>

    <!-- modal -->
      <div class="modal fade" id="avisos" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body" id="avisos-conteudo"><img src="/img/ajax-loader.gif" align="center" /></div>
            </div>
        </div>
      </div>
                
      <div class="modal fade" id="playlists-autodj" tabindex="-1" role="dialog" aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">AutoDJ</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body text-center" id="playlists-autodj-conteudo" style="text-align: center;"><img src="/img/ajax-loader.gif" /></div>
            </div>
          </div>
      </div>
                
      <div class="modal fade" id="log-sistema" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-body" id="log-sistema-conteudo" style="text-align:center"><img src="/img/ajax-loader.gif" /></div>
            </div>
        </div>
      </div>
      
    <div class="container-fluid page-body-wrapper">      
    <?php require_once("menu.php"); ?>
      <div class="main-panel">
        <div class="content-wrapper">
          <div id="local-status-acoes"><?php echo $_SESSION['status_acao'];unset($_SESSION['status_acao']); ?></div>
          <div class="alert alert-info text-center" role="alert">N&atilde;o &eacute; necess&aacute;rio desligar o autodj ao cadastrar/remover DJs.</div>
          <div class="row">            

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_djs_aba_djs']; ?></header>
                  </div>
                <div class="card-body">
                    <table id="data_table1" class="table dataTable no-footer" role="grid" aria-describedby="data_table_info">
                                                <thead>
                                                    <tr role="row">
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_porta_dj']; ?></th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_login']; ?></th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_senha_conexao']; ?></th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending">Status</th>
                                                        <th class="nosort sorting_disabled" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_executar_acao']; ?></th>
                                                    </tr>
                                                </thead>
                                                <tbody>

<?php

$sql = mysqli_query($conexao,"SELECT * FROM djs where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login");
while ($dados_dj = mysqli_fetch_array($sql)) {

$status = ($dados_dj["conectado"] == "sim") ? '<span class="badge badge-success">Conectado</span>' : '<span class="badge badge-light">Desconectado</span>';

$dj_code = code_decode($dados_dj["codigo"],"E");

echo "<tr id='".$dj_code."'>
<td height='25' align='left' scope='col' class='texto_padrao'>&nbsp;".$dados_stm["porta_dj"]."&nbsp;<span class='badge badge-primary' onClick='copiar_texto(\"".$dados_stm["porta_dj"]."\");' style='cursor:pointer;padding: 4px;' title='Copiar/Copy'><i class='fa fa-files-o' style='font-size: 11px;'></i></span></td>

<td height='25' align='left' scope='col' class='texto_padrao'>&nbsp;".$dados_dj["login"]."&nbsp;<span class='badge badge-primary' onClick='copiar_texto(\"".$dados_dj["login"]."\");' style='cursor:pointer;padding: 4px;' title='Copiar/Copy'><i class='fa fa-files-o' style='font-size: 11px;'></i></span></td>

<td height='25' align='left' scope='col' class='texto_padrao'>&nbsp;".$dados_dj["login"].":".$dados_dj["senha"]."&nbsp;<span class='badge badge-primary' onClick='copiar_texto(\"".$dados_dj["login"].":".$dados_dj["senha"]."\");' style='cursor:pointer;padding: 4px;' title='Copiar/Copy'><i class='fa fa-files-o' style='font-size: 11px;'></i></span></td>

<td height='25' align='left' scope='col' class='texto_padrao'>&nbsp;".$status."</td>
<td height='25' align='right' scope='col' class='texto_padrao'><a href='javascript:remover_dj(\"".$dj_code."\");'><i class='fa fa-trash-o text-danger'></i></a></td>
</tr>";
}

?>
                                                </tbody>
                                            </table>
                </div>
              </div>
            </div>

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_djs_aba_restricoes']; ?></header>
                  </div>
                <div class="card-body">
                    <table id="data_table2" class="table dataTable no-footer" role="grid" aria-describedby="data_table_info">
                                                <thead>
                                                    <tr role="row">
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_login']; ?></th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_restricoes_restricao']; ?></th>
                                                        <th class="nosort sorting_disabled" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_gerenciador_djs_executar_acao']; ?></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
<?php

$sql_restricoes = mysqli_query($conexao,"SELECT * FROM djs_restricoes where codigo_stm = '".$dados_stm["codigo"]."' ORDER by codigo ASC");
while ($dados_djs_restricao = mysqli_fetch_array($sql_restricoes)) {

$dados_dj = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM djs where codigo = '".$dados_djs_restricao["codigo_dj"]."'"));

// Restrição horario
if($dados_djs_restricao["hora_inicio"] && $dados_djs_restricao["hora_fim"]) {
$restricao_horario = $dados_djs_restricao["hora_inicio"]." ".$lang['lang_info_gerenciador_djs_restricoes_horario_ate']." ".$dados_djs_restricao["hora_fim"];
} else {
$restricao_horario = $lang['lang_info_gerenciador_djs_info_sem_restricao'];
}

// Restrição dias da semana
$array_dias = explode(",",$dados_djs_restricao["dias_semana"]);

foreach($array_dias as $dia) {

if($dia == "1") {
$dia_nome = "<font color='#003399'>".$lang['lang_label_segunda']."</font>";
} elseif($dia == "2") {
$dia_nome = "<font color='#FF0000'>".$lang['lang_label_terca']."</font>";
} elseif($dia == "3") {
$dia_nome = "<font color='#FF9900'>".$lang['lang_label_quarta']."</font>";
} elseif($dia == "4") {
$dia_nome = "<font color='#CC0066'>".$lang['lang_label_quinta']."</font>";
} elseif($dia == "5") {
$dia_nome = "<font color='#009900'>".$lang['lang_label_sexta']."</font>";
} elseif($dia == "6") {
$dia_nome = "<font color='#663300'>".$lang['lang_label_sabado']."</font>";
} elseif($dia == "7") {
$dia_nome = "<font color='#663399'>".$lang['lang_label_domingo']."</font>";
} else {
$dia_nome = "";
}

$lista_dias .= "".$dia_nome.", ";

}

$restricao_dia_semana = $lista_dias;

$dj_restricao_code = code_decode($dados_djs_restricao["codigo"],"E");

echo "<tr id='".$dj_restricao_code."'>
<td height='25' align='left' scope='col' class='texto_padrao'>&nbsp;".$dados_dj["login"]."</td>
<td height='25' align='left' scope='col' class='texto_padrao_pequeno'>&nbsp;".$restricao_horario." ".$restricao_dia_semana."</td>
<td height='25' align='right' scope='col' class='texto_padrao'><a href='javascript:remover_dj_restricao(\"".$dj_restricao_code."\");'><i class='fa fa-trash-o text-danger'></i></a></td>
</tr>";
unset($lista_dias);
unset($restricao_dia_semana);
}
?>
                                                </tbody>
                                            </table>
                </div>
              </div>
            </div>

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_djs_aba_cadastrar_dj']; ?></header>
                  </div>
                <div class="card-body">
                    <form name="cadastrar_dj" id="cadastrar_dj" method="post" action="/gerenciar-djs" style="padding:0px; margin:0px">
                                            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                              <tr>
                                                <td width="130" height="50" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_gerenciador_djs_login']; ?></strong></td>
                                                <td align="left"><input name="dj_login" type="text" class="form-control" id="dj_login" style="width:95%;" onkeyup="bloquear_acentos(this);" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_gerenciador_djs_info_caracteres_especiais']; ?>" /></td>
                                              </tr>
                                              <tr>
                                                <td height="50" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_gerenciador_djs_senha']; ?></strong></td>
                                                <td align="left"><input name="dj_senha" type="text" class="form-control" id="dj_senha" style="width:95%;" onkeyup="bloquear_acentos(this);" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_gerenciador_djs_info_caracteres_especiais']; ?>" /></td>
                                              </tr>
                                              <tr>
                                                <td height="50" colspan="2" align="right" style="padding-right:20px;"><button type="button" class="btn btn-info" onClick="document.cadastrar_dj.submit();"><?php echo $lang['lang_botao_titulo_cadastrar']; ?></button><input name="cadastrar_dj" type="hidden" id="cadastrar_dj" value="sim" /></td>
                                              </tr>
                                            </table>
                                            </form>
                </div>
              </div>
            </div>

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_djs_aba_cadastrar_restricao']; ?></header>
                  </div>
                <div class="card-body">
                    <form name="restricoes" id="restricoes" method="post" action="/gerenciar-djs" style="padding:0px; margin:0px" onsubmit="return verificar_restricao_dias_semana();">
                                            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                              <tr>
                                                <td width="130" height="30" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_gerenciador_djs_login']; ?></strong></td>
                                                    <td width="760" align="left">
                                                    <select name="codigo_dj" class="form-control" id="codigo_dj" style="width:95%;">
                                                    <?php
                                                    $sql_djs = mysqli_query($conexao,"SELECT * FROM djs where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login");
                                                    while ($dados_dj = mysqli_fetch_array($sql_djs)) {
                                                        echo '<option value="' . $dados_dj["codigo"] . '">' . $dados_dj["login"] . '</option>';
                                                    }
                                                    ?>
                                                   </select>
                                                    </td>
                                                  </tr>
                                                  <tr>
                                                <td width="130" height="30" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_gerenciador_djs_restricoes_horario']; ?></strong></td>
                                                    <td align="left" class="texto_padrao_titulo"><select name="hora_inicio" id="hora_inicio" style="width:50px;">
                                                        <option value="00">00</option>
                                                        <option value="01">01</option>
                                                        <option value="02">02</option>
                                                        <option value="03">03</option>
                                                        <option value="04">04</option>
                                                        <option value="05">05</option>
                                                        <option value="06">06</option>
                                                        <option value="07">07</option>
                                                        <option value="08">08</option>
                                                        <option value="09">09</option>
                                                        <option value="10">10</option>
                                                        <option value="11">11</option>
                                                        <option value="12">12</option>
                                                        <option value="13">13</option>
                                                        <option value="14">14</option>
                                                        <option value="15">15</option>
                                                        <option value="16">16</option>
                                                        <option value="17">17</option>
                                                        <option value="18">18</option>
                                                        <option value="19">19</option>
                                                        <option value="20">20</option>
                                                        <option value="21">21</option>
                                                        <option value="22">22</option>
                                                        <option value="23">23</option>
                                                      </select>
                                                      :
                                                      <select name="minuto_inicio" id="minuto_inicio" style="width:50px;">
                                                        <?php 
                                                    for ($minuto=0;$minuto<=59;$minuto++){

                                                    echo '<option value="'.sprintf("%02d",$minuto).'">'.sprintf("%02d",$minuto).'</option>';
                                                    
                                                    }
                                                    ?>
                                                      </select>
                                                      &nbsp;<?php echo $lang['lang_info_gerenciador_djs_restricoes_horario_ate']; ?>&nbsp;
                                                      <select name="hora_fim" id="hora_fim" style="width:50px;">
                                                        <option value="00">00</option>
                                                        <option value="01">01</option>
                                                        <option value="02">02</option>
                                                        <option value="03">03</option>
                                                        <option value="04">04</option>
                                                        <option value="05">05</option>
                                                        <option value="06">06</option>
                                                        <option value="07">07</option>
                                                        <option value="08">08</option>
                                                        <option value="09">09</option>
                                                        <option value="10">10</option>
                                                        <option value="11">11</option>
                                                        <option value="12">12</option>
                                                        <option value="13">13</option>
                                                        <option value="14">14</option>
                                                        <option value="15">15</option>
                                                        <option value="16">16</option>
                                                        <option value="17">17</option>
                                                        <option value="18">18</option>
                                                        <option value="19">19</option>
                                                        <option value="20">20</option>
                                                        <option value="21">21</option>
                                                        <option value="22">22</option>
                                                        <option value="23">23</option>
                                                      </select>
                                                      :
                                                      <select name="minuto_fim" id="minuto_fim" style="width:50px;">
                                                        <?php 
                                                    for ($minuto=0;$minuto<=59;$minuto++){

                                                    echo '<option value="'.sprintf("%02d",$minuto).'">'.sprintf("%02d",$minuto).'</option>';
                                                    
                                                    }
                                                    ?>
                                                    </select></td>
                                                  </tr>
                                                  <tr>
                                                    <td height="30" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_gerenciador_djs_restricoes_horario_dias_semana']; ?></strong></td>
                                                    <td align="left" valign="middle" class="texto_padrao">
                                                <input name="dias_semana[]" type="checkbox" value="1" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_segunda']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="2" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_terca']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="3" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_quarta']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="4" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_quinta']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="5" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_sexta']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="6" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_sabado']; ?>&nbsp;
                                                <input name="dias_semana[]" type="checkbox" value="7" id="dias_semana" checked="checked" style="vertical-align:middle" /><?php echo $lang['lang_label_domingo']; ?></td>
                                              </tr>
                                              <tr>
                                                <td height="50" colspan="2" align="right" style="padding-right:20px;"><button type="button" class="btn btn-info" onClick="document.restricoes.submit();"><?php echo $lang['lang_botao_titulo_cadastrar']; ?></button><input name="cadastrar_restricao" type="hidden" id="cadastrar_restricao" value="sim" /></td>
                                              </tr>                                              
                                            </table>
                                            </form>
                </div>
              </div>
            </div>

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header>Logs</header>
                  </div>
                <div class="card-body">
                  <table id="data_table3" class="table dataTable no-footer" role="grid" aria-describedby="data_table_info">
                                                <thead>
                                                    <tr role="row">
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending">Login DJ</th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending"><?php echo $lang['lang_info_streaming_logs_data']; ?></th>
                                                        <th class="sorting_asc" tabindex="0" aria-controls="data_table" rowspan="1" colspan="1" aria-sort="ascending">Status</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
<?php
$sql = mysqli_query($conexao,"SELECT * FROM djs_logs where codigo_stm = '".$dados_stm["codigo"]."' ORDER by data DESC");
while ($dados_dj_log = mysqli_fetch_array($sql)) {

$dados_dj = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM djs where codigo = '".$dados_dj_log["codigo_dj"]."'"));

if($dados_dj_log["status"] == "1") {
$status = '<span class="label label-verde">Conectado</span>';
} elseif($dados_dj_log["status"] == "2") {
$status = '<span class="label label-amarelo">Desconectado</span>';
} elseif($dados_dj_log["status"] == "3") {
$status = '<span class="label label-vermelho">Erro Senha</span>';
} else {
$status = '<span class="label label-amarelo">Erro '.$lang[ 'lang_info_gerenciador_djs_restricoes_restricao' ].' '.$lang[ 'lang_info_gerenciador_djs_restricoes_horario' ].'</span>';
}

echo "<tr>
<td height='25' align='left' class='texto_padrao'>&nbsp;".$dados_dj["login"]."</td>
<td height='25' align='left' class='texto_padrao'>&nbsp;".formatar_data($dados_stm["formato_data"], $dados_dj_log["data"], $dados_stm["timezone"])."</td>
<td height='25' align='left' class='texto_padrao'>&nbsp;".$status."</td>
</tr>";
}
?>
                                                </tbody>
                                            </table>
                </div>
              </div>
            </div>

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

    </div>
  </div>
  <script src="/inc/vendor.bundle.base.js"></script>
  <script src="/inc/vendor.bundle.addons.js"></script>
  <script src="/inc/theme.js"></script>
  <script>
  status_streaming('<?php echo $porta_code; ?>');
  setInterval("status_streaming('<?php echo $porta_code; ?>')",60000);
        $(document).ready(function() {

            var table = $('#data_table1').DataTable({
                responsive: true,
                "lengthMenu": [[25, 50, 100, 200, -1], [25, 50, 100, 200, "Todos/All"]],
                language: {
                    "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/<?php echo $lang_sortable; ?>.json"
                },
                select: true,
                'aoColumnDefs': [{
                    'bSortable': false,
                    'aTargets': ['nosort']
                }]
            });
            $('#data_table1 tbody').on( 'click', 'tr', function() {
                if ( $(this).hasClass('selected') ) {
                    $(this).removeClass('selected');
                }
                else {
                    table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });

            var table = $('#data_table2').DataTable({
                responsive: true,
                "lengthMenu": [[25, 50, 100, 200, -1], [25, 50, 100, 200, "Todos/All"]],
                language: {
                    "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/<?php echo $lang_sortable; ?>.json"
                },
                select: true,
                'aoColumnDefs': [{
                    'bSortable': false,
                    'aTargets': ['nosort']
                }]
            });
            $('#data_table2 tbody').on( 'click', 'tr', function() {
                if ( $(this).hasClass('selected') ) {
                    $(this).removeClass('selected');
                }
                else {
                    table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });

            var table = $('#data_table3').DataTable({
                responsive: true,
                "lengthMenu": [[25, 50, 100, 200, -1], [25, 50, 100, 200, "Todos/All"]],
                language: {
                    "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/<?php echo $lang_sortable; ?>.json"
                },
                select: true,
                'aoColumnDefs': [{
                    'bSortable': false,
                    'aTargets': ['nosort']
                }]
            });
            $('#data_table2 tbody').on( 'click', 'tr', function() {
                if ( $(this).hasClass('selected') ) {
                    $(this).removeClass('selected');
                }
                else {
                    table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });

        });
  </script>
</body>
</html>