public function _afterSave() { parent::_afterSave(); if (count($this->_others['item_pedido']) > 0 && $this->_others['item_pedido']['id_produto']) { $_itemPedido = new Vendas_DataView_ItemPedido_MapperView(); $_itemPedido->setIdPedido($this->getId())->setIdProduto($this->_others['item_pedido']['id_produto'])->setQtdItem($this->_others['item_pedido']['qtd_item']); if (!$_itemPedido->exists()) { $_itemPedido->insert(); } } if (count($this->_others['pagamento']) > 0 && $this->_others['pagamento']['id_forma_pagto']) { $_pagamento = new Vendas_DataView_Pagamento_MapperView(); $_pagamento->setIdPedido($this->getId())->setIdFormaPagto($this->_others['pagamento']['id_forma_pagto']); if (!$_pagamento->exists()) { $_pagamento->insert(); } } if ($this->getStatus(true)->toPhp() == 'E') { $_pagtoLanc = new Vendas_DataView_PagtoLanc_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('pagto_pedido.id_pedido', $this->getId()); $_pagtoLanc->findAll($_where); if (!$_pagtoLanc->fetch()) { $this->_pagamento->efetivar($this->getId()); } } if ($this->getStatus(true)->toPhp() == 'C') { $_pagtoLanc = new Vendas_DataView_PagtoLanc_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('pagto_pedido.id_pedido', $this->getId()); $_pagtoLanc->findAll($_where); if ($_pagtoLanc->fetch()) { $this->_pagamento->cancelar($this->getId()); } } }