public function updateAction($id)
 {
     $model = Widgets::findFirst($id);
     $this->view->form = new PagamentoForm($model, array('edit' => true));
     $this->view->pagamento = $model;
     if ($this->request->isPost()) {
         $this->save($model);
     }
 }
 public function finalizarAction()
 {
     $cart = new Cart(new Session(), new Cookie());
     //Cria o Pedido
     $pedido = new Pedidos();
     $pedido_id = $pedido->createData($cart, $this->request->getPost());
     //Cria os Itens do Pedido
     $pedido_itens = new PedidoItens();
     $pedido_itens = $pedido_itens->createData($cart->contents(), $pedido_id);
     //Envia Email
     $this->helper->mailer->getHelper(array('pedido_id' => $pedido_id, 'tipo' => 'pedidoCriado'));
     $widget = Widgets::findFirst("id = {$this->request->getPost('forma_pagamento')}")->toArray();
     $_POST['pagamento']['valor'] = number_format($cart->total() + $this->session->get('frete')['valor'], 2, '', '');
     $_POST['pagamento']['pedido_id'] = $pedido_id;
     $_POST['pagamento']['url_base'] = $this->ecommerce_options->url_base;
     //Inicia o pagamento
     $pagamento = '\\' . $widget['namespace'] . '\\Pagamento';
     $retorno = $pagamento::init(true, $this->request->getPost('pagamento'), unserialize($widget['opcoes']));
     // Retorno do PAGAMENTO
     $class = '\\' . $widget['namespace'] . '\\Retorno';
     $class::init($retorno, $pedido_id);
     //Destroy Cart
     $this->verificaStatus($pedido_id);
 }
Ejemplo n.º 3
0
 protected static function getEstatisticasPagamento($periodo)
 {
     if (!empty($periodo)) {
         $conditions = 'status_id in (3,4,5) AND data >= "' . $periodo['inicial'] . ' 00:00:00" and data <= "' . $periodo['final'] . ' 23:59:59"';
     } else {
         $conditions = 'status_id in (3,4,5)';
     }
     $dados = self::count(array('group' => 'forma_pagamento', 'conditions' => $conditions));
     $arr = array();
     for ($i = 0; $i < count($dados); $i++) {
         $arr[$i]['forma_pagamento'] = Widgets::findFirst('id = ' . $dados[$i]->forma_pagamento)->nome;
         $arr[$i]['quantidade'] = $dados[$i]->rowcount;
     }
     return $arr;
 }