Exemplo n.º 1
0
     $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'];
     $end->complemento = $_POST['Complemento'];
     $end->bairro = $_POST['Bairro'];
     $end->loadCep();
     $p->setEndereco($end);
     try {
         $p->getEndereco()->setValor(0);
Exemplo n.º 2
0
 public function alterar(Endereco $end)
 {
     parent::alterar($end);
     $where = "WHERE " . self::ID . " = '" . $end->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);
 }
Exemplo n.º 3
0
    }
}
/*
while($rs = $con->listar()){
	
	$iTCL->repetir();
	$iTCL->enterRepeticao()->trocar("id.Estado", $rs['id']);
	$iTCL->enterRepeticao()->trocar("nome.Estado", $rs['nome']);
	$iTCL->enterRepeticao()->trocar("uf.Estado", $rs['uf']);
	
	if($rs['id'] == $estado)
		$iTCL->enterRepeticao()->trocar("selected.Estado", 'selected');
	
}
*/
$lC = new ListaCidades();
$iTCL->createRepeticao("repetir->Cidade");
if (!empty($_GET['estado'])) {
    $lC->condicoes('', $_GET['estado'], ListaCidades::ESTADO);
    if (isset($_GET['json'])) {
        $a = array();
        while ($c = $lC->listar("ASC", ListaCidades::NOME)) {
            $a[] = array('id' => $c->getId(), 'nome' => $c->nome);
        }
        echo JSON::_Encode($a);
        exit;
    }
}
/*
while($rs = $con->listar()){