<?php
session_start();
if (!session_is_registered("clave_audio")) {
	include("../login.php");
	if (!$continuar) exit;
}
include('../db.php');
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ocasi&oacute;n</title>
<link href="../sformi.css" rel="stylesheet" type="text/css">
</head>
<body>
<table border="0" cellspacing="0" cellpadding="2">
	<tr>
	  <td width="200"><a href="ocasion_edit.php?op=add" class="button">[ a&ntilde;adir ocasi&oacute;n ]</a></td>
	<tr><td colspan="5"><img src="../_imgs/d.gif" width="200" height="5"></td></tr>
 </table>
<table border="0" cellspacing="0" cellpadding="0">
<?php
	$conn = db_connect();
	if($conn) {
		$query =   "SELECT ocasion_id, ocasion_categoria, ocasion_nombre, ocasion_estado, ocasion_pvp, ocasion_precio, ocasion_unidades, ocasion_descripcion 
					FROM shoop_ocasion
					/* WHERE ocasion_unidades > 0 */
					ORDER BY ocasion_categoria, ocasion_id";
		$result = mysql_query($query, $conn);
?>
	<tr>
		<td width="355" valign="top" class="hdr">Nombre</td>
		<td width="80" valign="top" class="hdr" align="right">PVP</td>
		<td width="80" valign="top" class="hdr" align="right">P. Oferta</td>
		<td width="40" valign="top" class="hdr" align="right">Uds.</td>
		<td width="100" valign="top" class="hdr">&nbsp;</td>
	</tr>
<?php
	$secciones = array('', 'Altavoces', 'Electr&oacute;nicas', 'Reproductores de CD, convertidores D/A, etc.', 'Varios');
	$curSeccion='';
	while ($row = mysql_fetch_array($result))
	{
		$ocasion_id = $row['ocasion_id'];
		$ocasion_categoria = $row['ocasion_categoria'];
		$ocasion_nombre = $row['ocasion_nombre'];
		$ocasion_estado = $row['ocasion_estado'];
		$ocasion_pvp = $row['ocasion_pvp'];
		$ocasion_precio = $row['ocasion_precio'];
		$ocasion_unidades = $row['ocasion_unidades'];
		$ocasion_descripcion = $row['ocasion_descripcion'];

		if($ocasion_categoria != $curSeccion){
			$curSeccion = $ocasion_categoria;
?>
		<tr>
			<td colspan="5" class="lbl"><?php echo $secciones[$ocasion_categoria]; ?><img src="../_imgs/d.gif" width="15" height="20"></td>
		</tr>
			
<?php
		}

?>
	<tr>
		<td width="355" valign="top" class="data">&nbsp;&nbsp;<?php echo '<span class="lbl">' . $ocasion_nombre . '</span>' . (strlen($ocasion_estado) ? ' (' . $ocasion_estado . ')': "") . (strlen($ocasion_descripcion) ? '<br>&nbsp;&nbsp;<i>' . $ocasion_descripcion . '</i>': "") ; ?></td>
		<td width="80" valign="top" align="right" class="data"><?php echo number_format($ocasion_pvp, 2, ',', '.');; ?></td>
		<td width="80" valign="top" align="right" class="data"><?php echo number_format($ocasion_precio, 2, ',', '.'); ?></td>
		<td width="40" valign="top" align="right" class="data"><?php echo $ocasion_unidades; ?></td>
		<td valign="top" class="data" align="center">&nbsp;<a href="ocasion_edit.php?op=edit&id=<?php echo $ocasion_id; ?>" class="button">[ editar ]</a></td>
	</tr>
	<tr>
		<td bgcolor="#DBDEE6" colspan=7><img src="img/d.gif" width="5" height="1"></td>
	</tr>
<?php
		}	// while
	} else {	// IF CONN
		echo '<p>An error has occurred while accessing the database: ' . mysql_error();
	}	 
?>
</table>
</body>
</html>

















