public function alterar(PedidoEnderecoEntrega $end, Pedido $ligacao) { //parent::alterar($end); $where = "WHERE " . self::IDSESSAO . " = '" . $ligacao->getId() . "'"; $e = $end->getEstado(); if ($e->getId() <= 0) { $lE = new ListaEstados(); $lE->inserir($e); $end->setEstado($e); } $c = $end->getCidade(); if ($c->getId() <= 0) { $lC = new ListaCidades(); $lC->inserir($c); $end->setCidade($c); } else { $lC = new ListaCidades(); $lC->condicoes('', $c->getId(), ListaCidades::ID); if ($lC->getTotal() <= 0) { if ($c->getPais()->getId() <= 0) { $c->setPais($end->getPais()); } if ($c->getEstado()->getId() <= 0) { $c->setEstado($end->getEstado()); } $this->con->executar("INSERT INTO " . Sistema::$BDPrefixo . $lC->getTabela() . "(" . ListaCidades::ID . ", " . ListaCidades::PAIS . ", " . ListaCidades::ESTADO . ", " . ListaCidades::NOME . ", " . ListaCidades::DDD . ") VALUES('" . $c->getId() . "','" . $c->getPais()->getId() . "','" . $c->getEstado()->getId() . "','" . $c->nome . "','" . $c->ddd . "')"); $id = $this->con->getId(); $end->setCidade(new Cidade($id)); } } $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::LOGRADOURO, $end->logradouro, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::NUMERO, $end->numero, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::COMPLEMENTO, $end->complemento, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::BAIRRO, $end->bairro, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::CIDADE, $end->getCidade()->getId(), $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::ESTADO, $end->getEstado()->getId(), $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::PAIS, $end->getPais()->getId(), $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::CEP, $end->getCep(), $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::TIPO, $end->tipo, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::PRAZO, $end->prazo, $where); $this->con->alterar(Sistema::$BDPrefixo . $this->tabela, self::VALOR, $end->getValor()->formatar(), $where); }