public function buscarProponentesVinculadosAction() { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); $get = Zend_Registry::get('get'); $idResponsavel = $get->idResponsavel; $arrBusca = array(); //$arrBusca['idUsuarioResponsavel = ?'] = $idResponsavel; $arrBusca['idUsuarioResponsavel = ?'] = $this->idUsuario; $arrBusca['sivinculo = ?'] = 1; //xd($arrBusca); $tblVinculo = new Vinculo(); $rsVinculo = $tblVinculo->buscar($arrBusca); //xd($rsVinculo->toArray()); $options = ""; $optionsTemp = ""; $idsProponente = 0; $tblAgente = new Agentes(); //==== MONTA COMBO COM TODOS OS PROPONENTES // foreach ($rsVinculo as $cahve => $valor) { //Descobrindo os dados do Agente/Proponente //$rsAgente = $tblAgente->buscar(array("idAgente = ? "=>$valor->idAgenteProponente))->current(); $rsProponente = $tblAgente->buscarAgenteNome(array("a.idAgente = ? " => $valor->idAgenteProponente))->current(); $cpfCnpj = $rsProponente->CNPJCPF; if (strlen($cpfCnpj) > 11) { $cpfCnpj = aplicaMascara($cpfCnpj, "99.999.999/9999-99"); } else { $cpfCnpj = aplicaMascara($cpfCnpj, "999.999.999-99"); } $optionsTemp .= "<option value='" . $rsProponente->idAgente . "'>" . $cpfCnpj . " - " . utf8_decode(htmlentities($rsProponente->Descricao)) . "</option>"; $idsProponente = $rsProponente->idAgente . ","; } //==== FIM MONTA COMBO COM TODOS OS PROPONENTES // //==== INCLUI NA COMBO O USUARIO LOGADO // $rsProponente = $tblAgente->buscarAgenteNome(array("a.idAgente = ? " => $idResponsavel))->current(); $cpfCnpj = $rsProponente->CNPJCPF; if (strlen($cpfCnpj) > 11) { $cpfCnpj = aplicaMascara($cpfCnpj, "99.999.999/9999-99"); } else { $cpfCnpj = aplicaMascara($cpfCnpj, "999.999.999-99"); } if (isset($rsProponente->idAgente)) { $optionsTemp .= "<option value='" . $rsProponente->idAgente . "'>" . $cpfCnpj . " - " . utf8_decode(htmlentities($rsProponente->Descricao)) . "</option>"; } //retira ultima virgula if (!empty($idsProponente)) { $idsProponente = substr($idsProponente, 0, strlen($idsProponente) - 1); } else { $idsProponente .= "," . $rsProponente->idAgente; } //==== FIM INCLUI NA COMBO O USUARIO LOGADO // if (isset($rsProponente->idAgente)) { $options .= "<option value='" . $idsProponente . "' selected>- TODOS -</option>"; } else { $options .= "<option value='' selected>- Nenhum Proponente encontrado -</option>"; } $options .= $optionsTemp; echo $options; }