<?php
// ####################################################
// tienda.php
// parte de shoop
// © ff 2005

// wfcart siempre antes del inicio de sesion
include('_incl/wfCart.php');
session_start();

include('db.php');
include('_config.php');
include('_incl/code.php');
include('_incl/shoopCliente.php');

// ####################################################
// cargo el carrito o lo creo nuevo si fuera menester
$cart =& $_SESSION['cart'];
if(!is_object($cart)) $cart = new wfCart();
?>
<!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>clave audio</title>
<link href="_incl/ca.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="_incl/code.js"></script>
	<link href="_incl/ca.css" rel="stylesheet" type="text/css" />
	<link href="_incl/sformi.css" rel="stylesheet" type="text/css" />
	<link href="_incl/banners.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="_incl/code.js"></script>
    <style type="text/css">
<!--
label, .input2 {
	display: block;
	width: 120px;
	float: left;
	margin-bottom: 6px;
}

label {
	text-align: right;
	width: 75px;
	padding-right: 10px;
}

br {
	clear: left;
}
-->
    </style>
</head>
<body>
<?php
	include("top.htm");
?>
<table border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
	</tr>
	<tr>
		<td valign="top" width="168">
<?php
include("clavemenu2.php");

$conn = db_connect();
if($conn) {
	$query = "SELECT faq_pregunta, faq_respuesta FROM shoop_faq WHERE faq_seccion >= 2 AND faq_seccion <=4 ORDER BY RAND() LIMIT 1 ";
	$result = mysql_query($query, $conn);
	if($result) {
		$row = mysql_fetch_array($result);
?>
	<div class="qa"><span class="capi">&iquest;</span><b><?php echo stripslashes($row['faq_pregunta']); ?>?</b><br /><?php echo stripslashes($row['faq_respuesta']); ?></div>
<?php
		}
	}
?>
		</td>
		<td background="_imgs/ptos.gif"></td>
		<td colspan="5" width="528" valign="top"><p><img src="_imgs/titPedido.gif" width="325" height="20"><br>
			<img src="_imgs/g.gif" width="528" height="1">
