Esempio n. 1
0
 /**
  * Grava registro. Se seja passado um ID ele altera um registro existente
  * @param array $dados - array com dados referentes as colunas da tabela no formato "nome_coluna_1"=>"valor_1","nome_coluna_2"=>"valor_2"
  * @return ID do registro inserido/alterado ou FALSE em caso de erro
  */
 public function salvar($dados)
 {
     //INSTANCIANDO UM OBJETO DE ACESSO AOS DADOS DA TABELA
     $tmpTblVinculo = new Vinculo();
     //DECIDINDO SE SERA FEITA UM INSERT OU UPDATE
     if (isset($dados['idVinculo'])) {
         $tmpRsVinculo = $tmpTblVinculo->find($dados['idVinculo'])->current();
     } else {
         $tmpRsVinculo = $tmpTblVinculo->createRow();
     }
     //ATRIBUINDO VALORES AOS CAMPOS QUE FORAM PASSADOS
     if (isset($dados['idAgenteResponsavel'])) {
         $tmpRsVinculo->idAgenteResponsavel = $dados['idAgenteResponsavel'];
     }
     if (isset($dados['idAgenteProponente'])) {
         $tmpRsVinculo->idAgenteProponente = $dados['idAgenteProponente'];
     }
     if (isset($dados['dtVinculo'])) {
         $tmpRsVinculo->dtVinculo = $dados['dtVinculo'];
     }
     if (isset($dados['dsEmailVinculo'])) {
         $tmpRsVinculo->dsEmailVinculo = $dados['dsEmailVinculo'];
     }
     if (isset($dados['stVinculo'])) {
         $tmpRsVinculo->stVinculo = $dados['stVinculo'];
     }
     if (isset($dados['tpVinculo'])) {
         $tmpRsVinculo->tpVinculo = $dados['tpVinculo'];
     }
     //echo "<pre>";
     //print_r($tmpRsVinculo);
     //SALVANDO O OBJETO CRIADO
     $id = $tmpRsVinculo->save();
     if ($id) {
         return $id;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 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;
 }