<?php
?>
<?php
include("conexion.php");
?>
<?php
$resultado=mysql_query("SELECT * FROM servicios GROUP BY id");
echo "<table class='striped responsive-table'>";
echo "<tr>";
echo "<th data-field='id' style='display:none'>Id</th>";
echo "<th data-field='id'>Categias</th>";
echo "<th data-field='id'>Producto</th>";
echo "<th data-field='id'>Precio</th>";
echo "<th data-field='id'>Imagen</th>";
echo "<th data-field='id'>Agregar</th>";
echo "</tr>";
echo "<tr>";
echo "<td style='display:none'>".$servicios['id']."</td>";
echo "<td>".$servicios['idproductos']."</td>";
echo "<td>".$servicios['descripcion']."</td>";
echo "<td>".$servicios['precio']." BsF </td>";
echo "<td><img src=".$servicios['imagen']." width='70' height='70'></td>";
echo "<td>
<a href='preparo_contrato.php?id=".$servicios['id']."&action=";
if (isset($_SESSION['carro'][$servicios['id']])){
echo "removeProd' alt='Eliminar del carro'>
<img src='img/remove_carro.png'
width='38' height='38'
alt='Eliminar del carro'
title='Añadir producto al carrito'>";
}
else
echo "add' alt='Añadir al carro'>
<img src='img/add_carro.png'
width='38' height='38' alt='Añadir al carrito'
title='Añadir producto al carrito'>";
echo "</tr>";
}
echo "</table>";
?>
</div>
<!-- fin para carga productos-->
<div class="col s6">
<!-- tabla de productos-->
<a name='action'></a>
<?php
include("conexion.php");
?>
<h5 class="black-text text-darken-4 center-align">Mis Productos Agregados</h5>
<?php
$id = $_GET['id'];
else
$id = 1;
if (isset($_GET['action'])) $action = $_GET['action'];
else
$action = "empty";
switch($action){
case "add":
if(isset($_SESSION['carro'][$id])) $_SESSION['carro'][$id]++;
else
$_SESSION['carro'][$id]=1;
break;
case "remove":
if(isset($_SESSION['carro'][$id])) {
$_SESSION['carro'][$id]--;
if($_SESSION['carro'][$id]==0)
unset($_SESSION['carro'][$id]); }
break;
case "removeProd":
if(isset($_SESSION['carro'][$id])){ unset($_SESSION['carro'][$id]); }
break;
case "mostrar":
if(isset($_SESSION['carro'][$id])){ continue;
}
break;
case "empty":
unset($_SESSION['carro']); break;
}
if(isset($_SESSION['carro'])){ echo "<form action='preparo_contrato.php' method='POST'>";
echo "<table class='striped responsive-table'>";
$totalcoste = 0;
//Inicializamos el contador de productos seleccionados.
$xTotal = 0;
echo "<tr>";
echo "<td>Producto</td>";
echo "<td>Cantidad</td>";
echo "<td>Acción</td>";
echo "<td colspan=4 align=right>Total</td>";
echo "</tr>";
echo "<tr><td colspan=5></td></tr>";
foreach($_SESSION['carro'] as $id => $x){
$resultado = mysql_query("SELECT * FROM servicios WHERE id "); $id = $mifila['id'];
$descripcion = $mifila['descripcion'];
//acortamos el nombre del producto a 40 caracteres
$descripcion = substr($descripcion,0,40); $precio = $mifila['precio'];
//Coste por artículo según la cantidad elegida
$coste = $precio * $x;
//Coste total del carro
$totalcoste = $totalcoste + $coste;
//Contador del total de productos añadidos al carro
$xTotal = $xTotal + $x;
echo "<tr>";
echo "<td align='left'>$descripcion</td>";//muestra pruducto en el carro
echo "<td align='center'>$x<input type='hidden' name=chk_group3[] value='$x'>";
echo "<input type='hidden' name=chk_group[] value='$id'></td>";
//acciones para el carrito:
echo "<td align='left'>";
echo "<a href='preparo_contrato.php?id=". $id ."&action=add'><img src='img/aumentar.png' style='padding:0 0px 0 5px;' alt='Aumentar cantidad' /></a>";
echo "<a href='preparo_contrato.php?id=". $id ."&action=remove'><img src='img/restar.png' alt='Reducir cantidad' /></a>";
echo "<a href='preparo_contrato.php?id=". $id ."&action=removeProd'><img src='img/eliminar.png' alt='Reducir cantidad' /></a></td>";
echo "<td align='right'> = </td>";
echo "<td align='right' style='margin-left:10px'>$coste BsF.
<input type='hidden' name=chk_group2[] value='$coste'>";
echo "</tr>";
$i++;
}
//el total de la venta
echo "<tr><td colspan='5'><hr></td></tr>";
echo "<tr>";
echo "<td colspan='4'><h5 class='right-align'><b>Total =</b></h5></td>";
echo "<td align='right'><h5><b>$totalcoste</b> BsF.</h5>
<input type='hidden' name=costetotal value='$totalcoste'></td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' colspan='5'>
<input type=text placeholder='Buscar Cliente' autocomplete='off'
title='BUSQUE POR NOMBRE O NÚMERO DE CÉDULA'
style='background: white url(imagenes/lupa.png) no-repeat;
background-position: 125px;' class='cajatexto2' id='inputString'
name='cedulac' onKeyUp='lookup(this.value);' onBlur='fill();'></div>
<div class='suggestionsBox' id='suggestions' style='display: none;'>
<div class='suggestionList' id='autoSuggestionsList'>
</div></div></td></tr>";?>