public function listar($ordem = "ASC", $campo = self::ID) { $info = parent::listar($ordem, $campo); if (!empty($info)) { $temp = new Cidade($info[self::ID]); $temp->nome = $info[self::NOME]; $temp->ddd = $info[self::DDD]; $lP = new ListaPaises(); $lP->condicoes('', $info[self::PAIS], ListaPaises::ID); if ($lP->getTotal() > 0) { $temp->setPais($lP->listar()); } $lE = new ListaEstados(); $lE->condicoes('', $info[self::ESTADO], ListaEstados::ID); if ($lE->getTotal() > 0) { $temp->setEstado($lE->listar()); } return $temp; } }
public function loadCep() { if (!empty($this->cep)) { $arq = self::_GetEnderecoByCep($this->cep); if ((string) $arq["status"] == "false") { $arq = Arquivos::__OpenArquivo(self::$urlCep . $this->cep, true); } else { $arq = JSON::_Encode($arq); } if (!empty($arq)) { $json = JSON::_Decode($arq); if (!empty($json->root->logradouro)) { $this->logradouro = $json->root->logradouro; } if (!empty($json->root->bairro)) { $this->bairro = $json->root->bairro; } if (!empty($json->root->uf)) { $lE = new ListaEstados(); $lE->condicoes('', strtoupper($json->root->uf), ListaEstados::UF); if ($lE->getTotal() > 0) { $this->estado = $lE->listar(); } else { $this->estado = new Estado(); $this->estado->uf = $json->root->uf; $this->estado->nome = $json->root->estado; $this->estado->setPais($this->pais); } } if (!empty($json->root->idcidade)) { $this->cidade = new Cidade($json->root->idcidade); $this->cidade->nome = $json->root->cidade; $this->cidade->setEstado($this->estado); $this->cidade->setPais($this->pais); } } } }
$p->calcularFrete(); } catch (Exception $e) { } $p->calcular(); } while ($pI = $p->getItem()->listar()) { $pI->quantidade = $_POST['quantidade'][$pI->getId()]; $pI->valorVenda = $_POST['valor'][$pI->getId()]; $p->addItem($pI); } if (!empty($_POST['CEP'])) { $end = $p->getEndereco(); $end->setCep($_POST['CEP']); $lE = new ListaEstados(); $lE->condicoes('', strtoupper($_POST['estado']), ListaEstados::UF); if ($lE->getTotal() > 0) { $end->setEstado($lE->listar()); } else { $end->getEstado()->uf = strtoupper($_POST['estado']); $end->getEstado()->setPais(new Pais(1)); } $lC = new ListaCidades(); $lC->condicoes('', $_POST['cidade'], ListaCidades::NOME); if ($lC->getTotal() > 0) { $end->setCidade($lC->listar()); } else { $end->getCidade()->nome = $_POST['cidade']; $end->getCidade()->setEstado($end->getEstado()); } $end->logradouro = $_POST['Logradouro']; $end->numero = $_POST['Numero'];