<p><span class="capi">1.</span> <span class="trece">Este es el contenido de su cesta de la compra.</span><br>
Antes de continuar compruebe que los productos, cantidades y, si corresponde, los acabados son correctos. Si desea eliminar alg&uacute;n producto de la cesta cambie la cantidad a 0 (cero).</p>
<?php
   	if(is_object($cart)) {
		$numProducts = $cart->itemcount;
		$subTotal = $cart->total;
	} else {
		$numProducts = $subTotal = 0;
	}

	if($numProducts) {
		$items = $cart->get_contents();
?>
      <form action="carrito_update.php" method="post" name="carrito" id="carrito">
        <table border="0" cellpadding="2" cellspacing="0">
          <tr>
            <td width="28" class="cab">Ud.</td>
            <td width="262" class="cab">Producto</td>
            <td width="90" class="cab">Acabados</td>
            <td width="64" class="cab" align="right">PVP Ud. </td>
            <td width="65" class="cab" align="right">Subtotal</td>
          </tr>
<?php
		foreach($items as $item) {
?>
          <tr>
            <td><input name="ud<?php echo $item['id']; ?>" type="text" class="data" style="width:18px;" value="<?php echo $item['qty']; ?>" maxlength="2"></td>
            <td width="262" class="data"><?php echo  $item['info']['tipo'] . $item['info']['marca'] . ' ' . $item['info']['modelo']; ?></td>
            <td class="data"><?php
		if(strlen($item['info']['acabados'])) {
?>
				<select name="color<?php echo $item['id']; ?>" id="color<?php echo $item['id']; ?>" class="data">
<?php
					// normalizo todas las comas-espacio a coma
					$prod_colores = str_replace(', ', ',', $prod_colores);
					echo array2Select(split(",", $item['info']['acabados']), $item['info']['color']);
?>
				</select>				
<?php
		}	
?>
</td>
            <td class="data" align="right"><?php echo miNumberFormat($item['price']); ?>&euro;</td>
            <td class="data" align="right"><?php echo miNumberFormat($item['subtotal']); ?>&euro;</td>
          </tr>   
<?php
		}
?>
			<tr>
				<td colspan="3"><img src="_imgs/d.gif" width="168" height="2"></td>
				<td colspan="2" background="_imgs/ptoshg6.gif"><img src="_imgs/d.gif" width="6" height="1"></td></tr>
<?php
		if($subTotal >= $GLOBALS['no_portes']) {
?>
			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right"><b>Total: </b><?php echo miNumberFormat($subTotal); ?>&euro;</td></tr>
			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right">IVA y Gastos de env&iacute;o incluidos.</td></tr>
<?php
		} else {
?>
			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right">Subtotal: <?php echo miNumberFormat($subTotal); ?>&euro;</td></tr>

			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right">Gastos de env&iacute;o: <?php echo $GLOBALS['portes']; ?>&euro;<br></td></tr>

			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right"><b>Total: </b><?php echo miNumberFormat($subTotal + $GLOBALS['portes']); ?>&euro;<br></td></tr>

			<tr>
				<td><img src="_imgs/d.gif" width="12" height="12"></td>
				<td colspan="4" class="data" align="right">IVA incluido.</td></tr>

<?php
		}
?>
			<tr>
				<td colspan="5"><img src="_imgs/d.gif" width="168" height="2"></td></tr>


			<tr><td colspan="5" class="data" align="right">
			Si ha modificado el pedido haga clic en este bot&oacute;n&nbsp;&nbsp;<input type="submit" value="Actualizar pedido" class="data"></td></tr>
        </table>
      </form>
      
<?php      
	} else {
?>
	<span class="data">Su cesta est&aacute; vac&iacute;a.</span>
<?php
}
?>
<hr align="center" width="90%" size="1" noshade>
<p><span class="capi">2.</span> <span class="trece">Ind&iacute;quenos ahora sus datos y la direcci&oacute;n donde desea que le enviemos el pedido.</span>
<form id="pedido" name="pedido" method="post" action="pedido_procesa.php">
<label for="nombre" class="data">Nombre:</label><input name="nombre" type="text" size="" maxlength="60" style="width:420px;" class="input2 data" value=""><br>
<label for="email" class="data">email:</label><input name="email" type="text" size="" maxlength="60" style="width:240px;" class="input2 data" value=""><br>
<label for="direccion" class="data">Direcci&oacute;n:</label><input name="direccion" type="text" size="" maxlength="60" style="width:420px;" class="input2 data" value=""><br>
<label for="codigopostal" class="data">C. Postal:</label><input name="codigopostal" type="text" size="" maxlength="6" style="width:50px;" class="input2 data" value="">
<label for="localidad" class="data">Localidad:</label><input name="localidad" type="text" size="" maxlength="50" style="width:278px;" class="input2 data" value=""><br>
<label for="provincia" class="data">Provincia:</label><input name="provincia" type="text" size="" maxlength="50" style="width:300px;" class="input2 data" value=""><br>
<label for="nif" class="data">NIF:</label><input name="nif" type="text" size="" maxlength="12" style="width:90px;" class="input2 data" value=""><br>
<label for="telefono" class="data">Tel&eacute;fono:</label><input name="telefono" type="text" size="" maxlength="15"  style="width:105px" class="input2 data" value="">
<label for="fax" class="data">Fax:</label><input name="fax" type="text" size="" maxlength="15"  style="width:105px" class="input2 data" value=""><br>
<hr align="center" width="90%" size="1" noshade>
<p><span class="capi">3.</span> <span class="trece">Por &uacute;ltimo, seleccione la forma de pago para su pedido.</span><br>En la siguiente pantalla podr&aacute; ver los detalles de pago.</p>
<label for="formapago">&nbsp;</label><input name="formapago" type="radio" class="data" value="tarjeta" checked>
	<span class="data">Tarjeta de Cr&eacute;dito</span>&nbsp;&nbsp;<input name="formapago" type="radio" class="data" value="transferencia">
	<span class="data">Transferencia Bancaria</span><br><br>
<div style="width:100%" align="right"><input type="submit" value="Confirmar pedido" class="cab"></div>
</form>  
</tr>
</table>	
</td>
</tr>
<tr><td colspan="7"><img src="_imgs/d.gif" width="708" height="12"></td></tr>
<tr>
<td colspan="7"><?php include("pie.htm"); ?></td>
</tr>
<tr><td colspan="7"><img src="_imgs/d.gif" width="708" height="12"></td></tr>
</table>
</body>
</html>
