Esempio n. 1
0
<?php

importar("LojaVirtual.Produtos.Lista.ListaProdutos");
importar("LojaVirtual.Pedidos.Lista.ListaPedidos");
$tituloPagina = 'Pedidos > Adicionar Produtos';
$iLPC = new IFAdmin(new Arquivos(Sistema::$adminLayoutCaminhoDiretorio . "/SistemaPedidos/listarProdutos.html"));
$iLPC->trocar("linkDeletar.Produto", "?p=" . $_GET['p'] . "&a=" . $_GET['a'] . "&");
$iLPC->trocar("linkBuscar.Produto", "?p=" . $_GET['p'] . "&");
$iLPC->trocar('id.Pedido', $_GET['pedido']);
$lP = new ListaProdutos();
if (!empty($_POST)) {
    $lPE = new ListaPedidos();
    $lPE->condicoes('', $_GET['pedido'], ListaPedidos::ID);
    if ($lPE->getTotal() > 0) {
        $ped = $lPE->listar();
        if ($_POST['selecionado']) {
            foreach ($_POST['selecionado'] as $v) {
                $lP->condicoes('', $v, ListaProdutos::ID);
                if ($lP->getTotal() > 0) {
                    $ped->addItem(PedidoItem::__ProdutoToPedidoItem($lP->listar()));
                }
            }
        }
        try {
            $ped->calcularFrete();
            $lPE->alterar($ped);
        } catch (Exception $e) {
        }
        header("Location: ?p=SistemaPedidos&a=alterarPedido&pedido=" . $_GET['pedido']);
    }
}
Esempio n. 2
0
<?php

