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

$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;

?>
<!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/ajax-streaming-musicas.js"></script>
  <script type="text/javascript" src="/inc/javascript.js"></script>
  <style type="text/css">.lista-musicas-playlist-vinheta{padding:0;color:red;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-comercial{padding:0;color:#06f;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-hora-certa{padding:0;color:#090;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-intercalado{padding:0;color:#63f;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-pasta{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-pasta li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}ul#lista-musicas-pasta li:hover{background-color:#eee}ul#lista-musicas-pasta a{text-decoration:none;color:#000}ul#lista-musicas-pasta a:hover{text-decoration:underline}ul#lista-pastas{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-pastas li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}ul#lista-pastas li:hover{background-color:#eee}ul#lista-pastas a{text-decoration:none;color:#000}ul#lista-pastas a:hover{text-decoration:underline}ul#lista-playlists{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-playlists li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}ul#lista-playlists li:hover{background-color:#eee}ul#lista-playlists a{text-decoration:none;color:#000}ul#lista-playlists a:hover{text-decoration:underline}ul#lista-musicas-playlist{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-playlist li{list-style:none;display:block;padding-top:2px;padding-bottom:2px;position:relative;cursor:n-resize;border:#fff 1px dashed}ul#lista-musicas-playlist li:hover{background-color:#eee;border:#999 1px dashed;-moz-opacity:.7;opacity:.7}ul#lista-musicas-playlist a{text-decoration:none;color:#000}ul#lista-musicas-playlist a:hover{text-decoration:underline}.container{width:100%;max-width:680px;text-align:center;margin:0 auto}.container h1{font-size:42px;font-weight:300;color:#0f3c4b;margin-bottom:40px}.container h1 a:focus,.container h1 a:hover{color:#39bfd3}.container nav{margin-bottom:40px}.container nav a{border-bottom:2px solid #c8dadf;display:inline-block;padding:4px 8px;margin:0 5px}.container nav a.is-selected{font-weight:700;color:#39bfd3;border-bottom-color:currentColor}.container nav a:not(.is-selected):focus,.container nav a:not(.is-selected):hover{border-bottom-color:#0f3c4b}.container footer{color:#92b0b3;margin-top:40px}.container footer p+p{margin-top:1em}.container footer a:focus,.container footer a:hover{color:#39bfd3}.box{font-size:1.25rem;background-color:#c8dadf;position:relative;padding:100px 20px}.box.has-advanced-upload{outline:2px dashed #92b0b3;outline-offset:-10px;-webkit-transition:outline-offset .15s ease-in-out,background-color .15s linear;transition:outline-offset .15s ease-in-out,background-color .15s linear}.box.is-dragover{outline-offset:-20px;outline-color:#c8dadf;background-color:#fff}.box__dragndrop,.box__icon{display:none}.box.has-advanced-upload .box__dragndrop{display:inline}.box.has-advanced-upload .box__icon{width:100%;height:80px;fill:#92b0b3;display:block;margin-bottom:40px}.box.is-error .box__input,.box.is-success .box__input,.box.is-uploading .box__input{visibility:hidden}.box__error,.box__success,.box__uploading{display:none}.box.is-error .box__error,.box.is-success .box__success,.box.is-uploading .box__uploading{display:block;position:absolute;top:50%;right:0;left:0;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.box__uploading{font-style:italic}.box__success{-webkit-animation:appear-from-inside .25s ease-in-out;animation:appear-from-inside .25s ease-in-out}@-webkit-keyframes appear-from-inside{from{-webkit-transform:translateY(-50%) scale(0)}75%{-webkit-transform:translateY(-50%) scale(1.1)}to{-webkit-transform:translateY(-50%) scale(1)}}@keyframes appear-from-inside{from{transform:translateY(-50%) scale(0)}75%{transform:translateY(-50%) scale(1.1)}to{transform:translateY(-50%) scale(1)}}.box__restart{font-weight:700}.box__restart:focus,.box__restart:hover{color:#39bfd3}.js .box__file{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.js .box__file+label{max-width:80%;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;display:inline-block;overflow:hidden}.box__file.has-focus+label strong,.box__file:focus+label strong,.js .box__file+label:hover strong{color:#39bfd3}.js .box__file.has-focus+label,.js .box__file:focus+label{outline:1px dotted #000;outline:-webkit-focus-ring-color auto 5px}.no-js .box__file+label{display:none}.no-js .box__button{display:block}.box__button{font-weight:700;color:#e5edf1;background-color:#39bfd3;display:none;padding:8px 16px;margin:40px auto 0}.box__button:focus,.box__button:hover{background-color:#0f3c4b}</style>
</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>
              <?php if($dados_stm["autodj"] == "sim") { ?>
              <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>
              <?php } ?>
            </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="upload" tabindex="-1" role="dialog" aria-hidden="true">
                     <div class="modal-dialog modal-dialog-centered" role="document">
                         <div class="modal-content">
                             <div class="modal-body" style="text-align:center" id="upload_conteudo">
                                <iframe id="iframe_upload" frameborder="0" width="100%" height="400" src="" style="background: url('/img/ajax-loader.gif') center center no-repeat;"></iframe>
                             </div>
                         </div>
                     </div>
                </div>
      <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="row">            

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_musicas_pastas']; ?></header>
                  </div>
                <div class="card-body">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="40%" align="left" style="padding-left:5px;">
                                            <div id="borda_lista_pastas" style="background-color:#FFFFFF; border: #CCCCCC 1px solid; width:100%; height:250px; text-align:left; padding:5px; overflow: auto;">
                                              <span id="status_lista_pastas"></span>
                                                          <ul id="lista-pastas"></ul>
                                                        </div>                                                      </td>
                                        </tr>
                                        <tr>
                                          <td height="40" align="left" style="padding-left:5px;">
                                            <button type="button" class="btn btn-light" onClick="criar_pasta('<?php echo $porta_code; ?>');"><i class="fa fa-plus-circle"></i> <?php echo $lang['lang_info_gerenciador_musicas_botao_criar_pasta']; ?></button>
                                            <button type="button" class="btn btn-light" onClick="carregar_pastas('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i> <?php echo $lang['lang_info_gerenciador_musicas_botao_recarregar_pastas']; ?></button>
                                            <button type="button" class="btn btn-light" onClick="atualizar_cache_pastas('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i> Atualizar Cache</button></td>
                                        </tr>
                                      </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_musicas_musicas_pasta']; ?></header>
                                        <div class="card-header-right">
                                            <button type="button" class="btn btn-info" onClick="<?php if($dados_stm["espaco_usado"] >= $dados_stm["espaco"]) { ?>upload_blk();<?php } else { ?>enviar_musicas();<?php } ?>"><i class="fa fa-upload"></i> <?php echo $lang['lang_info_gerenciador_musicas_botao_enviar_musicas']; ?></button>&nbsp;<button type="button" class="btn btn-primary" onClick="window.open('/webftp');"><i class="fa fa-cloud-upload"></i> WebFTP</button>
                                        </div>
                  </div>
                <div class="card-body">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td align="left">
                                            <div id="musicas" style="background-color:#FFFFFF; border: #CCCCCC 1px solid; width:100%; height:250px; text-align:left; padding:5px; overflow: auto;">
                                              <span id="msg_pasta"><?php echo $lang['lang_info_gerenciador_musicas_info_lista_musicas']; ?></span><span id="status_lista_musicas" style="display: none"><img src="/img/ajax-loader.gif" /></span>
                                              <ul id="lista-musicas-pasta"></ul>
                                            </div>                                          </td>
                                        </tr>
                                        <tr>
                                          <td width="60%" height="40" align="left"><div style="width:95%; text-align:left; float:right; padding:5px; overflow: auto;"><strong><?php echo $lang['lang_info_gerenciador_musicas_pasta_selecionada']; ?></strong>&nbsp;<span id="msg_pasta_selecionada"><?php echo $lang['lang_info_gerenciador_musicas_pasta_selecionada_nenhuma']; ?></span></div><input name="pasta_selecionada" type="hidden" id="pasta_selecionada" value="" /></td>
                                        </tr>
                                      </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);
        carregar_pastas('<?php echo $porta_code; ?>');
        $('#upload').on('hidden.bs.modal', function () {
        carregar_pastas('<?php echo $porta_code; ?>');
        carregar_musicas_pasta( '<?php echo $porta_code; ?>', document.getElementById("pasta_selecionada").value );
        });
        $('#log-sistema').on('hidden.bs.modal', function () {
        document.getElementById("log-sistema-conteudo").innerHTML = '<img src="/img/ajax-loader.gif" />';
        });
        window.closeModal = function(){
            $('#upload').modal('hide');
        };
        function upload_blk() {
          $('#upload_conteudo').html('<div class="alert alert-warning text-center" role="alert">O limite de espa&ccedil;o do seu plano foi atingido! Para efetuar novos uploads por favor entre em contato com suporte.</div>'); 
          $('#upload').modal('show'); 
        }
  </script>
</body>
</html>