<?php
ob_start();
clearstatcache();

require_once "connect.php";

if(isset($_GET['id_comanda'])){
    $id_comanda = $_GET['id_comanda'];
}

if(isset($_POST['id_comanda'])){
    $id_comanda = $_POST['id_comanda'];
}

/*
echo "<pre>";
echo $id_comanda;
echo "</pre>";
exit;
*/

?> 
<html> 
<head> 
	 <meta charset="UTF-8">
	<title>ERPC Code</title> 

	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="jquery.mobile.structure-1.0.1.css" />
	<link rel="apple-touch-icon" href="images/launch_icon_57.png" />
	<link rel="apple-touch-icon" sizes="72x72" href="images/launch_icon_72.png" />
	<link rel="apple-touch-icon" sizes="114x114" href="images/launch_icon_114.png" />
	<link rel="stylesheet" href="jquery.mobile-1.0.1.css" />
	<link rel="stylesheet" href="custom.css" />

	
	<script src="js/comanda_nav.js"></script>

	
    <script src="js/jquery.mobile-1.0.1.min.js"></script>
	<script src="js/jquery-1.7.1.min.js"></script>

	</head>

<body> 
<div id="choisir_ville" data-role="page" data-add-back-btn="true" >
	
	<div data-role="header"> 
	  <!-- button type="button" onclick="window.history.go(-1); return false;" id="voltar" >Voltar</button-->
	  <h1>Categorias</h1>
	</div> 

	<div data-role="content">
	
	<div class="choice_list"> 
	<h1>Selecione a categoria</h1>
  
	
	<ul data-role="listview" data-inset="true" data-filter="true"  >
	
  <?php 
  
// Método para post de Query Avançada
	$consulta = "select * from erpc_categorias_produtos where st_ativo = 1";
  

			$resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
			if (mysqli_num_rows($resultado)>0) {
            while ($registro = mysqli_fetch_assoc($resultado)){
                
            if(isset($_GET['id_comanda'])){
                $id_comanda = $_GET['id_comanda'];
            }

            $id_categoria = $registro['id'];
            $ds_categoria = $registro['ds_categoria'];
            $ds_imagem = $registro['ds_imagem'];
            
  ?>          

          <li><a href="erpc_comanda_produtos.php?id_comanda=<?php echo $id_comanda?>&id_categoria=<?php echo $id_categoria?>"  data-transition="slidedown"> <img src="../<?php echo $ds_imagem?>"/> <h2><?php echo $ds_categoria?></h2> </a> </li>      
          
<?php
          }
        }
          
  
  ?>
  
	</ul>
	</div>
	
	</div>

</div><!-- /page -->
</body>
</html>