<?php
session_start();
$car_pedido = $_SESSION['pedido'];
if(!isset($_SESSION['logado']) and $_SESSION['logado'] =='' ){
echo '<center>';
echo '<h2>Precisa estar logado</h2> <br><br>';
echo '<a href="index.php?pag=cadastrar"> Me Cadastrar</a> - <a href="index.php?pag=login"> Fazer Login</a>';
echo '</center>';
}
else
{
require_once('Connections/conn.php'); ?>
<?php
mysql_select_db($database_conn, $conn);
$query_rs = "SELECT * FROM carrinho c, produtos p where c.car_produto = p.pro_id AND c.car_pedido = '$car_pedido'";
$rs = mysql_query($query_rs, $conn) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
?>
<div>
<h2> Confirmar Pedido</h2>
<hr>
<?php
//com carrinho em produtos
if($totalRows_rs == 0) {
echo '<h2> O Carrinho está Vazio </h2>';
}
//caso exista produtos
else{
?>
<table width="532" border="0">
<tr>
<td width="63"> </td>
<td width="72">Produto</td>
<td width="103">Unitário</td>
<td width="83">x</td>
<td width="24">Sub</td>
<td width="9"> </td>
</tr>
<?php
$total = 0;
do {
$sub = $row_rs['pro_preco'] * $row_rs['car_qtd'];
$total = $total + $sub;
?>
<tr>
<td><?php echo Imagem::MiniaturaPro($row_rs['pro_foto'], 50,50); ?></td>
<td><?php echo utf8_encode ($row_rs['pro-nome']); ?></td>
<td><?php echo Sistema::Real($row_rs['pro_preco']); ?></td>
<td><?php echo $row_rs['car_qtd']; ?></td>
<td><?php echo Sistema::Real($sub); ?></td>
<td> </td>
</tr>
<?php } while ($row_rs = mysql_fetch_assoc($rs)); ?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>
<?php
echo '<h2> Valor Total: R$ ' . Sistema::Real ($total) . '</h2>';
?>
<?php
mysql_free_result($rs);
?>
<hr>
<table width="400" border="0" align="center">
<tr>
<td width="153" align="center"><a href="index.php?pag=home_produtos">Continuar Comprando</a></td>
<td width="137" align="center"><a href="#">Finalizar Pedido</a></td>
</tr>
</table>
<hr>
</div>
<?php
//fim do else
}
}//fim da verificação do if isset LOGADO
?>