<?

//-------------------------------fim da autenticação---------------------//

    include("authentication.php");

	include("conexao_e_agenda.php");

	include("funcoes.php");

	$id_usuario = $_SESSION["id_usuario"];

	$hora_i = $_SESSION["hora_i"];

	$hora_f = $_SESSION["hora_f"];	

    $nome_usuario = $_SESSION["nome_usuario"];

//-------------------------------fim da autenticação---------------------//

  if (isset($_GET['id_tcomp'])){

	  $id_tcomp=$_GET['id_tcomp'];

  } else {

	  $id_tcomp="";

  }

   

 $funcao = $_GET["funcao"];

 $funcao_exc = $_GET["funcao_exc"]; 



 if ($_GET['id_tcomp'] == 0){

  $funcao = "inc";

  $desc_funcao = "INCLUSÃO";  

 } else {

 $funcao = "alt";

 if($funcao_exc == 'exc'){ 

 $desc_funcao = "EXCLUSÃO"; 

 } else {

 $desc_funcao = "ALTERAÇÃO";

 }

 $sql_peca="select * from textos where id='$id_tcomp'";

 $result_peca=mysqli_query($conexao,$sql_peca) or die (mysqli_error($conexao));		  

 $linha=mysqli_fetch_array($result_peca);

 }

$desc_funcao2 = "INCLUSÃO";

$for = 'formulario'; // nome do formulário	

$voltar = -1; 

$origem = "cad_texto_alt.php";

$categoria = "texto"; 

?>

<html>

<head>

<title><? echo $empresa; ?></title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="estilo.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="js/mascara.js"></script>

<script type="text/javascript" src="lightbox.js"></script>

<SCRIPT language="javascript">

  function AbreCalendario(largura,altura,formulario,campo,tmpx) {

    vertical   = (screen.height/2) - (altura/2);

    horizontal = (screen.width/2) - (largura/2);

    var jan = window.open('calendario.php?formulario='+formulario+'&campo='+campo+'&tmpx='+tmpx,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,copyhistory=0,screenX='+screen.width+',screenY='+screen.height+',top='+vertical+',left='+horizontal+',width='+largura+',height='+altura);

    jan.focus();

  }

</SCRIPT>

<style type="text/css">

<!--

.style1 {

	color: #FFFFFF;

	font-weight: bold;

}

.style2 {color: #FFFFFF}

.style4 {font-weight: bold}

.style5 {color: #333333

}

-->

</style>

</head>



<body>

<?php include("cabecalho_e_clube.php"); ?>

<br>

<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="cant_cinza_form_peq">

  <tr class="verdana1">

    <td width="552" height="20" bgcolor="#666666"><div align="left"><font color="#FFFFFF"><strong> &nbsp;&nbsp;&nbsp;&nbsp; CADASTRO -  TEXTO</strong></font></div>

      <div align="center"><strong> <a href="index.php" class="link-bco"></a> </strong></div></td>

  </tr>

  <tr class="verdana1">

    <td height="18" bgcolor="#CCCCCC">&nbsp;&nbsp;&nbsp;&nbsp;<strong>VOC&Ecirc; 

      EST&Aacute; EXECUTANDO:</strong> <? echo $desc_funcao; ?></td>

  </tr>

  <tr class="verdana1">

    <td height="10">&nbsp;</td>

  </tr>

  <tr>

    <td height="46"><div align="right">

      <form name="<? echo $for; ?>" method="post" action="cad_texto_exec_alt.php">

        <input name="id_tcomp" type="hidden" id="id_tcomp" value="<? echo $id_tcomp; ?>">

        <input name="campo_funcao" type="hidden" id="campo_funcao" value="<? echo $funcao; ?>">

        <input name="funcao_exc" type="hidden" id="funcao_exc" value="<? echo $funcao_exc; ?>">

        <table width="100%" border="0" cellspacing="0" cellpadding="3">

          <? if($funcao == "alt"){ ?>

          <? } else { ?>

          <? } ?>

          <tr>

            <td colspan="2" class="verdana1"><div align="left"><strong>&nbsp;&nbsp;&nbsp;TEXTO:</strong>

                <input name='texto' type='text' class="caixa_preto_9" id="texto" size=80 maxlength='80' value="<? if ($funcao == 'alt') echo $linha['texto']; ?>">

            </div></td>

            </tr>

          <tr>

            <td width="28%" class="verdana1"><div align="left"><strong>&nbsp;&nbsp;&nbsp;DESCRI&Ccedil;&Atilde;O DO TEXTO:</strong></div></td>

            <td width="72%">&nbsp;</td>

          </tr>

          <tr>

            <td height="155" colspan="2" class="verdana1"><strong>

              <textarea name="desc_texto" id="desc_texto" cols="45" rows="15"><? echo $linha['desc_texto']; ?></textarea>

            </strong></td>

          </tr>

          <tr>

            <td class="verdana1">

              <div align="right"><strong>&nbsp;&nbsp;LINGUAGEM:</strong></div></td>

            <td class="verdana1"><input type="radio" name="lang" style="border:none" value="p" <?  if ($linha['lang'] == "p") echo "checked"; ?>>

              <span class="textosimples"> Portugu&ecirc;s</span>&nbsp;&nbsp;&nbsp;

              <input type="radio" name="lang" style="border:none" value="i" <?  if ($linha['lang'] == "i") echo "checked"; ?>>

              <span class="textosimples"> Ingl&ecirc;s</span>&nbsp;</td>

          </tr>

          <? if($funcao == "alt"){ ?>

          <tr>

            <td class="verdana1"><div align="right">Cadastrado em </div></td>

            <td class="verdana1"><? echo datapadrao_data($linha["dt_texto"])?></td>

          </tr>

           <? } ?>

          <tr>

            <td colspan="2" class="verdana1">&nbsp;&nbsp;&nbsp;<strong>SITUA&Ccedil;&Atilde;O:</strong>

              <input type="radio" name="situacao" style="border:none" value="d" <?  if ($linha['situacao'] == "d") echo "checked"; ?>>

              <span class="textosimples"> Vis&atilde;o Dispon&iacute;vel</span>&nbsp;&nbsp;&nbsp;

              <input type="radio" name="situacao" style="border:none" value="i" <?  if ($linha['situacao'] == "i") echo "checked"; ?>>

              <span class="textosimples">Vis&atilde;o Indispon&iacute;vel</span>&nbsp;</td>

            </tr>

          <tr>

            <td height="25" class="verdana1"><div align="center">

             <? if (($consulta == "")and($funcao == 'alt')) { ?>

              <input name="Button22" type="button" class="botao1" value="Voltar" onClick="window.location='<? echo $_SESSION['voltando'] ?>'">

              <? } if (($consulta == "")and($funcao == 'inc')) { ?>

              <input name="Button22" type="button" class="botao1" value="Voltar" onClick="window.location='<? echo $_SESSION['voltando'] ?>'">

              <? } ?>

            </div></td>

            <td height="25" class="verdana1">&nbsp;

                  <? if ($funcao == 'inc') { ?>

                  <input name="Button2" type="submit" class="botao1" value="Incluir">

                  <? } if (($funcao == 'alt') and ($funcao_exc == "")) {  ?>

                  <input name="Button2" type="submit" class="botao1" value="Atualizar">&nbsp;&nbsp;

                  <input name="Button22" type="button" class="botao1" value="Novo" onClick="window.location='cad_texto_alt.php?id_tcomp=0'">&nbsp;&nbsp;                             

                   <input name="Button" type="button" class="botao1" value="Excluir" onClick="window.location='cad_alt_excluir.php?id_c=<? echo $id_tcomp; ?>&&tabela=textos'">  <? } ?>      </td>

          </tr>

         </table>

      </form>

    </div></td>

  </tr> 

</table>

 </body>

</html>