+
+
+ ';
+
+ echo $html;
+ }
+
+ /**
+ * Fecha o Quadro Principal
+ *
+ * Função para fechar o quadro Principal do Sistema.
+ *
+ * @return void
+ */
+ function fechaQuadro() {
+ $html = "\n\n
\n";
+ echo $html;
+ }
+
+ /**
+ * MontaArraySelect
+ *
+ * Função para Retornar o array necessário para montar um campo do tipo SELECT.
+ * Parâmetros: Conexão, SQL, Id (nome do campo que será usado para o value das options), Valor (nome do campo que será mostrado nas options)
+ *
+ * @param string $conn
+ * @param string $sql
+ * @param string $id
+ * @param string $value
+ * @return array $arrSelectValues
+ */
+ function MontaArraySelect($conn,$sql,$id,$value) {
+ $arrSelectValues = array();
+ $resu = pg_query($conn,$sql);
+ if (pg_num_rows($resu)>0) {
+ for ($x=0;$x0) {
+ for ($x=0;$x0) {
+ for ($x=0;$x0) {
+ while ($linha = pg_fetch_array($resu,$i,PGSQL_ASSOC)) {
+ $ret = $this->validaCondicao($condicao,$linha);
+ if ($ret) {
+ array_push($arr,$linha[$key]);
+ }
+ }
+ }
+ return $arr;
+ }
+
+ public function validaCondicao($condicao,$linha,$debug = false) {
+ foreach (array_keys($linha) as $col) {
+ $condicao = str_replace("{" . $col . "}","'" . $linha[$col] . "'",$condicao);
+ }
+ $fcondicao = ' if (' . $condicao . ') { $ret = true; } else { $ret = false; }';
+ if ($condicao != "") {
+ if ($debug) { echo " " . $fcondicao ; }
+ eval($fcondicao);
+ } else {
+ $ret = false;
+ }
+ return $ret;
+ }
+
+}
+
+?>
Index: /trunk/workflow/inc/report/includes/classes/Formulario.class.php
===================================================================
--- /trunk/workflow/inc/report/includes/classes/Formulario.class.php (revision 5307)
+++ /trunk/workflow/inc/report/includes/classes/Formulario.class.php (revision 5307)
@@ -0,0 +1,1313 @@
+
+ * @since 25/05/2009
+ *
+ * @package Formulario
+ */
+
+include 'FormularioHtml.class.php';
+include 'FormularioUtil.class.php';
+if (file_exists("../../xajax/xajax.inc.php")) { include_once "../../xajax/xajax.inc.php"; }
+if (file_exists("../../../xajax/xajax.inc.php")) { include_once "../../../xajax/xajax.inc.php"; }
+
+class Formulario {
+
+ /**
+ * FormularioUtil - Instï¿œncia da Classe Formulï¿œrio Util.
+ */
+ public $util = FormularioUtil;
+
+ /**
+ * Array de FormularioHtml do Formulï¿œrio
+ */
+ private $_arrinputs = array();
+
+ /**
+ * Array de funᅵᅵes em Xajax.
+ */
+ private $_arrxajax = array();
+
+ /**
+ * Array de Querys em ajax.
+ */
+ private $_arrxajaxquery = array();
+
+ /**
+ * Array de arquivos que vieram por upload.
+ */
+ private $_arrfilesuploaded = array();
+
+ /**
+ * Array de Quadros pertencentes ao formulï¿œrio.
+ */
+ private $_arrquadros = array();
+ /**
+ * Array de Campos Agrupados.
+ */
+ private $_agruparcampos = array();
+ /**
+ * Array de Campos que Jᅵ foram Desenhados na tela,
+ * Utilizado para evitar que o mesmo campo seja desenhado duas vezes.
+ */
+ private $_desenhou = array();
+ /**
+ * Nome do Formulï¿œrio.
+ */
+ private $_nomeform;
+ /**
+ * Action do Formulï¿œrio.
+ */
+ private $_action;
+ /**
+ * Mï¿œtodo do Formulï¿œrio.
+ */
+ private $_method;
+ /**
+ * Valor do Onsubmit do formulï¿œrio.
+ */
+ private $_onsubmit;
+ /**
+ * Armazena o Cï¿œdigo HTML A ser impresso na tela.
+ */
+ //private $_htmlForm;
+
+ private $html;
+
+ /**
+ * A funᅵᅵo desenhar() jᅵ foi chamada?.
+ */
+ private $_desenhado = false;
+
+ /**
+ * ᅵ um formulᅵrio de Upload de arquivos?.
+ */
+ private $_isupload = false;
+
+ /**
+ * Depuraᅵᅵo de Cᅵdigo ativada?
+ */
+ private $_debug = true;
+
+ private $_iscachedform = false;
+
+ /**
+ * Array com os erros do debug.
+ */
+ private $_errors = array();
+
+ private $_microtime;
+
+ private $inputDisplayOptions = array("open_tr" => true,
+ "open_td" => true,
+ "open_td_colspan" => 1,
+ "makedivision" => true,
+ "close_td" => true,
+ "close_tr" => true);
+
+ private $FirstGroupColsDisplayOptions = array("open_tr" => true,
+ "open_td" => true,
+ "open_td_colspan" => 1,
+ "makedivision" => true,
+ "close_td" => false,
+ "close_tr" => false);
+
+ private $FirstGroupDisplayOptions = array("open_tr" => true,
+ "open_td" => true,
+ "open_td_colspan" => 100,
+ "makedivision" => true,
+ "close_td" => false,
+ "close_tr" => false);
+
+ private $InputGroupDisplayOptions = array("open_tr" => false,
+ "open_td" => false,
+ "open_td_colspan" => 1,
+ "makedivision" => false,
+ "close_td" => false,
+ "close_tr" => false);
+
+ private $InputGroupColsDisplayOptions = array("open_tr" => false,
+ "open_td" => true,
+ "open_td_colspan" => 1,
+ "makedivision" => true,
+ "close_td" => false,
+ "close_tr" => false);
+
+ private $ButtonDisplayOptions = array("open_tr" => false,
+ "open_td" => false,
+ "makedivision" => false,
+ "close_td" => false,
+ "close_tr" => false);
+
+ /**
+ * Instancia uma nova Interface de Formulï¿œrio
+ *
+ * @param string $name Nome
+ * @param string $action Action
+ * @param string $method Mï¿œtodo
+ * @param string $onsubmit Funᅵᅵo Javascript do OnSubmit
+ * @return void
+ */
+ function Formulario($name = "frmpadrao",$action = "",$method = "post",$onsubmit = "") {
+ $this->Interface = new FormularioHtml();
+ $this->setForm($name);
+ $this->setAction($action);
+ $this->setMethod($method);
+ $this->setOnSubmit($onsubmit);
+ $this->util = new FormularioUtil();
+ // $microtime = microtime(true);
+ $microtime = rand(0,900);
+ $this->microtime = $microtime;
+ $this->adicionarHidden($name . "_pkey",$microtime);
+ // $this->adicionarHidden($name . "_lastpkey",$_POST[$name . "_pkey"]);
+ }
+
+ /**
+ * Verifica se o ID passado jᅵ foi adicionado como sendo um campo do formulᅵrio.
+ *
+ * @param string $idinput ID Input
+ * @return void
+ */
+ protected function isInput($idinput) {
+ if ($idinput != "") {
+ $achou = false;
+ foreach ($this->_arrinputs as $input) {
+ if ($input->getName() == $idinput)
+ $achou = true;
+ }
+ } else {
+ $achou = true;
+ }
+ return $achou;
+ }
+
+ /**
+ * Retorna o Input para o ID passado.
+ *
+ * @param string $idinput ID Input
+ * @param boolean $retornaposicao Retorna a posiᅵᅵo do input no _arrinputs.
+ * @return void
+ */
+ protected function getInput($idinput,$retornaposicao = false) {
+ if ($idinput != "") {
+ $achou = "-1";
+ $i = 0;
+ foreach ($this->_arrinputs as $input) {
+
+ if ($input->getName() == $idinput) {
+ if ($retornaposicao) {
+ $achou = $i;
+ } else {
+ $achou = $input;
+ }
+ }
+ $i = i + 1;
+ }
+ } else {
+ $achou = "-1";
+ }
+ return $achou;
+ }
+
+ /**
+ * Agrupar Campos em um Formulï¿œrio
+ *
+ * Posiciona Campos um lado do outro em um formulï¿œrio, em uma mesma linha sem criar divisï¿œes nas tabelas.
+ *
+ * Exemplo:
+ *
+ * $form->adicionarCampo("nome",(.....));
+ * $form->adicionarCampo("cpf",(.....));
+ * $form->adicionarCampo("rg",(.....));
+ * $form->agruparCampos("nome,cpf,rg");
+ *
+ *
+ * @param string $campos Nome dos Campos a serem Agrupados, Separados por vï¿œrgula.
+ */
+ function agruparCampos($camposagrupados,$colunas = true) {
+ $arrcampos1 = explode(";",$camposagrupados);
+ foreach ($arrcampos1 as $campos) {
+ $arrcampos = explode(",",$campos);
+ $agcampos = array($arrcampos[0] => $arrcampos);
+
+ //VERIFICA SE O CAMPO Jᅵ FOI ADICIONADO E A ORDEM QUE FOI ADICIONADO AO FORMULᅵRIO.
+ if ($this->_debug) {
+ //$achouprimeiro = false;
+ foreach ($arrcampos as $idcampo) {
+
+ /* if ($achouprimeiro) {
+ if (in_array($idcampo,$this->desenhou)) {
+ $this->adicionarErro("agruparCampos() ID: " . $idcampo . " achou.",false);
+ }
+ }
+ if ($idcampo == $arrcampos[0]) {
+ $achouprimeiro = true;
+ } */
+ if ((!$this->isInput($idcampo)) && ($idcampo != "")) {
+ $this->adicionarErro("agruparCampos() ID: " . $idcampo . " nᅵo ᅵ um campo no formulᅵrio.",false);
+ }
+ }
+ }
+
+ $agcampos["colunas"] = $colunas;
+ array_push($this->_agruparcampos,$agcampos);
+ }
+ }
+
+ /**
+ * Adiciona um Quadro ao Formulï¿œrio
+ *
+ * $campos ᅵ opcional, SOMENTE quando sᅵ existe um quadro para o Formulᅵrio, a classe automaticamente entende que ᅵ todos os campos que jᅵ foram adicionados.
+ *
+ * @param string $idquadro Id do Quadro
+ * @param string $titulo Tï¿œtulo do Quadro
+ * @param string $campos Campos que Pertencerï¿œo ao Quadro (separados por vï¿œrgula)
+ */
+ function adicionarQuadro($idquadro,$titulo = "",$campos = "") {
+ $arrcampos = explode(",",$campos);
+ if ($this->_debug) {
+ if (is_array($this->_arrquadros[$idquadro])) {
+ $this->adicionarErro("adicionarQuadro() ID: $idquadro jᅵ foi adicionado no formulᅵrio.");
+ }
+ foreach ($arrcampos as $campo) {
+ if ($this->isInputInQuadro($campo)) {
+ $this->adicionarErro("adicionarQuadro() ID: $campo jᅵ foi adicionado a outro quadro neste formulᅵrio.");
+ }
+ if (!$this->isInput($campo)) {
+ $this->adicionarErro("adicionarQuadro() ID: $campo NᅵO estᅵ adicionado no formulᅵrio.");
+ }
+ }
+ }
+
+ if ($campos == "") {
+ $arrcampos = $this->montaArrayQuadroCampos($idquadro);
+ }
+
+ $quadro = array("idquadro" => $idquadro,"titulo" => $titulo, "campos" => $arrcampos,"botoes" => array());
+ $this->_arrquadros[$idquadro] = $quadro;
+ }
+
+ /**
+ * Funᅵᅵo interna para verificar se um Input jᅵ foi adicionado em algum quadro.
+ *
+ * @param string $idinput Id do Input
+ * @return boolean
+ */
+ protected function isInputInQuadro($idinput) {
+ $ret = false;
+ foreach ($this->_arrquadros as $quadro) {
+ if (in_array($idinput,$quadro['campos'])) {
+ $ret = true;
+ }
+ }
+ return $ret;
+ }
+
+ public function setCachedForm($value) {
+ $this->_iscachedform = $value;
+ }
+
+ /**
+ * Adiciona um Botᅵo ao Rodapᅵ de um Quadro do Formulᅵrio
+ *
+ * @param string $idquadro Id do Quadro
+ * @param string $idbutton Id do Botï¿œo
+ */
+ function adicionarQuadroButton($idquadro,$idbutton) {
+ if (!is_array($this->_arrquadros[$idquadro])) {
+ $erro = true;
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarQuadroButton() ID: $idquadro NᅵO estᅵ adicionado no formulᅵrio.");
+ }
+ }
+ if (!$this->isInput($idbutton)) {
+ $erro = true;
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarQuadroButton() ID: $idbutton NᅵO ᅵ um campo no formulᅵrio.");
+ }
+ }
+ if (!$erro) {
+ foreach ($this->_arrinputs as $input) {
+ if ($input->getName() == $idbutton) {
+ array_push($this->_arrquadros[$idquadro]["botoes"],$input);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adiciona Campo
+ *
+ * Funᅵᅵo para adicionar campos no formulᅵrio, permite vᅵrios formatos de tipo.
+ *
+ * tipo: text,data,periodo,moeda,cpf,cnpj,hidden,button
+ *
+ * @param string $name
+ * @param string $tipo
+ * @param string $label
+ * @param string $title
+ * @param string $value
+ * @param string $obrigatorio
+ * @param string $width
+ * @param string $maxlenght
+ * @param string $inforight
+ * @return void
+ */
+ function adicionarCampo($name,$tipo,$label,$title,$value = "",$obrigatorio = false,$width = "30",$maxlenght = "100",$inforight = "") {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setTipo($tipo);
+ $iface->setName($name);
+ $valores = explode("|",$value);
+ $iface->setValue(str_replace("\'","'",$valores[0]));
+ $iface->setValueAux(str_replace("\'","'",$valores[1]));
+ $iface->setTitle($title);
+ $iface->setLabel($label);
+ $iface->setObrigatorio($obrigatorio);
+ $iface->setSize($width,$maxlenght);
+ $iface->setInfoRight($inforight);
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarCampo() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+ /**
+ * Adiciona Campo Hidden
+ *
+ * Funᅵᅵo para adicionar campos hidden no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $value Valor do Campo
+ * @return void
+ */
+ function adicionarHidden($name,$value) {
+ $this->adicionarCampo($name,"hidden",$name,"",$value);
+ }
+
+ /**
+ * Adiciona Arquivo
+ *
+ * Funᅵᅵo para adicionar campos file no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $value Valor do Campo
+ * @return void
+ */
+ function adicionarUploadArquivo($name,$label,$pasta,$prefixo,$obrigatorio = false,$force = false) {
+ $this->_isupload = true;
+ $this->adicionarCampo($name,"file",$label,$pasta,$prefixo,$obrigatorio,$force);
+ }
+
+ /**
+ * Adiciona Campo Select
+ *
+ * Funᅵᅵo para adicionar campos select no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $label Label do Campo
+ * @param string $title Tï¿œtulo do Campo
+ * @param string $value Valor Prᅵ-Selecionado
+ * @param array $data Array com Conteï¿œdo do Select. Veja: $IUtils->MontaArraySelect();
+ * @param boolean $obrigatorio Campo Obrigatï¿œrio
+ * @param string $textoescolha Adiciona um Option com value = '' com o Texto passado na variï¿œvel.
+ * @param string $width Tamanho em pixels do Select
+ * @param string $height Altura em Linhas do Select (Usado para Mï¿œltiplos Campos)
+ * @param boolean $multiplo Indica se pode haver mais de um item selecionado.
+ * @return void
+ */
+ function adicionarSelect($name,$label,$title,$value,$data,$obrigatorio = false,$textoescolha = "",$width = "100",$height = "1",$multiplo = false,$selectCor = "",$arrCores = "") {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setName($name);
+ $iface->setValue($value);
+ $iface->setTitle($title);
+ $iface->setValuesSelect($data);
+ $iface->setSize($width,$height);
+ $mostraescolha = true;
+ if ($textoescolha == "") {
+ $mostraescolha = false;
+ }
+ $iface->setMultiplo($multiplo);
+ $iface->setSelectEscolha($mostraescolha, $textoescolha);
+ $iface->setLabel($label);
+ $iface->setObrigatorio($obrigatorio);
+ $iface->setTipo("select");
+
+ if ($selectCor != "") {
+ $iface->setValuesSelectCor($selectCor,$arrCores);
+ }
+
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarSelect() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+ /**
+ * Adiciona Campo CheckBox
+ *
+ * Funᅵᅵo para adicionar campos chekcbox no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $label Label do Campo
+ * @param string $value Valor Prᅵ-Selecionado
+ * @param array $data Array com Conteï¿œdo do CheckBox.
+ * @param boolean $obrigatorio Campo Obrigatï¿œrio
+ * @return void
+ */
+ function adicionarCheckBox($name,$label,$data,$obrigatorio = false) {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setName($name);
+ $iface->setValuesChecks($data);
+ $iface->setLabel($label);
+ $iface->setObrigatorio($obrigatorio);
+ $iface->setTipo("checkbox");
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarCheckBox() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+ /**
+ * Adiciona Campo Radios
+ *
+ * Funᅵᅵo para adicionar campos radios no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $label Label do Campo
+ * @param string $value Valor Prᅵ-Selecionado
+ * @param array $data Array com Conteï¿œdo do CheckBox.
+ * @param boolean $obrigatorio Campo Obrigatï¿œrio
+ * @return void
+ */
+ function adicionarRadio($name,$label,$data,$obrigatorio = false) {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setName($name);
+ $iface->setValuesRadio($data);
+ $iface->setLabel($label);
+ $iface->setObrigatorio($obrigatorio);
+ $iface->setTipo("radio");
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarRadio() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+ /**
+ * Adiciona Campo TextArea
+ *
+ * Funᅵᅵo para adicionar campos TextArea no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $label Label do Campo
+ * @param string $value Valor Prᅵ-Selecionado
+ * @param boolean $obrigatorio Campo Obrigatï¿œrio
+ * @param string $cols Colunas
+ * @param string $rows Linhas
+ * @return void
+ */
+ function adicionarTextarea($name,$label,$value,$obrigatorio = false,$cols = "80",$rows = "6") {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setName($name);
+ $iface->setLabel($label);
+ $iface->setObrigatorio($obrigatorio);
+ $iface->setValue(str_replace("\'","'",$value));
+ $iface->setSize($cols,$rows);
+ $iface->setTipo("textarea");
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarTextarea() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+ /**
+ * Adiciona Botï¿œo
+ *
+ * Funᅵᅵo para adicionar campos Button no formulᅵrio.
+ *
+ * @param string $name Nome do Campo
+ * @param string $value Valor
+ * @return void
+ */
+ function adicionarButton($name,$value) {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $iface->setName($name);
+ //$iface->setLabel($label);
+ $iface->setValue(str_replace("\'","'",$value));
+ $iface->setTipo("button");
+ if ($this->isInput($name)) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarButton() ID: $name foi adicionado duas vezes ao formulï¿œrio. Remova um campo ou altere seu ID.");
+ }
+ } else {
+ array_push($this->_arrinputs,$iface);
+ }
+ }
+
+
+ /**
+ * Adiciona Botï¿œo SUBMIT
+ *
+ * Funᅵᅵo para adicionar SUBMIT no formulᅵrio.
+ *
+ * @param string $idquadro ID do Quadro
+ * @param string $name Nome do Campo
+ * @param string $value Valor
+ * @param string $acao Aᅵᅵo de Submit
+ * @return void
+ */
+ function adicionarSubmit($idquadro,$name,$value,$acao) {
+ $erro = false;
+ if (!is_array($this->_arrquadros[$idquadro])) {
+ if ($this->_debug) {
+ $this->adicionarErro("adicionarSubmit() Quadro: $idquadro nᅵo estᅵ adicionado no formulᅵrio.");
+ }
+ $erro = true;
+ }
+ if (!$erro) {
+ $this->adicionarButton($name,$value);
+ $this->adicionarCampoAcao($name,"onclick","valida(document." . $this->_nomeform . ",'" . $acao . "',true);");
+ $this->adicionarQuadroButton($idquadro,$name);
+ }
+ }
+
+ /**
+ * Adiciona Subtitulo
+ *
+ * Funᅵᅵo para adicionar Subtitulos no Formulᅵrio
+ *
+ * @param string $value Subtï¿œtulo
+ * @return void
+ */
+ function adicionarSubTitulo($value) {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $id = count($this->_arrinputs);
+ $iface->setName("iFace_subtitulo_" . $id);
+ $iface->setValue($value);
+ $iface->setTipo("subtitulo");
+ array_push($this->_arrinputs,$iface);
+ }
+
+ /**
+ * Adiciona um Div
+ *
+ * Funᅵᅵo para adicionar um Div no Formulᅵrio
+ *
+ * @param string $value Subtï¿œtulo
+ * @return void
+ */
+ function adicionarDiv($value) {
+ $iface = new FormularioHtml();
+ $iface->setForm($this->_nomeform);
+ $id = count($this->_arrinputs);
+ $iface->setName("iFace_div_" . $id);
+ $iface->setValue($value);
+ $iface->setTipo("div");
+ array_push($this->_arrinputs,$iface);
+ }
+
+ /**
+ * Altera o Nome do Formulï¿œrio
+ *
+ * @param string $name Nome do Formulï¿œrio
+ * @return void
+ */
+ protected function setForm($nome) {
+ $this->_nomeform = $nome;
+ }
+
+ /**
+ * Altera o Action do Formulï¿œrio
+ *
+ * @param string $action Action do Formulï¿œrio
+ * @return void
+ */
+ public function setAction($action) {
+ if ($action == "") { $action = $_SERVER['PHP_SELF']; }
+ $this->_action = $action;
+ }
+
+ /**
+ * Altera o Mï¿œtodo do Formulï¿œrio
+ *
+ * @param string $method Mï¿œtodo do Formulï¿œrio
+ * @return void
+ */
+ protected function setMethod($method) {
+ $this->_method = $method;
+ }
+
+ /**
+ * Altera o OnSubmit do Formulï¿œrio
+ *
+ * @param string $onsubmit OnSubmit do Formulï¿œrio
+ * @return void
+ */
+ protected function setOnSubmit($onsubmit) {
+ $this->_onsubmit = $onsubmit;
+ }
+
+ /**
+ * Escreve o Cï¿œdigo de Abertura do Formulï¿œrio.
+ *
+ * @return void
+ */
+ public function abreForm() {
+ echo "\n\n";
+ if ($this->_isupload) { $adicionarenctype = ' enctype="multipart/form-data"'; }
+ echo '";
+ }
+
+ /**
+ * Escreve o Cï¿œdigo de Abertura de um Quadro
+ *
+ * @param string $idquadro ID do quadro a ser Aberto
+ * @return void
+ */
+ public function escreveAbreQuadro($idquadro) {
+ if ($this->_arrquadros[$idquadro]["titulo"] != "") {
+ echo "\n\n
";
+ echo "\n\t\n\t\t" . $this->_arrquadros[$idquadro]["titulo"] . " \n\t \n\t\n\t\n\t ";
+ } else {
+ echo "\n\n
\n\t";
+ }
+ }
+
+ /**
+ * Escreve o Cï¿œdigo de Fechamento de um Quadro
+ *
+ * @param string $idquadro ID do quadro a ser Fechado
+ * @return void
+ */
+ public function escreveFechaQuadro($idquadro) {
+ echo "
\n\t" .
+ "\n\t \n";
+
+ if (count($this->_arrquadros[$idquadro]["botoes"])) {
+ echo "\t\n
+ \t\t\n";
+ foreach ($this->_arrquadros[$idquadro]["botoes"] as $botao) {
+ echo $botao->desenhaHtmlForm($this->ButtonDisplayOptions) . "";
+ array_push($this->_desenhou,$botao->getName());
+ }
+
+ echo " \n\t \n";
+ }
+
+
+ echo "
\n
+
\n";
+ }
+
+
+ /**
+ * Adiciona uma Aᅵᅵo Javascript para qualquer campo do formulᅵrio
+ *
+ * Exemplo:
+ *
+ * $form->adicionarCampo("nome",(...));
+ * $form->adicionarCampoAcao("nome","onclick","alert('onclick');");
+ * $form->adicionarCampoAcao("nome","onblur","alert('onblur');");
+ *
+ *
+ * Possï¿œveis valores para tipo:
+ * onclick, onchange, onblur, onmouseout, onmousemove, onkeydown, onkeypress, onkeyup
+ *
+ *
+ * @param string $name Nome do Campo
+ * @param string $tipo Tipo de Aᅵᅵo
+ * @param string $javascript Cï¿œdigo em JavaScript a ser Executado.
+ * @return void
+ */
+ public function adicionarCampoAcao($name,$tipo,$javascript) {
+ $i = 0;
+ if (!$this->isInput($name)) {
+ $this->adicionarErro("adicionarCampoAcao() ID: " . $name . " nᅵo ᅵ um campo no formulᅵrio.",false);
+ }
+ foreach ($this->_arrinputs as $input) {
+ $i = $i + 1;
+ if (is_object($this->_arrinputs[$i])) {
+ if ($this->_arrinputs[$i]->getName() == $name) {
+ $campo = $this->_arrinputs[$i];
+ $campo->adicionarEvento(strtolower($tipo),$javascript);
+ $this->_arrinputs[$i] = $campo;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Funᅵᅵo utilizada internamente para verificar se um botᅵo faz parte de um quadro.
+ *
+ * @param string $name Nome do Botï¿œo
+ * @return boolean
+ */
+ protected function isInRodapeQuadro($name) {
+ $ret = false;
+ foreach ($this->_arrquadros as $quadro) {
+ foreach ($quadro["botoes"] as $botoes) {
+ if ($botoes->getName() == $name) {
+ $ret = true;
+ }
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * Funᅵᅵo utilizada para Desenhar um campo do Formulᅵrio.
+ *
+ * @param string $name Nome do Botï¿œo
+ * @param boolean true $showtableRow Escreve a Divisï¿œo TR
+ * @param boolean treu $showtableDivision Escreve a Divisï¿œo TD
+ * @return boolean
+ */
+ public function desenhaCampo($name,$options = "") {
+ if ($options == "") { $options = $this->inputDisplayOptions; }
+ if (!is_object($name)) {
+ if (!in_array($name,$this->_desenhou)) {
+ foreach ($this->_arrinputs as $input) {
+ if ($input->getName() == $name) {
+ if (!$this->isInRodapeQuadro($input->getName())) {
+ echo $input->desenhaHtmlForm($options);
+ array_push($this->_desenhou,$input->getName());
+ }
+ }
+ }
+ } else {
+ $this->adicionarErro("desenhaCampo() Nᅵo ᅵ possᅵvel desenhar o ID: $name jᅵ foi desenhado no formulᅵrio.");
+ }
+ } else {
+ $input = $name;
+ if (!in_array($input->getName(),$this->_desenhou)) {
+ if (!$this->isInRodapeQuadro($input->getName())) {
+ echo $input->desenhaHtmlForm($options);
+ array_push($this->_desenhou,$input->getName());
+ }
+ } else {
+ //$this->adicionarErro("desenhaCampo() Nᅵo ᅵ possᅵvel desenhar o ID: " . $input->getName() . " jᅵ foi desenhado no formulᅵrio.");
+ }
+
+ }
+ }
+
+ /**
+ * Funᅵᅵo utilizada internamente para Desenhar campos Agrupados no Formulᅵrio.
+ *
+ * @param string $name Nome do Botï¿œo
+ * @param boolean true $colunas Escreve a Divisï¿œo TR
+ * @return void
+ */
+ protected function desenhaAgrupados($campo) {
+ foreach ($this->_agruparcampos as $campoagru) {
+ $colunas = $campoagru["colunas"];
+ if ($colunas) {
+ $firstDisplayGroups = $this->FirstGroupColsDisplayOptions;
+ $displaygroups = $this->InputGroupColsDisplayOptions;
+ } else {
+ $firstDisplayGroups = $this->FirstGroupDisplayOptions;
+ $displaygroups = $this->InputGroupDisplayOptions;
+ }
+ if (count($campoagru[$campo])) {
+ foreach ($this->_arrinputs as $input) {
+ if (in_array($input->getName(),$campoagru[$campo])) {
+ if ($input->getName() == $campo) {
+ echo $this->desenhaCampo($input,$firstDisplayGroups);
+
+ } else {
+
+ if ($this->_debug) {
+ if (in_array($input->getName(),$this->_desenhou)) {
+ $this->adicionarErro("Funᅵᅵo Interna desenhaAgrupados() Nᅵo ᅵ possᅵvel desenhar o ID: " . $input->getName() . " na posiᅵᅵo correta. O ID foi adicionado ao formulᅵrio antes da chave do agrupamento. Verifique a ordem de criaᅵᅵo dos campos agrupados, ou se o ID nᅵo foi adicionado a outro quadro.",true);
+ }
+ }
+ echo $this->desenhaCampo($input,$displaygroups);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Funᅵᅵo interna utilizada para montar o array de campos para um quadro quando nᅵo ᅵ informado nenhum campo no parᅵmetro campos na funᅵᅵo adicionarQuadro, asumindo assim que todos os campos restantes serᅵo adicionados nesse ᅵltimo quadro.
+ *
+ * @param string $idquadro ID do quadro a ser Desenhado.
+ * @return void
+ */
+ protected function montaArrayQuadroCampos($idquadro) {
+ $arrcampos = array();
+ foreach ($this->_arrinputs as $input) {
+ if (!$this->isInputInQuadro($input->getName())) {
+ //echo $input->getName() . " ";
+ array_push($arrcampos,$input->getName());
+ }
+ }
+ return $arrcampos;
+ //print_r($this->_arrquadros);
+ }
+
+ /**
+ * Funᅵᅵo utilizada para desenhar um quadro especᅵfico.
+ *
+ * @param string $idquadro ID do quadro a ser Desenhado.
+ * @return void
+ */
+ public function desenhaQuadro($idquadro) {
+
+
+
+ $quadro = $this->_arrquadros[$idquadro];
+ $this->escreveAbreQuadro($idquadro);
+
+
+ foreach ($this->_arrinputs as $input) {
+
+ //VERIFICA SE O CAMPO A SER DESENHADO PERTENCE AO QUADRO.
+ if (in_array($input->getName(),$quadro["campos"])) {
+ $desenhou = false;
+ //VERIFICA SE EXISTEM CAMPOS AGRUPADOS
+ if (count($this->_agruparcampos)) {
+ foreach ($this->_agruparcampos as $campoagru) {
+ if (count($campoagru[$input->getName()])) {
+ //CHAMA A FUNᅵᅵO PARA DESENHAR OS CAMPOS AGRUPADOS.
+ $this->desenhaAgrupados($input->getName());
+ $desenhou = true;
+ }
+ }
+ }
+
+ if (!$desenhou) {
+ //CASO Nï¿œO SEJAM CAMPOS AGRUPADOS DESENHA O CAMPO NORMAL.
+ echo $this->desenhaCampo($input,$this->inputDisplayOptions);
+ }
+ }
+ }
+ $strcampos = "";
+ foreach ($quadro["campos"] as $campo) {
+ $strcampos .= $campo . ",";
+ }
+ echo "$strcampos
";
+ $this->escreveFechaQuadro($idquadro);
+ }
+
+ /**
+ * Desenha todos os quadros e todos os campos do formulï¿œrio.
+ *
+ * @return void
+ */
+ public function desenhaCampos() {
+ $this->_desenhado = true;
+ foreach ($this->_arrquadros as $quadro) {
+ $this->desenhaQuadro($quadro["idquadro"]);
+ }
+ }
+
+ /**
+ * Desenha o Formulï¿œrio.
+ *
+ * @return void
+ */
+ function desenhar() {
+ if (!$this->_desenhado) {
+ $this->_desenhado = true;
+ ob_start();
+ $this->abreForm();
+ $this->desenhaCampos();
+ $this->fechaForm();
+ $html = ob_get_contents();
+ ob_end_clean();
+ $this->displayErros();
+ $this->html = $html;
+ echo $html;
+ } else {
+ $this->adicionarErro("desenhar() Formulᅵrio jᅵ foi Desenhado anteriormente.",true);
+ }
+ }
+
+ /**
+ * Altera o Valor do DEBUG para fazer Depuraᅵᅵo de Erros.
+ *
+ * @return void
+ */
+ function setDebug($value) {
+ $this->_debug = $value;
+ }
+
+
+ /**
+ * Verifica se o Formulᅵrio foi Enviado para a aᅵᅵo passada como parᅵmetro.
+ *
+ * Exemplo:
+ *
+ * if ($form->isSubmit("enviar")) {
+ * //executa a aᅵᅵo do botᅵo enviar.
+ * }
+ *
+ *
+ * @param string $acao Aᅵᅵo do Formulᅵrio.
+ * @return void
+ */
+ public function isSubmit($acao,$permitirf5 = false) {
+ if (!$this->_iscachedform) {
+ if ($this->_method == "post") {
+ $varacao = $_POST[$this->_nomeform . '_acao'];
+ } else {
+ $varacao = $_GET[$this->_nomeform . '_acao'];
+ }
+
+ $ret = true;
+
+ if ($this->_desenhado) {
+ $this->adicionarErro("isSubmit() Ordem da funᅵᅵo isSubmit deve estar antes do formulᅵrio ser desenhado.",true);
+ }
+
+
+ //VERIFICA SE O F5 FOI PRESSIONADO
+ //session_start();
+ if (!$permitirf5) {
+ $sesspkey = $_SESSION[$this->_nomeform . '_pkey'];
+ $postpkey = $_POST[$this->_nomeform . '_pkey'];
+ if ($postpkey != "") {
+ if ($postpkey != $sesspkey) {
+ //$this->adicionarErro("isSubmit() Impossᅵvel fazer aᅵᅵo, F5 pressionado.",false);
+ //$ret = false;
+ }
+ }
+ }
+
+ if ($ret) {
+ if ($varacao == $acao) {
+ if ($this->_isupload) {
+ include('UploadFile.class.php');
+ foreach ($this->_arrinputs as $input) {
+ if ($input->getTipo() == "file") {
+ $fname = $input->getName();
+ $pasta = $input->getTitle();
+ $prefixo = $input->getValue();
+ $force = $input->getWidth();
+ //echo $force;
+ $upload = new UploadFile($_FILES[$fname],$pasta, $prefixo, $force);
+ if($upload->doUpload() === true) {
+ $filename = $upload->getFileNomeFinal();
+ $this->_arrfilesuploaded[$fname] = array( "field" => $fname, "folder" => $pasta, "prefix" => $prefixo, "filename" => $filename, "completefilename" => $pasta . $filename);
+ } else {
+ echo $upload->getSysError();
+ echo $upload->getSysDebug();
+ }
+ }
+ }
+ }
+ $ret = true;
+ } else {
+ $ret = false;
+ }
+ }
+ }
+ return $ret;
+ }
+ /**
+ * Funᅵᅵo que retorna os arquivos que foram enviados e salvos por upload.
+ */
+ public function getFiles() {
+ return $this->_arrfilesuploaded;
+ }
+
+
+ /**
+ * Funᅵᅵo usada internamente para adicionar um erro ao formulᅵrio.
+ *
+ * @param string $msgerro Mensagem de Erro
+ * @param boolean $fatal Se ᅵ um erro Fatal = true ()
+ * */
+ protected function adicionarErro($msgerro,$fatal = false) {
+ if ($fatal) { $this->_errors = array(); }
+ $erro = array("msgerro" => $msgerro,"fatal" => $fatal);
+ array_push($this->_errors,$erro);
+
+ if ($fatal) {
+ $this->displayErros();
+ exit;
+ }
+
+ }
+
+
+ /**
+ * Funᅵᅵo usada para exibir os erros.
+ *
+ * */
+ public function displayErros() {
+ if ($this->_debug) {
+ if (count($this->_errors)) {
+ echo "";
+ echo "";
+ foreach ($this->_errors as $erro) {
+ echo "
";
+
+ if ($erro["fatal"]) {
+ $adicionarmsg = "ERRO FATAL: ";
+ } else {
+ $adicionarmsg = "ERRO: ";
+ }
+ echo $adicionarmsg . $erro["msgerro"];
+ echo "
";
+ }
+ echo "
";
+ }
+ }
+ }
+
+
+ /**
+ * Funᅵᅵo utilizada para Desenhar o XAJAX do formulᅵrio e as funᅵᅵes registradas.
+ */
+ public function desenhaXAjax() {
+
+
+
+ $ajax = new xajax("",$this->_nomeform . "_xajax_",'ISO-8859-1');
+ $ajax->decodeUTF8InputOn();
+
+
+
+
+ foreach ($this->_arrxajax as $xajax) {
+
+ $findInput = $this->getInput($xajax['idorigem']);
+
+ $sql = $this->getSQLXajaxQuery($xajax['idquery']);
+ $fparametros = '$' . $this->_arrxajaxquery[$xajax['idquery']]["parametros"];
+ $fparametros = str_replace(",",',$',$fparametros);
+
+ $camposquery = $this->_arrxajaxquery[$xajax['idquery']]["campos"];
+ $campos = explode(",",$camposquery);
+ //echo $camposquery;
+
+ if ($xajax['funcao'] == "redesenhar") {
+
+ $funcao = "";
+
+ if ($findInput->getTipo() == "select") {
+ $funcao =
+ 'function ' . $xajax['idfuncao'] . '(' . $fparametros . '){
+ $objResponse = new xajaxResponse("ISO-8859-1");
+ global $conn;
+ //$objResponse->AddAssign("img_' . $xajax['idcampo'] . '","style.display","");
+ $sql = "' . $sql . '";
+ $IUtils = new FormularioUtil();
+ $data = $IUtils->MontaArraySelect($conn,$sql,"' . $campos[0] .'","' . $campos[1] .'");
+ $iface = new FormularioHtml();
+ $iface->setForm("' . $this->_nomeform . '");
+ $iface->setName("' . $xajax['idorigem'] . '") ;
+ $iface->setValue("' . $findInput->getValue() . '");
+ $iface->setTitle("' . $findInput->getTitle() . '");
+ $iface->setValuesSelect($data);
+ $iface->setSize(' . $findInput->getWidth() . ',' . $findInput->getHeight() . ');
+ $mostraescolha = true;
+ $textoescolha = "' . $findInput->getSelectEscolhaValue() . '";
+ if ($textoescolha == "") {
+ $mostraescolha = false;
+ }
+ $iface->setMultiplo("' . $findInput->getMultiplo() . '");
+ $iface->setSelectEscolha($mostraescolha, $textoescolha);
+ $iface->setLabel("' . $findInput->getLabel() . '");
+ $iface->setObrigatorio("' . $findInput->getObrigatorio() .'");
+ $iface->setTipo("select");
+ $iface->select();
+ $div = $iface->getHtml();
+ $objResponse->AddAssign(\'span_id_' . $xajax['idorigem'] . '\',\'innerHTML\',$div);
+ //$objResponse->AddScript(\'sleep(5000);\');
+ //$objResponse->AddAssign("img_' . $xajax['idcampo'] . '","style.display","");
+ return $objResponse->getXML();
+ }';
+ }
+ if ($findInput->getTipo() == "checkbox") {
+ $funcao =
+ 'function ' . $xajax['idfuncao'] . '(' . $fparametros . '){
+ $objResponse = new xajaxResponse("ISO-8859-1");
+ global $conn;
+ $sql = "' . $sql . '";
+ $IUtils = new FormularioUtil();
+ $data = $IUtils->MontaArrayCheckBox($conn,$sql,"' . $campos[0] .'","' . $campos[1] .'");
+ $iface = new FormularioHtml();
+ $iface->setForm("' . $this->_nomeform . '");
+ $iface->setName("' . $xajax['idorigem'] . '") ;
+ $iface->setValuesChecks($data);
+ $iface->setLabel("' . $findInput->getLabel() . '");
+ $iface->setObrigatorio("' . $findInput->getObrigatorio() .'");
+ $iface->setTipo("checkbox");
+ $iface->checkbox();
+ $div = $iface->getHtml();
+ $objResponse->AddAssign(\'span_id_' . $xajax['idorigem'] . '\',\'innerHTML\',$div);
+ return $objResponse->getXML();
+ }';
+ }
+
+ if ($findInput->getTipo() == "radio") {
+ $funcao =
+ 'function ' . $xajax['idfuncao'] . '(' . $fparametros . '){
+ $objResponse = new xajaxResponse("ISO-8859-1");
+ global $conn;
+ $sql = "' . $sql . '";
+ $IUtils = new FormularioUtil();
+ $data = $IUtils->MontaArrayCheckBox($conn,$sql,"' . $campos[0] .'","' . $campos[1] .'");
+ $iface = new FormularioHtml();
+ $iface->setForm("' . $this->_nomeform . '");
+ $iface->setName("' . $xajax['idorigem'] . '") ;
+ $iface->setValuesRadio($data);
+ $iface->setLabel("' . $findInput->getLabel() . '");
+ $iface->setObrigatorio("' . $findInput->getObrigatorio() .'");
+ $iface->setTipo("radio");
+ $iface->radio();
+ $div = $iface->getHtml();
+ $objResponse->AddAssign(\'span_id_' . $xajax['idorigem'] . '\',\'innerHTML\',$div);
+ return $objResponse->getXML();
+ }';
+ }
+
+ //echo $funcao;
+
+ if ($funcao != "") {
+ eval($funcao);
+ }
+
+ }
+
+
+
+ }
+ foreach ($this->_arrxajax as $xajax) {
+ $ajax->registerFunction($xajax['idfuncao']); //38
+
+ if ($xajax['idquery'] != "") {
+ $parametros = $this->_arrxajaxquery[$xajax['idquery']]["valores"];
+ } else {
+ $parametros = $xajax["valores"];
+ }
+
+ $this->adicionarCampoAcao($xajax['idcampo'],$xajax['acao']," formUtilExibeImgAjax('" . $xajax['idorigem'] . "'); " . $this->_nomeform . "_xajax_" . $xajax['idfuncao'] . "(" . $parametros ."); setTimeout('formUtilOcultaImgAjax(\'" . $xajax['idorigem'] . "\')',3000); ");
+ }
+ $ajax->processRequests();
+ $ajax->printJavascript();
+ }
+
+
+ /**
+ * Funᅵᅵo Utilizada para adicionar ᅵ um campo especᅵfico uma funᅵᅵo em XAJAX declarada fora do formulᅵrio.
+ * Tambᅵm faz o registro a funᅵᅵo em XAJAX no formulᅵrio.
+ */
+ public function adicionarCampoXajax($idcampo,$acao,$idfuncao,$valores) {
+ $ajax = array( "idfuncao" => $idfuncao, "funcao" => "funcao", "idcampo" => $idcampo, "valores" => $valores, "acao" => $acao);
+ array_push($this->_arrxajax,$ajax);
+ }
+
+ /**
+ * Funᅵᅵo utilizada para Redesenhar um campo utilizando uma query em XAJAX.
+ */
+ public function adicionarXajaxRedesenhar($idorigem,$idquery,$idcampo,$acao) {
+ $rand = rand(0,999);
+ $nomefuncao = "redesenhar_" . $idorigem . "_" . $idcampo . "_" . $acao;
+ $ajax = array( "idfuncao" => $nomefuncao, "funcao" => "redesenhar", "idquery" => $idquery,"idorigem" => $idorigem,"idcampo" => $idcampo, "acao" => $acao);
+ array_push($this->_arrxajax,$ajax);
+ }
+
+ /**
+ * Funᅵᅵo utilizada Internamente para retornar o SQL formatado de uma query em XJAX.
+ */
+ protected function getSQLXajaxQuery($idquery) {
+ foreach ($this->_arrxajaxquery as $query) {
+ if ($query['idquery'] == $idquery) {
+ $fparametros = '$' . $query["parametros"];
+ $fparametros = str_replace(",",',$',$fparametros);
+ $arrparametros = explode(",",$query["parametros"]);
+ $sql = $query['sql'];
+ foreach ($arrparametros as $parametro) {
+ $sql = str_replace('{' . $parametro. '}','$' . $parametro,$sql);
+ }
+ }
+ }
+ return $sql;
+ }
+
+ /**
+ * Funᅵᅵo utilizada para adicionar uma Query em XAJAX ao formulᅵrio.
+ */
+ public function adicionarXajaxQuery($idquery,$sql,$campos,$parametros,$valores) {
+ $query = array( "idquery" => $idquery, "sql" => $sql, "campos" => $campos, "parametros" => $parametros,"valores" => $valores);
+ $this->_arrxajaxquery[$idquery] = $query;
+ }
+
+ public function getNome() {
+ return $this->_nomeform;
+ }
+
+ public function setInFormFieldsAsHidden($form) {
+ $form->adicionarHidden($this->_nomeform . "_acao",$_POST[$this->_nomeform . "_acao"]);
+ // $form->adicionarHidden($this->_nomeform . "_ordem",$_POST[$this->_nomeform . "_ordem"]);
+ // $form->adicionarHidden($this->_nomeform . "_ordemtipo",$_POST[$this->_nomeform . "_ordemtipo"]);
+ foreach ($this->_arrinputs as $input) {
+ $valor = "";
+ if ($_POST[$input->getName()]) {
+ $valor = $_POST[$input->getName()];
+ } else {
+ $valor = $_GET[$input->getName()];
+ }
+ $form->adicionarHidden($input->getName(),$valor);
+ }
+ return $form;
+ }
+
+}
+
+
+?>
Index: /trunk/workflow/inc/report/includes/classes/FormularioInput.class.php
===================================================================
--- /trunk/workflow/inc/report/includes/classes/FormularioInput.class.php (revision 5307)
+++ /trunk/workflow/inc/report/includes/classes/FormularioInput.class.php (revision 5307)
@@ -0,0 +1,366 @@
+
+/**
+ * FormularioInput
+ *
+ * Implementação de Formulários Padrões do Sistema.
+ * @author Jair Pereira
+ */
+
+class FormularioInput {
+
+ protected $html;
+ protected $tipo;
+ protected $name;
+ protected $value;
+ protected $valueAux;
+ protected $title;
+ protected $form;
+ protected $valuesSelect;
+ protected $selectEscolha;
+ protected $selectEscolhaValue;
+ protected $valuesChecks;
+ protected $valuesRadio;
+ protected $width;
+ protected $height;
+ protected $multiple;
+ protected $inforight;
+ protected $obrigatorio;
+ protected $selectCor;
+ protected $selectValuesCor = array();
+ public $arreventos = array();
+
+ //$this->value
+ function input(){
+ $this->html = '';
+ $addeventos = $this->getHtmlEventos();
+ switch($this->tipo){
+ case 'periodo' :
+ $this->adicionarEvento("onkeyup","formatar(this,'@@/@@/@@@@'); validarPeriodo(document." . $this->form . "." . $this->name . "_inicio,document." .$this->form . "." . $this->name . "_fim);");
+ $this->adicionarEvento("onblur","revalidar(this,'@@/@@/@@@@','data'); validarPeriodo(document." . $this->form . "." . $this->name . "_inicio,document." .$this->form . "." . $this->name . "_fim);");
+ $addeventos = $this->getHtmlEventos();
+ echo ' ';
+ echo ' ';
+ echo ' a ' ;
+ echo ' ' ;
+ echo ' ';
+ break;
+ case 'data' :
+ $this->adicionarEvento("onkeyup","formatar(this,'@@/@@/@@@@'); validarPeriodo(document." . $this->form . "." . $this->name . "_inicio,document." .$this->form . "." . $this->name . "_fim);");
+ $this->adicionarEvento("onblur","revalidar(this,'@@/@@/@@@@','data'); validarPeriodo(document." . $this->form . "." . $this->name . "_inicio,document." .$this->form . "." . $this->name . "_fim);");
+ $addeventos = $this->getHtmlEventos();
+ echo ' ';
+ echo ' ';
+ break;
+
+ case 'moeda' :
+ $this->adicionarEvento("onkeyup","milhar(this);");
+ $this->adicionarEvento("onblur","revalidarMilhar(this);");
+ $addeventos = $this->getHtmlEventos();
+ echo ' '; break;
+ case 'cpf' :
+ $this->adicionarEvento("onkeyup","formatar(this,'@@@.@@@.@@@-@@');");
+ $this->adicionarEvento("onblur","revalidar(this,'@@@.@@@.@@@-@@','cpf');");
+ $addeventos = $this->getHtmlEventos();
+ echo ' '; break;
+ case 'cnpj' :
+ $this->adicionarEvento("onkeyup","formatar(this,'@@.@@@.@@@/@@@@-@@');");
+ $this->adicionarEvento("onblur","revalidar(this,'@@.@@@.@@@/@@@@-@@','cnpj');");
+ $addeventos = $this->getHtmlEventos();
+ echo ' '; break;
+
+ case 'hidden':echo ' '; break;
+
+ case 'int' :
+ $this->adicionarEvento("onkeyup","formatar(this,'@@@@@@@@@@@@@@@@@@');");
+ $this->adicionarEvento("onblur","revalidar(this,'@@@@@@@@@@@@@@@@@@');");
+ $addeventos = $this->getHtmlEventos();
+ echo ' ' . $this->inforight .' '; break;
+
+ default :
+
+ echo ' ' . $this->inforight .' ';
+ }
+
+ }
+
+ function subtitulo() {
+ echo "" . $this->value . " ";
+ }
+
+ function button() {
+ $addeventos = $this->getHtmlEventos();
+ echo " ";
+ }
+
+ function select(){
+ $selected = "";
+ $addeventos = $this->getHtmlEventos();
+ echo "\n\t\t\t";
+ if ($this->multiplo) { $addmultiplo = " MULTIPLE"; }
+ echo '';
+ echo "\n";
+ if($this->selectEscolha == true){
+ echo "\t\t\t" . $this->selectEscolhaValue . " ";
+ }
+ if(count($this->valuesSelect) > 0 ){
+ foreach($this->valuesSelect as $chave => $valor){
+ $selected = ("$chave" == "$this->value") ? ' selected="selected" ' : '';
+ echo "\t\t\t\t";
+ if (in_array($chave,$this->selectValuesCor)) {
+ $addstyle = ' style="color: '.$this->selectCor . ';"';
+ } else {
+ $addstyle = '';
+ }
+ echo '' . $valor . ' ';
+ echo "\n";
+ }
+ }
+ echo "\t\t\t
\n";
+ }
+
+
+ function checkbox(){
+ $selected = "";
+ $addeventos = $this->getHtmlEventos();
+ echo '';
+ if(count($this->valuesChecks) > 0 ){
+
+ echo "\n\t\t\n";
+
+ }
+ }
+
+ function radio(){
+ $selected = "";
+ $this->html = '';
+ $addeventos = $this->getHtmlEventos();
+ if(count($this->valuesRadio) > 0 ){
+ echo "\n\t\t\t";
+ }
+
+ }
+
+ function arquivo() {
+ $this->html = '';
+ $this->html = ' ';
+ }
+
+ function textArea(){
+ $this->html = '';
+ $addeventos = " " . $this->getHtmlEventos();
+ echo "";
+
+ }
+
+
+
+ function desenhaForm(){
+ return $this->html;
+ }
+ function setTipo($tipo){
+ $this->tipo = $tipo;
+ }
+ function setName($name){
+ $this->name = $name;
+ }
+ function setValue($value){
+ $this->value = "$value";
+ //echo $this->name . ": " . $this->value . " ";
+ }
+ function setValueAux($valueAux){
+ $this->valueAux = $valueAux;
+ }
+ function setTitle($title){
+ $this->title = $title;
+ }
+ function setInfoRight($info) {
+ $this->inforight = $info;
+ }
+ function setObrigatorio($obrigatorio){
+
+ if(strlen($obrigatorio)>1){
+ $this->obrigatorio = $obrigatorio;
+ return true;
+ }
+
+ switch($obrigatorio){
+ case true :
+ $this->obrigatorio = "";
+ break;
+ case false :
+ $this->obrigatorio = "not_";
+ break;
+ default :
+ $this->obrigatorio = "";
+ }
+ }
+
+
+ function setValuesSelect($arrayValores){
+ $this->valuesSelect = $arrayValores;
+ }
+ function getName() {
+ return $this->name;
+ }
+ function getValue() {
+ return $this->value;
+ }
+ function getWidth() {
+ return $this->width;
+ }
+ function getTipo() {
+ return $this->tipo;
+ }
+ function getObrigatorio() {
+ return $this->obrigatorio;
+ /*if ($this->obrigatorio == "not_") {
+ $ret = false;
+ } else {
+ $ret = true;
+ }
+ return $ret; */
+ }
+ function getHeight() {
+ return $this->height;
+ }
+ function getMultiplo() {
+ return $this->multiplo;
+ }
+ function getLabel() {
+ return $this->label;
+ }
+
+ function setValuesSelectCor($cor,$values) {
+ $this->selectValuesCor = $values;
+ $this->selectCor = $cor;
+ }
+
+ function getTitle() {
+ return $this->title;
+ }
+ function setForm($form){
+ $this->form = $form;
+ }
+ function getHtml() {
+ return $this->html;
+ }
+ function setSelectEscolha($escolha, $valor){
+ $this->selectEscolha = $escolha;
+ $this->selectEscolhaValue = $valor;
+ }
+ function getSelectEscolha() {
+ return $this->selectEscolha;
+ }
+ function getSelectEscolhaValue() {
+ return $this->selectEscolhaValue;
+ }
+
+ function setValuesChecks($arrValores){
+ $this->valuesChecks = $arrValores;
+ }
+ function setValuesRadio($arrValores){
+ $this->valuesRadio = $arrValores;
+ }
+
+ function setSize($tamanho1,$tamanho2 = "") {
+ $this->width = $tamanho1;
+ $this->height = $tamanho2;
+ }
+ function setMultiplo($multiplo) {
+ $this->multiplo = $multiplo;
+ }
+
+ function adicionarEvento($action,$javascript) {
+ $arrevt = array("action" => $action, "evento" =>$javascript);
+ array_push($this->arreventos,$arrevt);
+ }
+ function getHtmlEventos() {
+ $streventos = "";
+ foreach($this->arreventos as $evento) {
+ if ($evento["action"] == "onclick") {
+ $addonclick .= $evento["evento"];
+ }
+ if ($evento["action"] == "onchange") {
+ $addonchange .= $evento["evento"];
+ }
+ if ($evento["action"] == "onblur") {
+ $addonblur .= $evento["evento"];
+ }
+ if ($evento["action"] == "onmouseout") {
+ $addonmouseout .= $evento["evento"];
+ }
+ if ($evento["action"] == "onmousemove") {
+ $addonmousemove .= $evento["evento"];
+ }
+ if ($evento["action"] == "onkeydown") {
+ $addonkeydown .= $evento["evento"];
+ }
+ if ($evento["action"] == "onkeypress") {
+ $addonkeypress .= $evento["evento"];
+ }
+ if ($evento["action"] == "onkeyup") {
+ $addonkeyup .= $evento["evento"];
+ }
+ }
+ if ($addonclick != "") {
+ $streventos .= " OnClick=\" $addonclick \" ";
+ }
+ if ($addonchange != "") {
+ $streventos .= " OnChange=\" $addonchange \" ";
+ }
+ if ($addonmouseout != "") {
+ $streventos .= " OnMouseOut=\" $addonmouseout \" ";
+ }
+ if ($addonmousemove != "") {
+ $streventos .= " OnMouseMove=\" $addonmousemove \" ";
+ }
+ if ($addonkeypress != "") {
+ $streventos .= " OnKeyPress=\" $addonkeypress \" ";
+ }
+ if ($addonkeyup != "") {
+ $streventos .= " OnKeyUp=\" $addonkeyup \" ";
+ }
+ if ($addonkeydown != "") {
+ $streventos .= " OnKeyDown=\" $addonkeydown \" ";
+ }
+ if ($addonblur != "") {
+ $streventos .= " OnBlur=\" $addonblur \" ";
+ }
+ return $streventos;
+ }
+
+}
+?>
Index: /trunk/workflow/inc/report/includes/classes/DatabaseInfo.class.php
===================================================================
--- /trunk/workflow/inc/report/includes/classes/DatabaseInfo.class.php (revision 5307)
+++ /trunk/workflow/inc/report/includes/classes/DatabaseInfo.class.php (revision 5307)
@@ -0,0 +1,326 @@
+_dbhost = $dbhost;
+ $this->_dbuser = $dbuser;
+ $this->_dbpassword = $dbpassword;
+ $this->_dbname = $dbname;
+ $this->_parser = new SqlParser("");
+ $this->_conn = $this->conectar();
+ }
+
+ public function conectar() {
+ $connstring = "dbname=" . $this->_dbname . " host=" . $this->_dbhost . " user=" . $this->_dbuser . " password=" . $this->_dbpassword . "";
+ //echo $connstring;
+ $conn = pg_connect($connstring);
+ $this->_conn = $conn;
+
+ $this->_parser->bloquearPalavra("controle_acesso_banco",true);
+ $this->_parser->bloquearPalavra("controle_acesso_banco_usuarios",true);
+ $this->_parser->bloquearPalavra("controle_acesso_banco_historico",true);
+
+ //$this->bloquearFuncoes(true);
+
+ return $conn;
+ }
+
+ public function bloquearFuncoes($bloqueio) {
+ $res_funcoes = $this->getFuncoes();
+ while ($funcao = pg_fetch_object($res_funcoes)) {
+ $nome_funcao = $funcao->proname;
+ $this->_parser->bloquearPalavra($nome_funcao . "(",$bloqueio);
+ }
+ }
+
+ public function getErro() {
+ return $this->_sqlerror;
+ }
+
+ public function executar($sql,$transaction = true) {
+ $error = "";
+ $this->_sqlerror = "";
+
+ $this->_parser->setSql($sql);
+
+ $ret_parser = $this->_parser->verificaSql();
+
+ if ($ret_parser === false) {
+ $error = $this->_parser->getErro();
+ }
+
+ $sql = $this->_parser->getSql();
+ if ($error == "") {
+ if ($transaction) {
+ pg_query($this->_conn,"begin;");
+ }
+ $res = pg_query($this->_conn,$sql);
+ $error = pg_last_error($this->_conn);
+ if ($transaction) {
+ pg_query($this->_conn,"rollback;");
+ }
+
+ }
+ if ($error == "") {
+ return $res;
+ } else {
+ $this->_sqlerror = $error;
+ return false;
+ }
+ }
+
+ public function fetch_array($recordset){
+ return pg_fetch_array($recordset);
+ }
+
+ public function fetch_all($recordset) {
+ $process = array();
+ while ($rsatt = $this->fetch_array($recordset)){
+ $process[] = $rsatt;
+ }
+ return $process;
+ }
+
+ public function getDbIndices($schemaname,$tblname) {
+ $sqlstr = "select pg_get_indexdef(i.oid) as indice, x.indisprimary FROM pg_index x JOIN pg_class c ON c.oid = x.indrelid JOIN pg_class i ON i.oid = x.indexrelid WHERE c.relname=(select relname from pg_stat_user_tables where relname = '$tblname' and schemaname = '$schemaname') ";
+ $resu = $this->executar($sqlstr);
+ return $resu;
+ }
+
+ public function getDbConstraints($schemaname,$tblname) {
+ $sqlstr = "select pg_get_constraintdef(ct.oid) AS constraint FROM pg_class c inner join pg_catalog.pg_constraint ct ON (c.oid = ct.conrelid) WHERE c.relname=(select relname from pg_stat_user_tables where relname = '$tblname' and schemaname = '$schemaname')";
+ $resu = $this->executar($sqlstr);
+ return $resu;
+ }
+
+
+
+
+ public function getAttTable($schemaname,$tblname){
+
+ $sqlstr = "SELECT
+ pg_attribute.attnum AS index,
+ attname AS field,
+ typname AS type,
+ atttypmod-4 as length,
+ NOT attnotnull AS null,
+ adsrc AS def,
+ (select coalesce(d.description,'') as desc from pg_description d where d.objoid=attrelid and d.objsubid=attnum) as descricao_coluna
+ FROM
+ pg_attribute,
+ pg_class,
+ pg_type,
+ pg_attrdef
+ WHERE
+ pg_class.oid=attrelid
+ AND pg_type.oid=atttypid
+ AND attnum>0
+ AND pg_class.oid=adrelid
+ AND adnum=attnum
+ AND atthasdef='t'
+ AND lower(relname)= (select relname from pg_stat_user_tables where relname = '$tblname' and schemaname = '$schemaname')
+ UNION
+ SELECT
+ pg_attribute.attnum AS index,
+ attname AS field,
+ typname AS type,
+ atttypmod-4 as length,
+ NOT attnotnull AS null,
+ '' AS def,
+ (select coalesce(d.description,'') as desc from pg_description d where d.objoid=attrelid and d.objsubid=attnum) as descricao_coluna
+ FROM
+ pg_attribute,
+ pg_class,
+ pg_type
+ WHERE
+ pg_class.oid=attrelid
+ AND pg_type.oid=atttypid
+ AND attnum>0
+ AND atthasdef='f'
+ AND lower(relname)=(select relname from pg_stat_user_tables where relname = '$tblname' and schemaname = '$schemaname')
+ order by
+ index;";
+
+ //echo $sqlstr;
+ $resu = $this->executar($sqlstr);
+ //print_r($resu);
+ return $resu;
+ }
+
+ public function getDbViews($schemaname = "",$viewname = ""){
+ $add = "";
+ if ($schemaname != "") {
+ $add = " and schemaname ilike '%$schemaname%'";
+ }
+ if ($schemaname != "") {
+ $add .= " and viewname ilike '%$viewname%'";
+ }
+ $sqlstr = "select schemaname, viewname, definition from pg_views where schemaname not in ('information_schema','pg_catalog') $add ";
+ $resu = $this->executar($sqlstr);
+ //print_r($resu);
+ return $resu;
+ }
+
+ public function getQueries() {
+
+ $sql = "select datname, procpid, usename, query_start,
+ ( CASE WHEN client_addr is null then
+ 'LOCAL'
+ ELSE
+ client_addr::text
+ END) AS client_addr,
+ current_query,
+
+(to_char(((timeofday()::TIMESTAMP)-query_start),'hh24:mi:ss')||' -
+Inicio: '||to_char(query_start,'hh24:mi:ss') ) AS duracao,
+ ( CASE WHEN timeofday()::TIMESTAMP-query_start >
+INTERVAL '30 seconds' THEN
+ 'LENTA'
+ ELSE
+ 'NORMAL'
+ END) AS lentas,
+ ( CASE WHEN waiting = 't' THEN
+ 'SIM'
+ ELSE
+ 'NAO'
+ END) AS waiting
+ from pg_stat_activity
+ where current_query not ilike ''
+ order by query_start asc";
+
+ //$sql = "SELECT pg_stat_activity.datid, pg_stat_activity.datname, pg_stat_activity.procpid, pg_stat_activity.usesysid, pg_stat_activity.usename, pg_stat_activity.current_query, pg_stat_activity.query_start, pg_stat_activity.backend_start, pg_stat_activity.client_addr, pg_stat_activity.client_port FROM pg_stat_activity WHERE (pg_stat_activity.current_query <> ''::text) ORDER BY pg_stat_activity.query_start DESC;";
+ $resu = $this->executar($sql);
+ return $resu;
+ }
+
+ public function getDbTables() {
+
+ $sqlstr = "SELECT c.relname as tablename,
+
+ pg_catalog.pg_get_userbyid(c.relowner) AS dono,
+
+ pg_catalog.obj_description(c.oid, 'pg_class') AS comentario, reltuples::integer as registros,
+
+ (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=c.reltablespace) AS tablespace,
+ 'public' AS schemaname
+
+ FROM pg_catalog.pg_class c
+
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
+
+ WHERE c.relkind = 'r'
+
+ AND nspname='public'
+
+ ORDER BY c.relname";
+
+ $resu = $this->executar($sqlstr);
+ return $resu;
+ }
+
+ public function getFuncoes($funnome = '') {
+
+ if ($funnome != "") { $add .= " AND proname || '(' || pg_catalog.oidvectortypes(pg_proc.proargtypes) || ')' ilike '$funnome%' "; }
+
+
+ $sql = "select pg_proc.oid as oid, proname, nspname, pg_catalog.pg_get_userbyid(proowner) AS proowner, pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS procomment, pg_catalog.oidvectortypes(pg_proc.proargtypes) AS proarguments from pg_namespace,pg_proc where pg_proc.pronamespace=pg_namespace.oid and nspname in ('public','representacoes') $add order by nspname, proname; ";
+
+ $resu = $this->executar($sql);
+ return $resu;
+ }
+
+ public function getDbFuncao($funcao,$funnome = '') {
+
+ if ($funcao != "") { $add = " AND pc.oid = $funcao "; }
+ if ($funnome != "") { $add .= " AND proname || '(' || pg_catalog.oidvectortypes(pc.proargtypes) || ')' ilike '$funnome' "; }
+
+ $sqlstr = "SELECT
+ pc.oid AS prooid,
+ proname,
+ lanname as prolanguage,
+ pg_catalog.format_type(prorettype, NULL) as proresult,
+ prosrc,
+ probin,
+ proretset,
+ proisstrict,
+ provolatile,
+ prosecdef,
+ pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments,
+ proargnames AS proargnames,
+ pg_catalog.pg_get_userbyid(proowner) AS proowner,
+ pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment,
+ proname || '(' || pg_catalog.oidvectortypes(pc.proargtypes) || ')' as nomefuncao
+ FROM pg_catalog.pg_proc pc, pg_catalog.pg_language pl
+ WHERE
+ pc.prolang = pl.oid
+ $add
+ ";
+ $resu = $this->executar($sqlstr);
+ return $resu;
+ }
+
+ public function getDbFuncaoSrc($funoid = "",$funnome = "") {
+ $this->bloquearFuncoes(false);
+ $res_funcoes = $this->getDbFuncao($funoid,$funnome);
+
+ $textcontent = "";
+
+ if (pg_num_rows($res_funcoes)) {
+ $dados = $this->fetch_array($res_funcoes);
+
+ $textcontent = "
+-- Function: " . $dados["proname"]. "(" . $dados["proarguments"]. ")
+
+-- DROP FUNCTION " . $dados["proname"]. "(" . $dados["proarguments"]. ");
+
+CREATE OR REPLACE FUNCTION " . $dados["proname"]. "(" . $dados["proarguments"]. ") RETURNS " . $dados["proresult"]. " AS
+\$BODY\$";
+ $textcontent .= $dados["prosrc"];
+ $textcontent .= "\$BODY\$
+ LANGUAGE 'pltcl' VOLATILE
+ COST 100;
+ALTER FUNCTION " . $dados["proname"]. "(" . $dados["proarguments"]. ") OWNER TO " . $dados["proowner"].";";
+
+ if ($dados["procomment"] != "") {
+ $textcontent .= "
+COMMENT ON FUNCTION " . $dados["proname"]. "(" . $dados["proarguments"]. ") IS '" . $dados["procomment"] . "';";
+ }
+ }
+
+ return $textcontent;
+
+ }
+
+ public function getPrefixo($prefixo) {
+ $sqlstr = "select
+ relname AS tabela,
+ attname AS valor
+ from
+ pg_attribute,
+ pg_class
+ where
+ not attname in ('cmax','xmax','xmin','cmin','ctid','tableoid')
+ and attrelid=relfilenode
+ and relhaspkey
+ and (attname ilike '%$prefixo%' or relname ilike '%$prefixo%') order by relname, attname";
+ $resu = $this->executar($sqlstr);
+ return $resu;
+ }
+
+ function getDBTriggers() {
+ $sql = "select tgname, tgfoid, tgrelid from pg_trigger where substring(trim(tgname),0,4) != 'RI_' and substring(trim(tgname),0,4) != 'pg_' ";
+ $resu = $this->executar($sql);
+ return $resu;
+ }
+
+}
+
+?>
Index: /trunk/workflow/inc/report/includes/classes/ListagemIndicador.class.php
===================================================================
--- /trunk/workflow/inc/report/includes/classes/ListagemIndicador.class.php (revision 5307)
+++ /trunk/workflow/inc/report/includes/classes/ListagemIndicador.class.php (revision 5307)
@@ -0,0 +1,85 @@
+
+ *
+ */
+class ListagemIndicador {
+
+ private $idindicador;
+ private $tipo;
+ private $condicao;
+ private $codigoimagem;
+ private $legenda;
+ private $tamanho;
+ private $legendaarquivo;
+ private $_url_base_path;
+
+ public function ListagemIndicador($idindicador,$condicao = "",$tipo = "R",$codigoimagem = "1",$legenda = "",$legendaarquivo = "",$tamanho = "1") {
+ $this->idindicador = $idindicador;
+ $this->condicao = $condicao;
+ $this->tipo = $tipo;
+ $this->codigoimagem = $codigoimagem;
+ $this->legenda = $legenda;
+ $this->legendaarquivo = $legendaarquivo;
+ $this->tamanho = $tamanho;
+ $this->_url_base_path = "";
+ }
+
+ public function getLegenda() {
+ return $this->legenda;
+ }
+
+ public function setUrlBasePath($base_path) {
+ $this->_url_base_path = $base_path;
+ }
+
+ public function getIdIndicador() {
+ return $this->idindicador;
+ }
+
+ public function getTipo() {
+ return $this->tipo;
+ }
+
+ public function getCodigoImagem() {
+ return $this->codigoimagem;
+ }
+
+ protected function getFileName($fundo = false) {
+ if (strtoupper($this->tipo) == "R") { $pasta = $this->_url_base_path . "/images/indicadores/redondos/ap"; }
+ if (strtoupper($this->tipo) == "Q") { $pasta = $this->_url_base_path . "/images/indicadores/quadrados/ap"; }
+ if (strtoupper($this->tipo) == "T") { $pasta = $this->_url_base_path . "/images/indicadores/triangulares/ap"; }
+ if (strtoupper($this->tipo) == "I") { $pasta = $this->_url_base_path . "/images/icones/t"; }
+ if ($fundo) { $pasta = $pasta . "f"; }
+ if (strtoupper($this->tipo) != "I") {
+ if ($this->codigoimagem < 10) {
+ $nomeimagem = "ap0" . $this->codigoimagem . ".jpg";
+ } else {
+ $nomeimagem = "ap" . $this->codigoimagem . ".jpg";
+ }
+ $filename = $pasta ."/" . $nomeimagem;
+ } else {
+ $filename = $pasta . $this->tamanho . "/" . $this->codigoimagem . ".jpg";
+ }
+ if (!file_exists($filename)) {
+ $filename = str_replace("../../../","",$filename);
+ }
+ return $filename;
+ }
+
+ public function getLegendaArquivo() {
+ return $this->legendaarquivo;
+ }
+
+ public function getHtml($fundo = false) {
+ $file = $this->getFileName($fundo);
+ $html = " ";
+ return $html;
+ }
+ public function getCondicao() {
+ return $this->condicao;
+ }
+}
+?>
Index: /trunk/workflow/inc/report/includes/classes/FormularioHtml.class.php
===================================================================
--- /trunk/workflow/inc/report/includes/classes/FormularioHtml.class.php (revision 5307)
+++ /trunk/workflow/inc/report/includes/classes/FormularioHtml.class.php (revision 5307)
@@ -0,0 +1,124 @@
+
+/**
+ * FormularioHtml
+ *
+ * Implementação de Formulários Padrões do Sistema.
+ *
+ * @author Jair Pereira
+ */
+
+include 'FormularioInput.class.php';
+
+class FormularioHtml extends FormularioInput {
+ protected $htmlForm;
+ protected $label;
+ protected $widthlabel;
+ protected $widthinput;
+
+ function desenhaHtmlForm($options,$showTableDivision = true, $showTableRow = true){
+ switch($this->tipo){
+ case 'periodo' : $this->formInput($options); break;
+ case 'data' : $this->formInput($options); break;
+ case 'moeda' : $this->formInput($options); break;
+ case 'cpf' : $this->formInput($options); break;
+ case 'cnpj' : $this->formInput($options); break;
+ case 'input' : $this->formInput($options); break;
+ case 'select' : $this->formSelect($options); break;
+ case 'checkbox' : $this->formCheckBox($options); break;
+ case 'radio' : $this->formRadio($options); break;
+ case 'textarea' : $this->formTextArea($options); break;
+ case 'button' : $this->formButton($options); break;
+ case 'hidden' : $this->formHidden(false,false); break;
+ case 'subtitulo' : $this->formSubTitulo(); break;
+ case 'div' : $this->formDiv(); break;
+ case 'file' : $this->formArquivo($options); break;
+ default: $this->formInput($options);
+ }
+
+ return $this->htmlForm;
+ }
+ function makeDisplayHTML($options,$tipo = "input") {
+ $opentr = $options["open_tr"];
+ $opentd = $options["open_td"];
+ $makedivision = $options["makedivision"];
+ $makedivision_colspan = $options["makedivision_colspan"];
+ $open_td_colspan = $options["open_td_colspan"];
+ $closetd = $options["close_td"];
+ $closetr = $options["close_tr"];
+
+ if ($opentr) echo "\n\t";
+ if ($makedivision) {
+ if ($makedivision_colspan) $addcolspan = " colspan=" . $makedivision_colspan;
+ if ($this->widthlabel) { $addwidthlabel = " width='" . $this->widthlabel . "'"; }
+ echo "\n\t\t";
+ }
+ echo "". $this->label . " ";
+ if ($makedivision) echo " ";
+ if ($opentd) {
+ if ($open_td_colspan) $addcolspan2 = " colspan=" . $open_td_colspan;
+ if ($this->widthinput) { $addwidthinput = " width='" . $this->widthinput . "'"; }
+ echo "\n\t\t";
+ }
+
+ echo "\n\t\t\t";
+ if ($tipo == "input") { $this->input(); }
+ if ($tipo == "select") { $this->select(); }
+ if ($tipo == "checkbox") { $this->checkbox(); }
+ if ($tipo == "radio") { $this->radio(); }
+ if ($tipo == "textarea") { $this->textarea(); }
+ if ($tipo == "arquivo") { $this->arquivo(); }
+ if ($tipo == "button") { $this->button(); }
+ echo " ";
+ if ($closetd) echo "\n\t\t ";
+ if ($closetr) echo "\n\t \n";
+
+ return $this->htmlForm;
+ }
+
+ function formInput($options = array()){
+ //$this->input();
+ return $this->makeDisplayHTML($options);
+ }
+
+ function formSelect($options){
+ //$this->select();
+ return $this->makeDisplayHTML($options,"select");
+ }
+ function formCheckbox($options){
+ //$this->checkbox();
+ return $this->makeDisplayHTML($options,"checkbox");
+ }
+ function formRadio($options){
+ //$this->radio();
+ return $this->makeDisplayHTML($options,"radio");
+ }
+ function formHidden() {
+ echo "\n\t\t\t" . $this->input();
+ }
+ function formTextArea($options){
+ // $this->textArea();
+ return $this->makeDisplayHTML($options,"textarea");
+ }
+ function formButton($options){
+ //$this->button();
+ return $this->makeDisplayHTML($options,"button");
+ }
+ function formSubTitulo() {
+ echo "\n\t\t\n\t\n\t
\n\t\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t" . $this->value . " \n\t \n\t ";
+ }
+ function formDiv() {
+ echo "\n\t\t\n\t\n\t
\n\t\n\t\n\t
\n\t";
+ }
+ function formArquivo($options) {
+ //$this->arquivo();
+ return $this->makeDisplayHTML($options,"arquivo");
+ }
+ function setLabel($label){
+ $this->label = $label;
+ }
+
+}
+
+
+
+?>
Index: /trunk/workflow/inc/report/xajax_js/xajax.js
===================================================================
--- /trunk/workflow/inc/report/xajax_js/xajax.js (revision 5307)
+++ /trunk/workflow/inc/report/xajax_js/xajax.js (revision 5307)
@@ -0,0 +1,172 @@
+/* xajax Javascript library :: version 0.2.4 */
+Array.prototype.containsValue=function(valueToCheck){for(var i=0;i 1000)text=text.substr(0,1000)+"...\n[long response]\n...";try{if(this.debugWindow==undefined||this.debugWindow.closed==true){this.debugWindow=window.open('about:blank','xajax-debug','width=800,height=600,scrollbars=1,resizable,status');this.debugWindow.document.write('Xajax debug output Xajax debug output
');}
+text=text.replace(/&/g,"&")
+text=text.replace(//g,">")
+debugTag=this.debugWindow.document.getElementById('debugTag');debugTag.innerHTML=(''+(new Date()).toString()+' : '+text+' ')+debugTag.innerHTML;}catch(e){alert("Xajax Debug:\n "+text);}
+};this.workId='xajaxWork'+new Date().getTime();this.depth=0;this.responseErrorsForAlert=["400","401","402","403","404","500","501","502","503"];this.getRequestObject=function(){if(xajaxDebug)this.DebugMessage("Initializing Request Object..");var req=null;if(typeof XMLHttpRequest!="undefined")
+req=new XMLHttpRequest();if(!req&&typeof ActiveXObject!="undefined"){try{req=new ActiveXObject("Msxml2.XMLHTTP");}
+catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP");}
+catch(e2){try{req=new ActiveXObject("Msxml2.XMLHTTP.4.0");}
+catch(e3){req=null;}
+}
+}
+}
+if(!req&&window.createRequest)
+req=window.createRequest();if(!req)this.DebugMessage("Request Object Instantiation failed.");return req;}
+this.$=function(sId){if(!sId){return null;}
+var returnObj=document.getElementById(sId);if(!returnObj&&document.all){returnObj=document.all[sId];}
+if(xajaxDebug&&!returnObj&&sId!=this.workId){this.DebugMessage("Element with the id \""+sId+"\" not found.");}
+return returnObj;}
+this.include=function(sFileName){var objHead=document.getElementsByTagName('head');var objScript=document.createElement('script');objScript.type='text/javascript';objScript.src=sFileName;objHead[0].appendChild(objScript);}
+this.stripOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')==0){sEventName=sEventName.replace(/on/,'');}
+return sEventName;}
+this.addOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')!=0){sEventName='on'+sEventName;}
+return sEventName;}
+this.addHandler=function(sElementId,sEvent,sFunctionName){if(window.addEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').addEventListener('"+sEvent+"',"+sFunctionName+",false);");}
+else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"').attachEvent('"+sAltEvent+"',"+sFunctionName+",false);");}
+}
+this.removeHandler=function(sElementId,sEvent,sFunctionName){if(window.addEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').removeEventListener('"+sEvent+"',"+sFunctionName+",false);");}
+else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"').detachEvent('"+sAltEvent+"',"+sFunctionName+",false);");}
+}
+this.create=function(sParentId,sTag,sId){var objParent=this.$(sParentId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);if(objParent)
+objParent.appendChild(objElement);}
+this.insert=function(sBeforeId,sTag,sId){var objSibling=this.$(sBeforeId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling);}
+this.insertAfter=function(sAfterId,sTag,sId){var objSibling=this.$(sAfterId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
+this.getInput=function(sType,sName,sId){var Obj;if(!window.addEventListener){Obj=document.createElement(' ');}
+else{Obj=document.createElement('input');Obj.setAttribute('type',sType);Obj.setAttribute('name',sName);Obj.setAttribute('id',sId);}
+return Obj;}
+this.createInput=function(sParentId,sType,sName,sId){var objParent=this.$(sParentId);var objElement=this.getInput(sType,sName,sId);if(objParent&&objElement)
+objParent.appendChild(objElement);}
+this.insertInput=function(sBeforeId,sType,sName,sId){var objSibling=this.$(sBeforeId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode)
+objSibling.parentNode.insertBefore(objElement,objSibling);}
+this.insertInputAfter=function(sAfterId,sType,sName,sId){var objSibling=this.$(sAfterId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode){objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
+}
+this.remove=function(sId){objElement=this.$(sId);if(objElement&&objElement.parentNode&&objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement);}
+}
+this.replace=function(sId,sAttribute,sSearch,sReplace){var bFunction=false;if(sAttribute=="innerHTML")
+sSearch=this.getBrowserHTML(sSearch);eval("var txt=this.$('"+sId+"')."+sAttribute);if(typeof txt=="function"){txt=txt.toString();bFunction=true;}
+if(txt.indexOf(sSearch)>-1){var newTxt='';while(txt.indexOf(sSearch)>-1){x=txt.indexOf(sSearch)+sSearch.length+1;newTxt+=txt.substr(0,x).replace(sSearch,sReplace);txt=txt.substr(x,txt.length-x);}
+newTxt+=txt;if(bFunction){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
+else if(this.willChange(sId,sAttribute,newTxt)){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
+}
+}
+this.getFormValues=function(frm){var objForm;var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true)
+submitDisabledElements=true;var prefix="";if(arguments.length > 2)
+prefix=arguments[2];if(typeof(frm)=="string")
+objForm=this.$(frm);else
+objForm=frm;var sXml="";if(objForm&&objForm.tagName=='FORM'){var formElements=objForm.elements;for(var i=0;i < formElements.length;i++){if(!formElements[i].name)
+continue;if(formElements[i].name.substring(0,prefix.length)!=prefix)
+continue;if(formElements[i].type&&(formElements[i].type=='radio'||formElements[i].type=='checkbox')&&formElements[i].checked==false)
+continue;if(formElements[i].disabled&&formElements[i].disabled==true&&submitDisabledElements==false)
+continue;var name=formElements[i].name;if(name){if(sXml!='')
+sXml+='&';if(formElements[i].type=='select-multiple'){for(var j=0;j < formElements[i].length;j++){if(formElements[i].options[j].selected==true)
+sXml+=name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";}
+}
+else{sXml+=name+"="+encodeURIComponent(formElements[i].value);}
+}
+}
+}
+sXml+=" ";return sXml;}
+this.objectToXML=function(obj){var sXml="";for(i in obj){try{if(i=='constructor')
+continue;if(obj[i]&&typeof(obj[i])=='function')
+continue;var key=i;var value=obj[i];if(value&&typeof(value)=="object"&&this.depth <=50){this.depth++;value=this.objectToXML(value);this.depth--;}
+sXml+=""+key+" "+value+" ";}
+catch(e){if(xajaxDebug)this.DebugMessage(e.name+": "+e.message);}
+}
+sXml+=" ";return sXml;}
+this._nodeToObject=function(node){if(node.nodeName=='#cdata-section'){var data="";for(var j=0;j"+document.getElementsByTagName("HTML")[0].innerHTML+"