public function __construct(EntityManager $em, OrmPublicador $orm = null, $publicador = null) { parent::__construct("formPublicador"); $dao = $em->getRepository('Stj\\Entity\\OrmGrupo'); if ($publicador == null) { $lista = $dao->findAll(); } else { $lista = $dao->ListALL(FALSE, $publicador->getGrupo()->getCongregacao()); } $option = array(); $grupoarray = array(); $i = 0; $nomeCongregacao = ""; foreach ($lista as $key => $value) { $grupo = new OrmGrupo(); $grupo = $value; if ($nomeCongregacao != "") { if ($grupo->getCongregacao()->getNome() == $nomeCongregacao) { $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } else { $option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome()); $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } } else { $option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome()); $option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome(); } $nomeCongregacao = $grupo->getCongregacao()->getNome(); } /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtNome = new Element\Text("nome"); $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Publicador', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true')); /* * cmbGrupo */ $cmbGrupo = new Element\Select('grupo'); $cmbGrupo->setValueOptions($option); $cmbGrupo->setEmptyOption("Escolha o grupo"); $cmbGrupo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * cmbClasse */ $cmbClasse = new Element\Select('classe'); $cmbClasse->setValueOptions(array('OO' => 'Outra Ovelha', 'U' => 'Ungido')); $cmbClasse->setEmptyOption("Escolha a classe"); $cmbClasse->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * cmbSexo */ $cmbSexo = new Element\Select('sexo'); $cmbSexo->setValueOptions(array('M' => 'Masculino', 'F' => 'Feminino')); $cmbSexo->setEmptyOption("Escolha o sexo"); $cmbSexo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true')); /* * txtdataNascimento */ $txtNascimento = new Element\Text("nascimento"); $txtNascimento->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * txtdataEmissao */ $txtEmissao = new Element\Text("emissao"); $txtEmissao->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * txtTelefone */ $txtTelefone = new Element\Text("telefone"); $txtTelefone->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)1234-1234', 'max-length' => '13', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{4}-[0-9]{4}")); /* * txtCelular */ $txtCelular = new Element\Text("celular"); $txtCelular->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)12345-1234', 'max-length' => '14', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{5}-[0-9]{4}")); /* * txtCep */ $txtCep = new Element\Text("cep"); $txtCep->setAttributes(array('class' => 'form-control', 'placeholder' => 'XXXXXXXX', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]{2}[0-9]{3}[0-9]{3}$/', 'max-length' => '8')); /* * txtNumero */ $txtNumero = new Element\Text("numero"); $txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6')); /* * txtLogradouro */ $txtLogradouro = new Element\Text("logradouro"); $txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtComplemento */ $txtComplemento = new Element\Text("complemento"); $txtComplemento->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...')); /* * txtBairro */ $txtBairro = new Element\Text("bairro"); $txtBairro->setAttributes(array('class' => 'form-control')); /* * txtCidade */ $txtCidade = new Element\Text("cidade"); $txtCidade->setAttributes(array('class' => 'form-control')); /* * txtUf */ $txtUf = new Element\Text("uf"); $txtUf->setAttributes(array('class' => 'form-control', 'max-length' => '2')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtNome->setValue($orm->getNome()); $cmbGrupo->setValue($orm->getGrupo()->getId()); $cmbClasse->setValue($orm->getClasse()); $cmbSexo->setValue($orm->getSexo()); if ($orm->getDtNascimento() != "") { $txtNascimento->setValue($orm->getDtNascimento()->format('d-m-Y')); } if ($orm->getDtEmissao() != "") { $txtEmissao->setValue($orm->getDtEmissao()->format('d-m-Y')); } $txtTelefone->setValue($orm->getTel()); $txtCelular->setValue($orm->getCel()); $txtCep->setValue($orm->getCep()); $txtNumero->setValue($orm->getNumero()); $txtLogradouro->setValue($orm->getLogradouro()); $txtComplemento->setValue($orm->getComplemento()); $txtBairro->setValue($orm->getBairro()); $txtCidade->setValue($orm->getCidade()); $txtUf->setValue($orm->getUf()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtNome); $this->add($cmbGrupo); $this->add($cmbClasse); $this->add($cmbSexo); $this->add($txtNascimento); $this->add($txtEmissao); $this->add($txtTelefone); $this->add($txtCelular); $this->add($txtCep); $this->add($txtNumero); $this->add($txtLogradouro); $this->add($txtComplemento); $this->add($txtBairro); $this->add($txtCidade); $this->add($txtUf); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->add($cmbGrupo); $this->setAttributes(array('id' => 'form', 'action' => '/Publicador/Salvar', 'data-parsley-validate' => NULL)); }
public function __construct(EntityManager $em, OrmPublicador $tipoPrivilegio = null, OrmPrivilegios $orm = null) { parent::__construct("formPrivilegios"); // var_dump($option); // exit(); /* * txtID */ $txtId = new Element\Hidden("id"); /* * txtNome */ $txtDataInicio = new Element\Text("dataInicio"); $txtDataInicio->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10', 'required' => 'true')); $txtDataTermino = new Element\Text("dataTermino"); $txtDataTermino->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10')); /* * cmbPublicador */ $dao = $em->getRepository('Stj\\Entity\\OrmPublicador'); if (empty($tipoPrivilegio)) { $lista = $dao->findAll(); } else { $lista = $dao->ListALLWhere($tipoPrivilegio->getId()); } $option = array(); foreach ($lista as $key => $value) { $tipoPrivilegio = new OrmPublicador(); $tipoPrivilegio = $value; $option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome(); } $cmbPublicador = new Element\Select('publicador'); $cmbPublicador->setValueOptions($option); $cmbPublicador->setEmptyOption("Selecionar"); $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * cmbPrivilegio */ $dao = $em->getRepository('Stj\\Entity\\OrmTipoPrivilegios'); $lista = $dao->findAll(); $option = array(); foreach ($lista as $key => $value) { $tipoPrivilegio = new OrmTipoPrivilegios(); $tipoPrivilegio = $value; $option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome(); } $cmbPrivilegio = new Element\Select('privilegio'); $cmbPrivilegio->setValueOptions($option); $cmbPrivilegio->setEmptyOption("Selecionar"); $cmbPrivilegio->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true')); /* * Itoken */ $iToken = new Element\Csrf("iToken"); /* * btnSalvar */ $btnSalvar = new Element\Button('salvar'); $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * btnVoltar */ $btnVoltar = new Element\Button('voltar'); $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button')); /* * Preencher Componentes */ if ($orm != null) { $txtId->setValue($orm->getId()); $txtDataInicio->setValue($orm->getDataInicio() != "" ? $orm->getDataInicio()->format('d/m/Y') : ""); $txtDataTermino->setValue($orm->getDataTermino() != "" ? $orm->getDataTermino()->format('d/m/Y') : ""); $cmbPrivilegio->setValue($orm->getTipoPrivilegio()->getId()); $cmbPublicador->setValue($orm->getPublicador()->getId()); } // Adiciona componetes no form $this->add($txtId); $this->add($txtDataInicio); $this->add($txtDataTermino); $this->add($cmbPublicador); $this->add($cmbPrivilegio); $this->add($iToken); $this->add($btnSalvar); $this->add($btnVoltar); $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL)); }
/** * {@inheritDoc} */ public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::getId(); }