Guest User

Untitled

a guest
Mar 29th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.07 KB | None | 0 0
  1. <?php
  2. $sql = "SELECT * FROM painel_usuario_rel r, painel_cargos t \n".
  3.             "WHERE t.tp_usr_id=r.tp_usr_id \n".
  4.             "AND r.usr_id='".$_SESSION['usuario_id_admin']."'\n".
  5.             "AND t.tp_usr_id='1'\n".
  6.             "LIMIT 1";
  7.  
  8. $res = mysql_query($sql) or die(mysql_error());
  9. if (isset($_GETT['action'])) {
  10.     $action = $_GET['action'];
  11.        
  12.         if (isset($_GET['hora'])) {
  13.             $hora = $_GET['hora'];
  14.                
  15.                 if (isset($_GE['dia'])) {
  16.                     $dia = $_GET['dia'];   
  17.                     $dia = ($dia)?$dia:"1";
  18.                    
  19. if(mysql_num_rows($res) > 0){
  20.     $admin = true;
  21. }else{
  22.     $admin = false;
  23. }
  24. function traduz_dia($x){
  25.         switch($x){
  26.         case "7" : return "Domingo";
  27.         break;
  28.         case "1" : return "Segunda-Feira";
  29.         break;
  30.         case "2" : return "Ter&ccedil;a-Feira";
  31.         break;
  32.         case "3" : return "Quarta-Feira";
  33.         break;
  34.         case "4" : return "Quinta-Feira";
  35.         break;
  36.         case "5" : return "Sexta-Feira";
  37.         break;
  38.         case "6" : return "S&aacute;bado";
  39.         break;
  40.         }
  41. }
  42. $i=1;
  43.  
  44. $nome_dia = traduz_dia($dia);
  45.        
  46. if($action == "marcarhorario"){
  47.     $sql = "SELECT * FROM painel_horarios h INNER JOIN painel_usuarios u ON id=h.usr_id WHERE hor_dia='$dia' AND hor_hora='$hora'";
  48.     $res = mysql_query($sql) or die(mysql_error());
  49.    
  50.     if(mysql_num_rows($res)<=0){
  51.         $sql2 = "UPDATE painel_horarios SET usr_id='".$_SESSION['usuario_id_admin']."' WHERE hor_dia='$dia' AND hor_hora='$hora'";
  52.         $res2 = mysql_query($sql2) or die(mysql_error());
  53.     }
  54. }elseif($action=="desmarcarhorario"){
  55.     $sql = "SELECT * FROM painel_horarios WHERE hor_dia='$dia' AND hor_hora='$hora' AND usr_id='".$_SESSION['usuario_id_admin']."'";
  56.     $res = mysql_query($sql) or die(mysql_error());
  57.    
  58.     if(mysql_num_rows($res)>0 || $admin){
  59.         $sql2 = "UPDATE painel_horarios SET usr_id='0' WHERE hor_dia='$dia' AND hor_hora='$hora'";
  60.         $res2 = mysql_query($sql2) or die(mysql_error());
  61.     }
  62. }
  63.        
  64. echo "<center>";
  65. while($i<=7){
  66.     if($i!=1){
  67.         echo " | ";
  68.     }
  69.     if($dia==$i){
  70.         echo "<a href='?cp=$cp&c=$c&dia=$i'><b>".traduz_dia($i)."</b></a>";
  71.     }else{
  72.         echo "<a href='?cp=$cp&c=$c&dia=$i'>".traduz_dia($i)."</a>";
  73.     }
  74.     $i++;
  75. }
  76. }
  77. echo "</center>";
  78.  
  79.  
  80. ?>
  81. <script>
  82.     $("#titulo_canal span").append("&nbsp;- <?php $nome_dia ?>");
  83. </script>
  84.  
  85.     <div class="table"> <p><strong><span style="font-size:16px;">Hor&aacute;rios</span></strong></p><br/>
  86. <div>M&aacute;ximo de horas: <strong>6 horas</strong> semanais. M&iacute;nimo de horas: <strong>4 horas</strong> semanais. Pode marcar at&eacute; dois horarios por dia.
  87. </div>
  88.  
  89. <div>Em sequ&ecirc;ncia: <strong>2 horas</strong> de programa&ccedil;&atilde;o; e/ou tamb&eacute;m por exemplo um de manh&atilde; e outro a noite.&nbsp;
  90. </div>
  91.     <table width="100%" cellpadding="0" cellspacing="0" class="listing">
  92.         <tr>
  93.             <th class="first" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
  94.             <center><b>Hor&aacute;rio</b></center>
  95.             </th>
  96.            
  97.             <th align="center" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
  98.             <b>Locutor</b>
  99.             </th>
  100.            
  101.             <th class="last" style="padding:3px; background:#eeeeee; border:2px solid #fff; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px;">
  102.             <b>Programa</b>
  103.             </th>
  104.         </tr>
  105.        
  106.     <?php
  107.     $sql ="SELECT * FROM painel_horarios h WHERE h.hor_dia='$dia' ORDER BY h.hor_hora";
  108.     $res = mysql_query($sql) or die(mysql_error());
  109.     $i=1;
  110.     $total = mysql_num_rows($res);
  111.     while($row = mysql_fetch_array($res)){
  112.         $hora = str_pad($row['hor_hora'], 2, "0", STR_PAD_LEFT);
  113.    
  114.         if($row['usr_id']){
  115.             $sql_u = "SELECT usuario FROM painel_usuarios WHERE id='$row[usr_id]'";
  116.             $res_u=mysql_query($sql_u) or die(mysql_error());
  117.             $row_u=mysql_fetch_array($res_u);
  118.         }
  119.         if(!$row){
  120.             $locutor = "<a href='?cp=$cp&c=$c&action=marcarhorario&dia=$dia&hora='$row[hor_hora]''><u>Marcar Hor&aacute;rio<u></a>";
  121.             $programa = $locutor;
  122.         }elseif($_SESSION['usuario_id_admin']==$row['usr_id'] || $admin){
  123.             $titulo = $row_u['usuario'];
  124.             $programa = $row_u['programa'];
  125.        
  126.         }else{
  127.             $locutor = $row_u['usuario'];
  128.             $programa = $row_u['programa'];
  129.         }
  130.     $bg = (($i+1)%2==0)?"bg":"";
  131.    
  132.    
  133.     ?>
  134.         <tr class="<?php $bg ?>">
  135.             <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
  136.             <?php str_pad($row['hor_hora'], 2, "0", STR_PAD_LEFT).":00 ~ ".(str_pad($row['hor_hora']+1, 2, "0", STR_PAD_LEFT)) .":00"?>
  137.             </td>
  138.            
  139.             <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
  140.             <?php $locutor?>
  141.             </td>
  142.            
  143.             <td align="center" style="border-left:2px dashed #fff; border-bottom:1px dashed #fff; padding:2px;">
  144.             <?php $programa?>
  145.             </td>
  146.         </tr>
  147.     <?php
  148.         unset($row_u);
  149.         unset($locutor);
  150.         unset($programa);
  151.         $i++;
  152.     }
  153.         }
  154. }
  155.      ?>
  156.     </table>
  157. </div>
  158. </div>
  159. </div>
Advertisement
Add Comment
Please, Sign In to add comment