Ver Mensaje Individual
  #7 (permalink)  
Antiguo 20/06/2011, 23:32
privatefta
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: [Ayudas] con un codigo que no me quiere funcionar

Código PHP:
Ver original
  1. <?php
  2.     // Mostrar el listado de mis  usuarios
  3.     $u = new usuarios();
  4.     $listado = $u->listado();
  5.     $cuantos = $u->cuantos();
  6.     $de = $cuantos + $_SESSION['creditos_altas'];
  7.     $creditosRenovaciones =  $_SESSION["creditos_renovaciones"];
  8.     $p = $_SESSION["posicion"];
  9.  
  10. if( $cuantos < $de || $_SESSION["posicion"] == ADMIN)
  11. {
  12.     echo "<a href='?mod=usuarios&nuevo'> [Nuevo] </a>";
  13.     if( $_SESSION["posicion"] != ADMIN )
  14.     echo "| {$cuantos} de {$de} cr&eacute;ditos";
  15. }
  16. if (isset($_GET["action"]) and $_GET["action"] == "quickenable" and $_GET["uid"] <> "") {
  17.     $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
  18.     mysql_select_db($dbname, $conn);
  19.     mysql_query("UPDATE usuarios SET enabled='true' WHERE id_usuario='".$_GET["uid"]."'") or die ("Error editing user");
  20.     mysql_close($conn);
  21. }
  22.  
  23. if (isset($_GET["action"]) and $_GET["action"] == "quickdisable" and $_GET["uid"] <> "") {
  24.     $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
  25.     mysql_select_db($dbname, $conn);
  26.     mysql_query("UPDATE usuarios SET enabled='false' WHERE id_usuario='".$_GET["uid"]."'") or die ("Error editing user");
  27.     mysql_close($conn);
  28. }
  29. ?>
  30. <script type="text/javascript">
  31.  
  32.  $.tipo = function( id )
  33.  {
  34.      var t = $('#tipo_'+id).val();
  35.  
  36.      if( t == 0 )
  37.      {
  38.         $('#altas_'+id).hide();
  39.         $('#renovaciones_'+id).hide();
  40.         $('#boton_'+id).hide();
  41.      }else if( t == 1 )
  42.      {
  43.         $('#altas_'+id).show();
  44.        
  45.         $.reestablecer('#renovaciones_'+id);
  46.         $('#boton_'+id).show();
  47.      }else if( t == 2 )
  48.      {
  49.         $('#renovaciones_'+id).show();
  50.         $.reestablecer('#altas_'+id);
  51.         $('#boton_'+id).show();
  52.      }
  53.      
  54.  }
  55.  $.reestablecer = function( id )
  56.  {
  57.     $(id+" option:selected").text(0) ;
  58.     $(id).hide();
  59.  }
  60.  $.SumarCreditos = function( este, id,fv )
  61.  {
  62.      $.get('modulos/usuarios/vista_sumar_creditos.php',{id_usuario:id,p:<?php echo $p?>,creditosRenovaciones:<?php echo $creditosRenovaciones?>,fv:fv},function(data){
  63.              $(este).parent().html(data);
  64.       });  
  65.  }
  66. </script>
  67. <?php
  68.     if( $listado ){
  69. ?>
  70.    
  71.     <table cellpadding="5" cellspacing="0" width="700" class="listado">
  72.         <thead>
  73.             <tr>
  74.                 <th width="100">
  75.                     USUARIOS:
  76.                 </th>
  77.                 <th>
  78.                     Contrase&ntilde;a
  79.                 </th>
  80.                  <th width="70">
  81.                     Inicio:
  82.                 </th>
  83.                 <th>
  84.                     Vencimiento:
  85.                 </th>
  86.                 <th>
  87.                     Renovar:
  88.                 </th>  
  89.                 <th>
  90.                     Estado:
  91.                 </th>
  92.                 <th>
  93.                     Editar:
  94.                 </th>    
  95.                 <th>
  96.                     Eliminar:
  97.                 </th>                  
  98.             </tr>
  99.         </thead>
  100.         <tbody>
  101.         <?php while( $row = mysql_fetch_assoc( $listado ) ){ $id = $row['id_usuario'];?>
  102.                 <tr>
  103.                     <th>
  104.                         <?php echo $row["usuario"];?><br />
  105.                         <span><?php echo $row["nombre"];?></span>
  106.                     </th>
  107.                     <th>
  108.                         <?php echo $row["contrasena"];?><br />
  109.                     </th>
  110.                     <td>
  111.                         <?php echo $row["fecha_inicio"];?>
  112.                     </td>
  113.                     <td>
  114.                         <?php echo $row["fecha_vencimiento"];?>
  115.                     </td>
  116.                      <td>
  117.                         <a href="#" onclick="$.SumarCreditos(this,'<?php echo $id?>','<?php echo $row['fecha_vencimiento']?>');">
  118.                             Sumar
  119.                         </a>
  120.                     </td>
  121.     <?php
  122.     if( $listado ){
  123.          $fecha_v_array=explode('-',$row["fecha_vencimiento"]);
  124.          $fechaa_a_array = explode('-',Date("Y-m-d"));
  125.          if(mktime(0,0,0,$fecha_v_array[1],$fecha_v_array[2],$fecha_v_array[0])< mktime(0,0,0,$fechaa_a_array[1],$fechaa_a_array[2],$fechaa_a_array[0])) {
  126.          $enableline = "<div><img src=\"images/no.png\" title=\"".$row["usuario"]." Usuario esta Vencido )\"></div>";
  127.         }else {
  128.         if ($row["enabled"] == "true") {
  129.          $enableline = "<div><a href=\"?mod=usuarios&action=quickdisable&uid=".$row["id_usuario"]."\"><img src=\"images/si.png\" title=\"".$row["usuario"]." Esta Activado (haga clic para desactivar)\"></a></div>";
  130.         } else {
  131.             $enableline = "<div><a href=\"?mod=usuarios&action=quickenable&uid=".$row["id_usuario"]."\"><img src=\"images/no.png\" title=\"".$row["usuario"]." Esta Desactivado (haga clic para activar)\"></a></div>";
  132.         }
  133.             print("<td>".$enableline."</td>");
  134.             }
  135.     ?>
  136.                      <td>
  137.                         <a href="?mod=usuarios&editar&id=<?php echo $row["id_usuario"]?>">
  138.                         <img src="images/editar.png" width="20" height="20" alt="Editar">
  139.                         </a>
  140.                     </td>
  141.                     <td>
  142.                         <a href="?mod=usuarios&eliminar&id=<?php echo $row["id_usuario"]?>"
  143.                         onclick="return confirm('Realmente desea eliminar al usuario: <?php echo $row["usuario"]?>?');">
  144.                         <img src="images/eliminar.png" width="20" height="20" alt="Eliminar">
  145.                         </a>
  146.                     </td>
  147.                 </tr>
  148.         <?php }?>
  149.         </tbody>
  150.        
  151.     </table>
  152.     <?php }else{?>
  153.     <br />
  154.     <br />
  155.      <div class="msj_info">
  156.         No hay usuarios creados.
  157. </div>
  158. <?php }?>