<?php
error_reporting(E_WARNING);
require_once("funcoes.php");
require_once("valida.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php 

	$edit	=	$_GET['edit'];
	$selectnot	=	"SELECT * FROM tb_contatos WHERE cod = $edit";
	$querynot	=	mysql_query($selectnot);
	$sqlnot	=	mysql_fetch_array($querynot);
	
	
echo $sqlnot['nome_cliente'] ?> / Contato / Painel de Administra&ccedil;&atilde;o</title>
<?php require_once("topo.php"); ?>  
<link rel="stylesheet" href="css/query-ui.css" />
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<div id="conteudo">

	<div id="top_conteudo"> 
    <form action="" method="post" enctype="multipart/form-data">
    	<p style=""> Visualizando contato de <?php echo $sqlnot['nome_cliente']?></p>
        <a href="#"><div id="criar_produto"><input type="submit" name="editar_contato" value="Salvar" style="color:#fff; cursor:pointer; font-size:12px; font-weight:bold; background-color:transparent; border:0" /></div></a>
        </div> 
                
        <div id="contatos">
        
                <div id="tabs"> 
            <ul>
        <li><a href="#geral"><span>Geral</span></a></li>
        <li><a href="#produto"><span>Produto</span></a></li>
        </ul>
        <div id="geral">
        <?php
        if(isset($_GET['edit'])){
        
		$cod	=	$_GET['edit'];
		$select	=	"SELECT *, c.status AS statuscontato FROM tb_contatos c, tb_produto p WHERE c.cod = $cod AND p.cod = c.cod_prod LIMIT 1";
		$query	=	mysql_query($select);
        //p.nome AS nomeprod, c.nome_cliente, c.email_cliente, c.telefone_cliente,
		echo mysql_error();
        
		while($sql	=	mysql_fetch_array($query)){
	
		?>
        
        <table>
        	
			<input type="hidden" name="cod" value="<?php echo $cod ?>" />
          
        	<tr>
                <td>Nome Cliente </td>
                <td><?php echo $sql['nome_cliente']; ?></td>
            </tr>

            <tr>
                <td>E-mail </td>
                <td><?php echo $sql['email_cliente']; ?></td>
            </tr>

            <tr>
                <td>Telefone </td>
                <td><?php echo $sql['telefone_cliente']; ?></td>
            </tr>

            <tr>
                <td>Valor</td>
                <td>R$ <?php echo number_format($sql['valor'],2, ',', '.'); ?></td>
            </tr>

            <tr>
                <td>Data da solicitação </td>
                <td><?php echo data($sql['data']); ?></td>
            </tr>

            <tr>
                <td>Feedback </td>
                <td><textarea name="feedback"><?php echo $sql['feedback']; ?></textarea></td>
            </tr>

            <tr>
                <td>Status </td>
                <td><input type="text" name="status" value="<?php echo $sql['statuscontato']; ?>" /></td>
            </tr>


            </table>   
        </div>
        <div id="produto">

            <table>

                <tr>
                    <th>Imagem</th>
                    <th>Informações</th>
                    <?php if($sql['quantidade'] <> ""){
                    $precounitario = $sql['valor'] / $sql['quantidade']; ?>
                    <th>Valor unitário</th>
                    <th>Quantidade</th>
                    <?php } else {
                        $precounitario = $sql['valor'];
                    }?>
                    <th>Valor total</th>
                    <th></th>
                    <th></th>
                </tr>

                <tr>

                    <td><img src="../images/produtos/principal/miniatura/<?php echo $sql['imagem_principal'] ?>" height='80' /></td>
                    <td><?php echo $sql['nome'] ?><br/>Cód: <?php echo $sql['sku'] ?> | Cor: <?php echo $sql['cor_prod'] ?></td>
                    <?php if($sql['quantidade'] <> ""){ ?>
                    <td>R$ <?php echo number_format($precounitario,2, ',', '.'); ?></td>
                    <td><?php echo $sql['quantidade'] ?> caixas</td>
                    <?php } ?>
                    <td>R$ <?php echo number_format($sql['valor'],2, ',', '.'); ?></td>
       

                </tr>

            </table>  

        </div>     
        
        <?php } } ?>
        </div> 
        </div>
        
        <script>
        $( "#tabs" ).tabs();
        </script>
        </table>
  
    </div> 
    </div> 
    </div>
    </div>

    </form>

<?php require_once("footer.php"); ?>


</body>
</html>