*/ 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 'Calendário...'; echo ' a ' ; echo '' ; echo 'Calendário...'; 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 'Calendário...'; 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 '
\n"; } function checkbox(){ $selected = ""; $addeventos = $this->getHtmlEventos(); echo ''; if(count($this->valuesChecks) > 0 ){ echo "\n\t\t"; echo "\n\t\t\n\t\t\t"; echo "\n\t\t
"; $i = 0; echo "\n\t\t\t
name . "'>"; foreach($this->valuesChecks as $valores){ //$class = ($class == 'tdc') ? 'tde' : 'tdc'; $selected = ($valores[2] == true) ? ' checked ' : ''; if (isset($_POST[$this->name])) { if (in_array($valores[0],$_POST[$this->name])) { $selected = "checked"; } } $i = $i + 1; echo "\n\t\t\t\t"; echo '' . $valores[1] ; echo "
"; } echo "\n\t\t\t
"; echo "\n\t\t
\n"; } } function radio(){ $selected = ""; $this->html = ''; $addeventos = $this->getHtmlEventos(); if(count($this->valuesRadio) > 0 ){ echo "\n\t\t\t
name . "'>"; echo "\n\t\t"; echo "\n\t\t\n\t\t\t"; echo "\n\t\t
"; foreach($this->valuesRadio as $valores){ $selected = ($valores[2] == true) ? ' checked ' : ''; echo "\n\t\t\t\t"; echo '" . $valores[1] ; echo "
\n"; } echo "\n\t\t
\n"; 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; } } ?>