<?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_popup WHERE cod = $edit";
	$querynot	=	mysql_query($selectnot);
	$sqlnot	=	mysql_fetch_array($querynot);
	
	
echo $sqlnot['cod'] ?> / Popup / 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="gerenciar_popup.php?pag=1" method="post" enctype="multipart/form-data">
    	<p style=""> Editando popup</p>
        <a href="#"><div id="criar_produto"><input type="submit" name="editar_popup" value="Salvar" style="color:#fff; cursor:pointer; font-size:12px; font-weight:bold; background-color:transparent; border:0" /></div></a>
        </div> 
                
        <div id="cadastros">
        
        <div id="tabs"> 
            <ul>
                <li><a href="#geral"><span>Geral</span></a></li>
        	</ul>
        <div id="geral">
        <?php
        if(isset($_GET['edit'])){
        
		$cod	=	$_GET['edit'];
		$select	=	"SELECT * FROM tb_popup WHERE cod = $cod LIMIT 1";
		$query	=	mysql_query($select);
		echo mysql_error();
		while($sql	=	mysql_fetch_array($query)){
		
		?>
        
        <table>
        	
			<input type="hidden" name="cod" value="<?php echo $sql['cod']; ?>" />
            
             <tr class="titulo">
                <td>Titulo: </td>
                <td><input type="text" name="titulo" value="<?php echo $sql['titulo']; ?>" required="" /></td>
            </tr>

            <?php if($sql['tipo'] == 1){ ?>

            <tr class="descricao">
                <td>Descrição: </td>
                <td><input type="text" name="descricao" class="input" required="" value="<?php echo $sql['descricao']; ?>" /></td>
            </tr>

            <tr class="descricao">
                <td>Texto Botão: </td>
                <td><input type="text" name="botao" class="input" required="" value="<?php echo $sql['text_button']; ?>" /></td>
            </tr>

            <tr class="descricao">
                <td>Msg Agradecimento: </td>
                <td><input type="text" name="msg_agradecimento" class="input" required="" value="<?php echo $sql['msg_agradecimento']; ?>" /></td>
            </tr>

            <?php } ?>
            
            <tr>
                <td>Imagem: </td>
                

                <?php if(isset($_GET['del_imagem_prod1'])){
                               
                    $coddelprod =   $_GET['del_imagem_prod1'];
                    $updateprod =   "UPDATE tb_popup SET imagem = '' WHERE cod = $coddelprod";
                    $deletar_foto   =   "../images/popup/".$sql['imagem'];
                    if($queryprod   =   mysql_query($updateprod)){
                    
                    if(unlink($deletar_foto)){
                              
                              echo "Imagem excluida";
                              
                             } else {
                                 
                                 echo "Erro ao excluir";
                                 
                             } } }
                         
                if($sql['imagem'] == "" or $_GET['del_imagem_prod1']){?>
                
                    <td><input type="file" name="foto" value="" required="" /></td>
                
                <?php } else { ?> 

                    <td><?php if($sql['imagem'] <>""){ echo "<img src='../images/popup/".$sql['imagem']."' width='50' />"; } ?><input type="file" name="foto" /><a href="?edit=<?php echo $sql['cod'] ?>&del_imagem_prod1=<?php echo $sql['cod'] ?>" style="font-size:10px; text-decoration:none;">Excluir</a></td>
                    <input type="hidden" name="foto2" value="<?php echo $sql['imagem']; ?>" />
                
                <?php } ?>
            </tr>

            <tr>
                <td>Exibições: </td>
                <td><input type="text" name="exibicoes" value="<?php echo $sql['exibicoes']; ?>" required="" /></td>
            </tr>
        
            
            </table>          
        
        
        </div> 
        
        
        </div>
        <?php } } ?>
        
        <script>
        $( "#tabs" ).tabs();
        </script>
        </table>
  
    </div> 
    </div> 
    </div>
    </div>

    </form>

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


</body>
</html>