<?php 
//Verifica se o usu�rio tem permiss�o para acessar este conte�do
require "login_verifica.php";
if ($permissao_quiosque_definirvendedores != 1) {
    header("Location: permissoes_semacesso.php");
    exit;
}
$tipopagina = "quiosques";
include "includes.php";
$quiosque = $_POST['quiosque'];
$vendedor = $_POST['vendedor'];
$operacao = $_POST['operacao'];
$datafuncao = desconverte_data($_POST['datafuncao']);
//Template de Título e Sub-título
$tpl_titulo = new Template("templates/titulos.html");
$tpl_titulo->TITULO = "VENDEDORES";
$tpl_titulo->SUBTITULO = "CADASTRO DE VENDEDORES DO QUIOSQUE";
$tpl_titulo->ICONES_CAMINHO = "{$icones}";
$tpl_titulo->NOME_ARQUIVO_ICONE = "../pessoas2/vendedor.png";
$tpl_titulo->show();
//Estrutura da notifica��o
$tpl_notificacao = new Template("templates/notificacao.html");
$tpl_notificacao->ICONES = $icones;
$tpl_notificacao->DESTINO = "vendedores.php?quiosque={$quiosque}";
//Se a opera��o for cadastro ent�o
if ($operacao == 'cadastrar') {
    //Verifica se o vendedor j� est� na lista de vendedores do quiosque
    $sql = "SELECT * FROM quiosques_vendedores WHERE quiven_vendedor={$vendedor} and quiven_quiosque={$quiosque}";
    $query = mysql_query($sql);
    if (!$query) {
include "includes.php";
$lote = $_GET["lote"];
$numero = $_GET["numero"];
$sql = "\n    SELECT \n        pes_nome,pro_nome,entpro_quantidade,protip_sigla,protip_codigo\n    FROM \n        entradas \n        join entradas_produtos on (ent_codigo=entpro_entrada) \n        join pessoas on (ent_fornecedor=pes_codigo)\n        join produtos on (pro_codigo=entpro_produto)\n        join produtos_tipo on (protip_codigo=pro_tipocontagem)\n    WHERE \n        entpro_entrada={$lote} and\n        entpro_numero={$numero}        \n";
$query = mysql_query($sql);
if (!$query) {
    die("Erro1:" . mysql_error());
}
while ($dados = mysql_fetch_assoc($query)) {
    $fornecedor_nome = $dados["pes_nome"];
    $produto_nome = $dados["pro_nome"];
    $qtd = $dados["entpro_quantidade"];
    $tipo_contagem = $dados["protip_codigo"];
    $sigla = $dados["protip_sigla"];
}
$data = desconverte_data($_POST["data"]);
$hora = $_POST["hora"];
$tpl_titulo = new Template("templates/titulos.html");
$tpl_titulo->TITULO = "ENTRADAS";
$tpl_titulo->SUBTITULO = "IMPRIMIR ETIQUETAS GRANDE";
$tpl_titulo->ICONES_CAMINHO = "{$icones}";
$tpl_titulo->NOME_ARQUIVO_ICONE = "etiquetas.png";
$tpl_titulo->show();
$tpl1 = new Template("templates/cadastro_edicao_detalhes_2.html");
$tpl1->LINK_DESTINO = "entradas_etiquetao2.php";
$tpl1->LINK_TARGET = "_blank";
//Lote
$tpl1->TITULO = "Lote";
$tpl1->block("BLOCK_TITULO");
$tpl1->CAMPO_QTD_CARACTERES = "";
$tpl1->CAMPO_TIPO = "text";
        $tpl2->block("BLOCK_LISTAGEM");
        $tpl2->block("BLOCK_FIMFORM");
        $tpl2->show();
    }
}
$tpl2 = new Template("templates/lista2.html");
$tpl2->block("BLOCK_FIMFORM");
$tpl2->show();
//Botões
$tpl = new Template("templates/cadastro1.html");
$tpl->FORM_NOME = "form2";
$tpl->FORM_TARGET = "";
$tpl->FORM_LINK = "acertos_revenda_cadastrar2.php";
$tpl->block("BLOCK_FORM");
$tpl->CAMPOOCULTO_NOME = "dataini";
$tpl->CAMPOOCULTO_VALOR = desconverte_data($dataini);
$tpl->block("BLOCK_CAMPOOCULTO");
$tpl->CAMPOOCULTO_NOME = "datafim";
$tpl->CAMPOOCULTO_VALOR = "{$datafim}";
$tpl->block("BLOCK_CAMPOOCULTO");
$tpl->CAMPOOCULTO_NOME = "horaini";
$tpl->CAMPOOCULTO_VALOR = "{$horaini}";
$tpl->block("BLOCK_CAMPOOCULTO");
$tpl->CAMPOOCULTO_NOME = "horafim";
$tpl->CAMPOOCULTO_VALOR = "{$horafim}";
$tpl->block("BLOCK_CAMPOOCULTO");
$tpl->CAMPOOCULTO_NOME = "totalvenda";
$tpl->CAMPOOCULTO_VALOR = "{$venda_total}";
$tpl->block("BLOCK_CAMPOOCULTO");
$tpl->CAMPOOCULTO_NOME = "totalcusto";
$tpl->CAMPOOCULTO_VALOR = "{$custo_total}";