Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $sql = "SELECT * FROM painel_usuario_rel r, painel_cargos t \n".
- "WHERE t.tp_usr_id=r.tp_usr_id \n".
- "AND r.usr_id='".$_SESSION['usuario_id_admin']."'\n".
- "AND t.tp_usr_id='1'\n".
- "LIMIT 1";
- $res = mysql_query($sql) or die(mysql_error());
- if (isset($_GETT['action'])) {
- $action = $_GET['action'];
- if (isset($_GET['hora'])) {
- $hora = $_GET['hora'];
- if (isset($_GE['dia'])) {
- $dia = $_GET['dia'];
- $dia = ($dia)?$dia:"1";
- if(mysql_num_rows($res) > 0){
- $admin = true;
- }else{
- $admin = false;
- }
- function traduz_dia($x){
- switch($x){
- case "7" : return "Domingo";
- break;
- case "1" : return "Segunda-Feira";
- break;
- case "2" : return "Terça-Feira";
- break;
- case "3" : return "Quarta-Feira";
- break;
- case "4" : return "Quinta-Feira";
- break;
- case "5" : return "Sexta-Feira";
- break;
- case "6" : return "Sábado";
- break;
- }
- }
- $i=1;
- $nome_dia = traduz_dia($dia);
- if($action == "marcarhorario"){
- $sql = "SELECT * FROM painel_horarios h INNER JOIN painel_usuarios u ON id=h.usr_id WHERE hor_dia='$dia' AND hor_hora='$hora'";
- $res = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($res)<=0){
- $sql2 = "UPDATE painel_horarios SET usr_id='".$_SESSION['usuario_id_admin']."' WHERE hor_dia='$dia' AND hor_hora='$hora'";
- $res2 = mysql_query($sql2) or die(mysql_error());
- }
- }elseif($action=="desmarcarhorario"){
- $sql = "SELECT * FROM painel_horarios WHERE hor_dia='$dia' AND hor_hora='$hora' AND usr_id='".$_SESSION['usuario_id_admin']."'";
- $res = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($res)>0 || $admin){
- $sql2 = "UPDATE painel_horarios SET usr_id='0' WHERE hor_dia='$dia' AND hor_hora='$hora'";
- $res2 = mysql_query($sql2) or die(mysql_error());
- }
- }
- echo "<center>";
- while($i<=7){
- if($i!=1){
- echo " | ";
- }
- if($dia==$i){
- echo "<a href='?cp=$cp&c=$c&dia=$i'><b>".traduz_dia($i)."</b></a>";
- }else{
- echo "<a href='?cp=$cp&c=$c&dia=$i'>".traduz_dia($i)."</a>";
- }
- $i++;
- }
- }
- echo "</center>";
- ?>
- <script>
- $("#titulo_canal span").append(" - <?php $nome_dia ?>");
- </script>
- <div class="table"> <p><strong><span style="font-size:16px;">Horários</span></strong></p><br/>
- <div>Máximo de horas: <strong>6 horas</strong> semanais. Mínimo de horas: <strong>4 horas</strong> semanais. Pode marcar até dois horarios por dia.
- </div>
- <div>Em sequência: <strong>2 horas</strong> de programação; e/ou também por exemplo um de manhã e outro a noite.
- </div>
- <table width="100%" cellpadding="0" cellspacing="0" class="listing">
- <tr>
- <th class="first" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
- <center><b>Horário</b></center>
- </th>
- <th align="center" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
- <b>Locutor</b>
- </th>
- <th class="last" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
- <b>Programa</b>
- </th>
- </tr>
- <?php
- $sql ="SELECT * FROM painel_horarios h WHERE h.hor_dia='$dia' ORDER BY h.hor_hora";
- $res = mysql_query($sql) or die(mysql_error());
- $i=1;
- $total = mysql_num_rows($res);
- while($row = mysql_fetch_array($res)){
- $hora = str_pad($row['hor_hora'], 2, "0", STR_PAD_LEFT);
- if($row['usr_id']){
- $sql_u = "SELECT usuario FROM painel_usuarios WHERE id='$row[usr_id]'";
- $res_u=mysql_query($sql_u) or die(mysql_error());
- $row_u=mysql_fetch_array($res_u);
- }
- if(!$row){
- $locutor = "<a href='?cp=$cp&c=$c&action=marcarhorario&dia=$dia&hora='$row[hor_hora]''><u>Marcar Horário<u></a>";
- $programa = $locutor;
- }elseif($_SESSION['usuario_id_admin']==$row['usr_id'] || $admin){
- $titulo = $row_u['usuario'];
- $programa = $row_u['programa'];
- }else{
- $locutor = $row_u['usuario'];
- $programa = $row_u['programa'];
- }
- $bg = (($i+1)%2==0)?"bg":"";
- ?>
- <tr class="<?php $bg ?>">
- <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
- <?php str_pad($row['hor_hora'], 2, "0", STR_PAD_LEFT).":00 ~ ".(str_pad($row['hor_hora']+1, 2, "0", STR_PAD_LEFT)) .":00"?>
- </td>
- <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
- <?php $locutor?>
- </td>
- <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
- <?php $programa?>
- </td>
- </tr>
- <?php
- unset($row_u);
- unset($locutor);
- unset($programa);
- $i++;
- }
- }
- }
- ?>
- </table>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment