Saudações pessoal.
Possuo um sistema web de atendimento em lanchonete funcionando no modo multi empresa.
Preciso criar uma maneira da tela de pedidos que fica na cozinha atualize os pedidos de 5 em 5 segundos.
O carro chefe do sistema é o uso de sessões para identificar os estabelecimentos.
Porém quando tento carregar a DIV (atualizar) ela dá um erro como a sessão não existe.
Tentei colocar o código referente a sessão manualmente na consulta SQL mas mesmo assim ele não consegue reconhecer os campos da tabela.
Se não conseguir resolver logo terei de voltar ao antigo refresh da página.
Se alguém puder me ajudar a resolver agradeço.
Abaixo está a página responsável pelos pedidos.
<?php
error_reporting(0);
session_start();
include('scripts/conexao.php');
if($_SESSION[loglogado] != 'S') { header("Location:".$base."/logar.html"); }
?>
<!DOCTYPE html>
<html dir="ltr" lang="pt-BR">
<head>
<meta charset="utf-8">
<title><?php echo $_SESSION[lognomeempresa]; ?></title>
<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
<link rel="stylesheet" href="<?php echo $base; ?>/style.css" media="screen">
<link rel="stylesheet" href="<?php echo $base; ?>/style.responsive.css" media="all">
<script src="<?php echo $base; ?>/jquery.js"></script>
<script src="<?php echo $base; ?>/script.js"></script>
<script src="<?php echo $base; ?>/script.responsive.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
atualiza();
});
function atualiza(){
$.get('listapedidos.php', function(resultado){
$('#tabela').html(resultado);
})
setTimeout('atualiza()', 3000);
}
</script></head>
<body>
<div id="art-main">
<?php include('scripts/headeruser.php'); ?>
<div class="art-sheet clearfix">
<div class="art-layout-wrapper">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-content">
<article class="art-post art-article">
<h2 class="art-postheader">Pedidos em Andamento</h2>
<div class="art-postcontent art-postcontent-0 clearfix">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div id="tabela" class="art-layout-cell" style="width:100%" >
######################################################################################
#################### AQUI DEVERÁ CARREGAR A LISTA DE PEDIDOS #########################
######################################################################################
</div>
</div>
</div>
</div>
<div class="art-postcontent art-postcontent-0 clearfix">
<!-- ################### LINHA 1 ##################### -->
<div class="art-content-layout">
<div class="art-content-layout-row">
<!-- ################### COLUNA 1 ##################### -->
<div class="art-layout-cell" style="width:33%; padding-right:70px" >
<p>
</p>
</div>
<!-- ################### COLUNA 2 ##################### -->
<div class="art-layout-cell" style="width:33%; padding-right:70px" >
<p>
<button class="art-button" style="width:100%;height:100px" onClick="window.location.href='<?php echo $base; ?>/atendimento.html';">VOLTAR</button>
</p>
</div>
<!-- ################### COLUNA 3 ##################### -->
<div class="art-layout-cell" style="width:33%; padding-right:70px" >
<p>
</p>
</div>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
</div>
<?php include('scripts/footer.php'); ?>
</div>
</div>
</body>
</html>
Esta é a pagina que deve retornar a lista de pedidos.
<?php
$sqlpedidos = "SELECT pedidos_mesas.*, estoque.* FROM pedidos_mesas INNER JOIN estoque ON pedidos_mesas.id_item=estoque.id_estoque Where pedidos_mesas.id_empresa=".$_SESSION[logempresa]." && pedidos_mesas.finalizado='S' && pedidos_mesas.entregue='N' ORDER BY pedidos_mesas.pronto ASC, pedidos_mesas.id_ped_mesa ASC";
$respedidos = mysql_query($sqlpedidos,$conexao);
?>
<p>
<table width="100%" border="0">
<tr>
<td style="width:100%; background-color:#CCC; border:0px; height:55px;vertical-align:middle; border-bottom:thin #CCC 1px"> PEDIDOS</td>
<td style="width:45px; background-color:#CCC; border:0px; height:55px; border-bottom:thin #CCC 1px"> </td>
<td style="width:45px; background-color:#CCC; border:0px; height:55px; border-bottom:thin #CCC 1px"> </td>
<td style="width:45px; background-color:#CCC; border:0px; height:55px; border-bottom:thin #CCC 1px"> </td>
</tr>
<?php
while($lista=mysql_fetch_array($respedidos)) {
?>
<tr style="font-weight:bold; font-size:16px">
<?php if($lista[pronto]=='S') { $bacground='background-color:#9F6;'; } else { $bacground=''; } ?>
<td style="width:100%; border:0px; <?php echo $bacground; ?> height:55px; vertical-align:middle; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:#CCC"> <?php echo $lista[qtd_item].' '.$lista[nome_estoque].' PARA A MESA '.$lista[id_mesa].$lista[observacao]; ?></td> <!-- ############################################################################################################################################################################################################################################ -->
<?php if($lista[finalizado]=='S' && $lista[pronto]=='N') { ?>
<td style="width:45px; border:0px; height:55px; border-bottom:thin #CCC 1px"><input name="altera" type="button" class="art-button" style="height:55px; background-image:url(<?php echo $base; ?>/images/btn-ok.png); background-repeat:no-repeat; background-position:center" title="Pronto" onClick="window.location.href='<?php echo $base; ?>/finaliza-pedido-corrente/<?php echo $lista[id_ped_mesa]; ?>.html';"></td>
<?php } else { ?>
<td style="width:45px; border:0px; height:55px; border-bottom:thin #CCC 1px"> </td>
<?php } ?>
<td style="width:45px; border:0px; height:55px; border-bottom:thin #CCC 1px"><input name="exclui" type="button" class="art-button" style="height:55px; background-image:url(<?php echo $base; ?>/images/btn-del.png); background-repeat:no-repeat; background-position:center" title="Cancelar" onClick="window.location.href='<?php echo $base; ?>/cancela-pedido-corrente/<?php echo $lista[id_ped_mesa]; ?>.html';"></td>
</tr>
<?php
}
?>
</table>
</p>
Desde já agradeço a todos.
Obrigado.