importar("LojaVirtual.Pedidos.Lista.ListaPedidos");
$tituloPagina = 'Pedidos > Pedidos';
$iTLPE = new IFAdmin(new Arquivos(Sistema::$adminLayoutCaminhoDiretorio . "/SistemaPedidos/listarPedidos.html"));
$iTLPE->trocar("linkDeletar.Pedido", "?p=" . $_GET['p'] . "&a=" . $_GET['a'] . "&");
$iTLPE->trocar("linkBuscar.Pedido", "?p=" . $_GET['p'] . "&");
if (!empty($_GET['deletar'])) {
    $lP = new ListaPedidos();
    $lP->condicoes('', $_GET['deletar'], ListaPedidos::ID);
    if ($lP->getTotal() > 0) {
        try {
            $ped = $lP->listar();
            $ped->setStatus(PedidoStatus::CANCELADO);
            if ($ped->estoque == 1) {
                $ped->estoque = 0;
                $lPR = new ListaProdutos();
                while ($pI = $ped->getItem()->listar()) {
                    $lPR->condicoes('', $pI->getId(), ListaProdutos::ID);
                    if ($lPR->getTotal() > 0) {
                        $pR = $lPR->listar();
                        $pR->estoque = $pR->estoque + $pI->quantidade;
                        $lPR->alterar($pR);
                    }
                }
            }
            $lP->alterar($ped);
            $ped->sendEmail('Status de Pedido alterado');
            $javaScript .= Aviso::criar("Pedido cancelado com sucesso!");
        } catch (Exception $e) {
            $javaScript .= Aviso::criar($e->getMessage());
Esempio n. 3
0
 public function listar($ordem = "ASC", $campo = self::ID)
 {
     $info = parent::listar($ordem, $campo);
     if (!empty($info)) {
         $lP = new ListaProdutos();
         $lP->condicoes('', $info[self::ID], ListaProdutos::ID);
         //if($lP->getTotal() > 0){
         $prod = $lP->listar();
         if ($lP->getTotal() > 0) {
             $temp = PedidoItem::__ProdutoToPedidoItem($prod);
         } else {
             $temp = new PedidoItem($info[self::ID]);
         }
         if (!empty($info[self::NOME])) {
             $temp->nome = $info[self::NOME];
         }
         if ($info[self::PESO] > 0) {
             $temp->peso = $info[self::PESO];
         }
         if ($info[self::LARGURA] > 0) {
             $temp->largura = $info[self::LARGURA];
         }
         if ($info[self::ALTURA] > 0) {
             $temp->altura = $info[self::ALTURA];
         }
         if ($info[self::COMPRIMENTO] > 0) {
             $temp->comprimento = $info[self::COMPRIMENTO];
         }
         if ($info[self::VALORCUSTO] > 0) {
             $temp->valorCusto = $info[self::VALORCUSTO];
         }
         if ($info[self::VALORREAL] > 0) {
             $temp->valorReal = $info[self::VALORREAL];
         }
         if ($info[self::VALORVENDA] > 0) {
             $temp->valorVenda = $info[self::VALORVENDA];
         }
         if ($info[self::FRETE] > 0) {
             $temp->frete = $info[self::FRETE];
         }
         if ($info[self::TIPOPEDIDO] > 0) {
             $temp->tipoPedido = $info[self::TIPOPEDIDO];
         }
         if (trim(strip_tags($info[self::DESCRICAOPEQUENA])) != '') {
             $temp->descricaoPequena = $info[self::DESCRICAOPEQUENA];
         }
         if (trim(strip_tags($info[self::DESCRICAO])) != '') {
             $temp->descricao = $info[self::DESCRICAO];
         }
         if ($info[self::ORDEM] > 0) {
             $temp->ordem = $info[self::ORDEM];
         }
         if ($info[self::DISPONIVEL] > 0) {
             $temp->disponivel = $info[self::DISPONIVEL] == self::VALOR_DISPONIVEL_TRUE ? true : false;
         }
         if ($info[self::PROMOCAO] > 0) {
             $temp->promocao = $info[self::PROMOCAO] == self::VALOR_DISPONIVEL_TRUE ? true : false;
         }
         if ($info[self::LANCAMENTO] > 0) {
             $temp->lancamento = $info[self::LANCAMENTO] == self::VALOR_DISPONIVEL_TRUE ? true : false;
         }
         if ($info[self::DESTAQUE] > 0) {
             $temp->destaque = $info[self::DESTAQUE] == self::VALOR_DISPONIVEL_TRUE ? true : false;
         }
         if ($info[self::REMOVIDO] > 0 && !$temp->removido) {
             $temp->removido = $info[self::REMOVIDO] == self::VALOR_DISPONIVEL_TRUE ? true : false;
         }
         if ($info[self::TIPOUNIDADE] > 0) {
             $temp->tipoUnidade = $info[self::TIPOUNIDADE];
         }
         if ($info[self::QUANTIDADEU] > 0) {
             $temp->quantidadeu = $info[self::QUANTIDADEU];
         }
         if ($info[self::ESTOQUE] > 0) {
             $temp->estoque = $info[self::ESTOQUE];
         }
         if (!empty($info[self::CODIGO])) {
             $temp->codigo = $info[self::CODIGO];
         }
         if (!empty($info[self::VIDEO])) {
             $temp->setVideo($info[self::VIDEO]);
         }
         $temp->setDataCadastro(new DataHora($info[self::DATACADASTRO]));
         $lPE = new ListaPedidos();
         $lPE->condicoes('', $info[self::IDSESSAO], ListaPedidos::ID);
         if ($lPE->getTotal() > 0) {
             $temp->setPedido($lPE->listar());
         }
         $lPM = new ListaProdutoMarcas();
         $lPM->condicoes('', $info[self::MARCA], ListaProdutoMarcas::ID);
         if ($lPM->getTotal() > 0) {
             $temp->setMarca($lPM->listar());
         }
         $temp->quantidade = $info[self::QUANTIDADE];
         $temp->observacao = $info[self::OBSERVACAO];
         $temp->setValorFrete($info[self::VALORFRETE]);
         return $temp;
         //}
     }
 }