Advertisement
luisabarca

Radio estrellas

Sep 2nd, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <?php
  2.  
  3. // @TODO: Pasarlo a libreria
  4. // ESTE ES EL METODO QUE USO PARA GENERAR LOS RADIO BUTTONS
  5.  
  6. function __generarEstrellasSoloLectura()
  7. {
  8.     $value = 10;
  9.     $numargs = func_num_args();
  10.     $valor = '';
  11.     $checked = '';
  12.     $radioFormat = "<input name=\"%s\" type=\"radio\" class=\"star {half:true}\" value=\"%s\" id=\"%d\" disabled=\"disabled\" %s />"
  13.  
  14.     if (3 == $numargs) {
  15.         $name = func_get_arg(0);       
  16.         $id_sub = func_get_arg(1);
  17.         $calificacion = func_get_arg(2);
  18.  
  19.         //$str=null;
  20.         $link = new Conexion();
  21.  
  22.         $mysqli = $link->getLink();
  23.  
  24.         for ($i=0; $i < 10; $i++) {
  25.             $valor = $value . '-' . $id_sub;           
  26.             $checked = $value == $calificacion ? ' checked="checked"' : '';
  27.  
  28.             printf($radioFormat, $name, $valor, $id_sub, $checked);
  29.             $value += 10;
  30.         }
  31.     } // if
  32.  
  33.     unset($link);
  34.     //return $str;     
  35. } // funcion
  36.  
  37. // OBTENGO MI RANKING DE EMPLEADOS DESDE UNA CONSULTA DE SQL
  38. $ranking = $evaluacion->obtenerRanking($_SESSION['id_empresa']);
  39.  
  40. ?>
  41.  
  42. <table border="0" width="100%" align="center" cellspacing="2" cellpadding="2">
  43. <?php foreach ($ranking as $r) :
  44.     $estrellas = round($r['estrellas']);
  45.     $cal = $evaluacion->calcularCalificacion($estrellas);  
  46. ?>
  47. <tr>    
  48.     <td width="60%" style="color:#fff;">
  49.         <a href="VerEmpleado.php?id=<?php echo $r['id'] ?>"><?php echo $r['nombre'] ?></a>
  50.     </td>
  51.    
  52. <?php                
  53.     /* MANDO LLAMAR A MI METODO QUE ME GENERA LOS RADIO BUTTONS DE ACUERDO A SU CALIFICACION Y DESPUES ESTOS SE CONVIERTEN A ESTRELLAS CON JQUERY * /
  54.  
  55. ?>
  56.  
  57.     <td width="40%" style="color:#000;" align="center">
  58.     <?php $evaluacion->__generarEstrellasSoloLectura($cont, $cont, $cal) ?>
  59.     </td>
  60. </tr>
  61. <?php $cont++; endforeach; ?>
  62. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement