<?php
ini_set('display_errors', 0);
require_once './Control/ControlArea.php';
require_once './Util/formAjax/FormAjax.php';
extract($_POST);
if (!isset($lang))
{
	$lang = 'pt';
} else 
{
	if ($lang == 'undefined')
	{
		$lang = 'pt';
	}
}
$controlArea = new ControlArea();
if ($acao == 'inserir')
{
        echo 'Novo Registro...';
        $pk = '';
	$area = new Area();
} else
{
	$area = $controlArea->pegarUmArea($pk);
}
$area->lang = $lang;
$arquivoGrid = 'adm_areaGrid.php';
?>
<form name="frm" id="frm" action="adm_areaCMD.php" method="post">
    <input id="hacao" name="acao" type="hidden" value="<?php echo $acao?>">
    <input id="lang" name="lang" type="hidden" value="<?php echo $lang?>">
    <input id="arqFrm" name="arqFrm" type="hidden" value="<?php echo end(explode("/", $_SERVER['PHP_SELF']))?>">
	<fieldset>
		<label>Área</label>
                <?php echo Idiomas::ComboSelecionarIdiomaPainelControle($acao, $pk, $lang);?>
		<section><label for="pk">ID</label>
                    <div><input  readonly="true" type="text" id="pk" name="pk" value="<?php echo $area->getAreaid(); ?>" placeholder="Este campo é gerido de forma automática."></div>
		</section>
                <section><label for="txtTitulo">Titulo</label>
                    <div><input type="text" id="txtTitulo" name="txtTitulo" required value="<?php echo $area->getTitulo(); ?>"></div>
		</section>
                <section><label for="txtDescricao">Descrição</label>
                    <div><input type="text" id="txtDescricao" name="txtDescricao" value="<?php echo $area->getDescricao(); ?>"></div>
		</section>
                <section><label for="txtTexto">Texto</label>
                    <div><textarea required id="txtTexto" name="txtTexto" class="html" rows="20" cols="100%" ><?php echo $area->gTexto(); ?></textarea></div>
		</section>
                <section><label for="txtTexto">Texto</label>
                    <div><textarea id="txtTexto1" name="txtTexto1" class="html" rows="20" cols="100%"><?php echo $area->gTexto1(); ?></textarea></div>
		</section>
                <section>
                    <div><button onclick="mostrarArquivo('<?php echo $arquivoGrid; ?>','#dados');" >Cancelar</button><button id="salvar" class="submit" name="submitbuttonname" value="submitbuttonvalue">Salvar</button></div>
		</section>
	</fieldset>
</form>
<?php
      FormAjax::javascriptTrocarIdioma('adm_areaForm.php');
      FormAjax::PrepararFormAjax('#frm');
?>
<script>
$("#txtTexto").ready(function(){
	carregarEditor();
});    
</script>