Código PHP:
Ver original<?php
// Mostrar el listado de mis usuarios
$u = new usuarios();
$listado = $u->listado();
$cuantos = $u->cuantos();
$de = $cuantos + $_SESSION['creditos_altas'];
$creditosRenovaciones = $_SESSION["creditos_renovaciones"];
$p = $_SESSION["posicion"];
if( $cuantos < $de || $_SESSION["posicion"] == ADMIN)
{
echo "<a href='?mod=usuarios&nuevo'> [Nuevo] </a>";
if( $_SESSION["posicion"] != ADMIN )
echo "| {$cuantos} de {$de} créditos";
}
if (isset($_GET["action"]) and
$_GET["action"] == "quickenable" and
$_GET["uid"] <> "") { $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or
die ("Error connecting to database"); mysql_query("UPDATE usuarios SET enabled='true' WHERE id_usuario='".$_GET["uid"]."'") or
die ("Error editing user"); }
if (isset($_GET["action"]) and
$_GET["action"] == "quickdisable" and
$_GET["uid"] <> "") { $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or
die ("Error connecting to database"); mysql_query("UPDATE usuarios SET enabled='false' WHERE id_usuario='".$_GET["uid"]."'") or
die ("Error editing user"); }
?>
<script type="text/javascript">
$.tipo = function( id )
{
var t = $('#tipo_'+id).val();
if( t == 0 )
{
$('#altas_'+id).hide();
$('#renovaciones_'+id).hide();
$('#boton_'+id).hide();
}else if( t == 1 )
{
$('#altas_'+id).show();
$.reestablecer('#renovaciones_'+id);
$('#boton_'+id).show();
}else if( t == 2 )
{
$('#renovaciones_'+id).show();
$.reestablecer('#altas_'+id);
$('#boton_'+id).show();
}
}
$.reestablecer = function( id )
{
$(id+" option:selected").text(0) ;
$(id).hide();
}
$.SumarCreditos = function( este, id,fv )
{
$.get('modulos/usuarios/vista_sumar_creditos.php',{id_usuario:id,p:<?php echo $p?>,creditosRenovaciones:<?php echo $creditosRenovaciones?>,fv:fv},function(data){
$(este).parent().html(data);
});
}
</script>
<?php
if( $listado ){
?>
<table cellpadding="5" cellspacing="0" width="700" class="listado">
<thead>
<tr>
<th width="100">
USUARIOS:
</th>
<th>
Contraseña
</th>
<th width="70">
Inicio:
</th>
<th>
Vencimiento:
</th>
<th>
Renovar:
</th>
<th>
Estado:
</th>
<th>
Editar:
</th>
<th>
Eliminar:
</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<?php echo $row["usuario"];?><br />
<span><?php echo $row["nombre"];?></span>
</th>
<th>
<?php echo $row["contrasena"];?><br />
</th>
<td>
<?php echo $row["fecha_inicio"];?>
</td>
<td>
<?php echo $row["fecha_vencimiento"];?>
</td>
<td>
<a href="#" onclick="$.SumarCreditos(this,'<?php echo $id?>','<?php echo $row['fecha_vencimiento']?>');">
Sumar
</a>
</td>
<?php
if( $listado ){
$fecha_v_array=explode('-',$row["fecha_vencimiento"]); 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])) { $enableline = "<div><img src=\"images/no.png\" title=\"".$row["usuario"]." Usuario esta Vencido )\"></div>";
}else {
if ($row["enabled"] == "true") {
$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>";
} else {
$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>";
}
print("<td>".$enableline."</td>");
}
?>
<td>
<a href="?mod=usuarios&editar&id=<?php echo $row["id_usuario"]?>">
<img src="images/editar.png" width="20" height="20" alt="Editar">
</a>
</td>
<td>
<a href="?mod=usuarios&eliminar&id=<?php echo $row["id_usuario"]?>"
onclick="return confirm('Realmente desea eliminar al usuario: <?php echo $row["usuario"]?>?');">
<img src="images/eliminar.png" width="20" height="20" alt="Eliminar">
</a>
</td>
</tr>
<?php }?>
</tbody>
</table>
<?php }else{?>
<br />
<br />
<div class="msj_info">
No hay usuarios creados.
</div>
<?php }?>