<?php
  include("adm/conexao_e_agenda.php");
 // include("limpa_key.php");  
 //print_r($_POST);
 //exit();
 session_save_path('./minhas_sessions/');
 ini_set('session.gc_maxlifetime', '28800');  
  $a = session_id();
  if(empty($a)) session_start();
//echo "<br>session_id(): ".session_id();//."<br>COOKIE: ".$_COOKIE["PHPSESSID"];	 
  $session_id = session_id(); 

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width">
<title>CARRINHO DE COMPRAS - CABELOS E CREMES</title>
<!-- Jquery -->
<script src="jquery/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/tooltipster.css" />
<script type="text/javascript" src="jquery/jquery.tooltipster.min.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src="js/bootstrap.min.js"></script>
<!-- Font Awesome -->
<link href="css/font-awesome.min.css" rel="stylesheet">
<!-- Fonts -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
<!-- Custom CSS -->
<link rel="stylesheet" href="css/flaticon.css">
<!-- Custom JS-->
<script src="jquery/jquery.liveFilter.js" type="text/javascript"></script>
<!-- Template -->
<link rel="stylesheet" href="css/fwk.css">
<link rel="stylesheet" href="css/template.css">
<script type="text/javascript" src="jquery/footer.js"></script>
<!-- Ícone -->
<link rel="icon" type="image/ico" href="ico/ico_cabecremes.ico">
<style type="text/css">
.main-container.box-shadow-15-777 table tr td div {
}
.main-container.box-shadow-15-777 table tr td {
	font-weight: normal;/*bold;*/
}
</style>
</head>
<body>
	<nav class="navbar navbar-inverse navbar-static-top box-shadow-15-333">
		<div class="container">
			<div class="navbar-header">
				<h1><a class="navbar-brand text-shadow-15-000" href="http://cabelosecremes.com.br" target="_blank"><span>&nbsp;&nbsp;&nbsp;CABELOS E CREMES</span></a></h1>
			</div>
		</div>
	</nav>
    <header class="main-header">
        <h2 class="system-title">CARRINHO DE COMPRAS</h2>
    </header>
    <div class="main-container box-shadow-15-777">
      <h2 class="section-title"><i class="fa fa-home"></i><span>Produtos Adicionados</span><span class="decoration"></span></h2>
      <table width="900" border="0">
        <tr>
          <td colspan="2"></td>
        </tr>
        <tr>
          <td width="395"><input name="Button2" type="button" class="button-container" value="CONTINUAR COMPRANDO" style="cursor:hand" onClick="window.location='index.php'"></td>
          <td width="495">&nbsp; <? 
	 if(isset($_SESSION["login"])){
		$login=$_SESSION["login"];
	}else{
		$login="";
	}
	//echo $_SESSION["apelido"];
	  if($login==""){ echo "<img src='images/useronline_off.gif' width='16' height='16' />"; } else { echo "Seja Bem Vindo! ".$_SESSION["apelido"]." <a href='area_login_logout.php'>&nbsp;&nbsp;<img src='images/useronline.gif' width='16' height='16' />&nbsp;[ SAIR ]</a>"; }?></td>
    </td>
        </tr>
      </table>      
      <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0">
          <?
         $sql="SELECT * FROM pedidos_itens WHERE id_session='$session_id' ORDER BY id ASC";// AND CURDATE() BETWEEN $data_simul AND $data_simul 
         $result=mysqli_query($conexao,$sql) or die (mysqli_error($conexao));
         $temproduto=mysqli_num_rows($result);
         if($temproduto==0){
         ?>
<tr>
    <td bgcolor="#F5F5F5" colspan="4"><div align="left">&nbsp;<font size="2" color="#000000">&nbsp;&nbsp;OLÁ!&nbsp;&nbsp; SEU CARRINHO ESTÁ VAZIO! </font></div></td>
    </tr>
    <? } else { ?>
        <tr>
    <td width="511" height="40" bgcolor="#3278B5"><div align="left"><font size="2" color="#FFFFFF">&nbsp;PRODUTO</font></div></td>
    <td width="196" bgcolor="#3278B5"><div align="left"><font size="2" color="#FFFFFF"> &nbsp;QUANTIDADE</font></div></td>
    <td width="150" bgcolor="#3278B5"><div align="left"><font size="2" color="#FFFFFF">&nbsp;VALOR</font></div></td>    
    <td width="83" bgcolor="#3278B5"><div align="center"><font size="2" color="#FFFFFF">A&Ccedil;&Atilde;O</font></div></td>
        </tr>
      
    <? while($linha_aus=mysqli_fetch_array($result)){			  		
		?>
  <tr>
    <td width="511" height="40" bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"><? echo utf8_decode($linha_aus["descricao"]); ?></font></div></td>
    <td bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"><? echo utf8_decode($linha_aus["quantidade"]); ?></font></div></td>
    <td bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"><? echo utf8_decode($linha_aus["valor"]); ?>
      </font></div></td>
    <td bgcolor="#F5F5F5"><div align="center"><a href="excluir_item.php?id=<? echo $linha_aus["id"]; ?>"><img src="btn_excluir.png" width="28" height="22" align="middle"></a></div></td>
  </tr>
  <? } 
		 mysqli_free_result($result);	  ?>
          <tr>
    <td width="511" height="20" bgcolor="#3278B5"><div align="left"></div></td>
    <td width="196" bgcolor="#3278B5"><div align="left"><font size="2" color="#FFFFFF"> &nbsp;QUANTIDADE TOTAL</font></div></td>
    <td width="150" bgcolor="#3278B5"><div align="left"><font size="2" color="#FFFFFF">&nbsp;VALOR TOTAL</font></div></td>    
    <td width="83" bgcolor="#3278B5"><div align="center"></div></td>
        </tr>
  <tr>
    <td width="511" height="40" bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"></font></div></td>
    <td bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"><? 
	     $sqlq="SELECT SUM(quantidade) as qtde FROM pedidos_itens WHERE id_session='$session_id' ORDER BY id ASC";
         $resultq=mysqli_query($conexao,$sqlq) or die (mysqli_error($conexao));
		 $linha_ausq=mysqli_fetch_array($resultq);
	echo utf8_decode($linha_ausq["qtde"]); 
		 mysqli_free_result($resultq);		?></font></div></td>
    <td bgcolor="#F5F5F5"><div align="left">&nbsp;<font size="2" color="#000000"><? 
	     $sqlv="SELECT SUM(valor) as valort FROM pedidos_itens WHERE id_session='$session_id' ORDER BY id ASC";
         $resultv=mysqli_query($conexao,$sqlv) or die (mysqli_error($conexao));
		 $linha_ausv=mysqli_fetch_array($resultv);
	echo utf8_decode(round($linha_ausv["valort"], 2)); 
		 mysqli_free_result($resultv);		?>
      </font></div></td>
    <td bgcolor="#F5F5F5"><div align="center"></div></td>
  </tr>
<!--  <tr>
    <td width="204" height="5"></td>
    <td colspan="6"></td>
  </tr>-->

</table>
      <br>
      <table width="900" border="0">
        <tr>
          <td colspan="2"></td>
        </tr>
        <tr>
          <td colspan="2" height="25"></td>
        </tr>           
        <tr>
          <td width="395"><input name="Button2" type="button" class="button-container" value="CONTINUAR COMPRANDO" style="cursor:hand" onClick="window.location='index.php'">
            &nbsp;&nbsp;&nbsp;<input name="Button" type="button" class="button-container" style="cursor:hand" onClick="window.location='cancelar_carrinho.php'" value="CANCELAR COMPRA">&nbsp;&nbsp;</td>
          <td width="495">
         &nbsp;&nbsp;<input name="Button" type="button" class="button-container" style="cursor:hand" onClick="window.location='carrinho_finaliza.php'" value="FINALIZAR COMPRA">
          </form> 
          </td>
        </tr>
      </table>
      <? } ?>
        <footer class="main-footer">
       	  <!--<h5>Prefeitura do Munic&iacute;pio de Maring&aacute;</h5>
			<p>Fone: (44) 3221.1234 - Av. XV de Novembro, 701 - Centro - Maring&aacute;-PR - CEP: 87.013-230</p>-->
            <p>&nbsp;</p>
        </footer>
    </div>
</body>
</html>
<? mysqli_close($conexao); ?>