Exemple #1
0
 public function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->_action != 'delete') {
         if ($this->getIdEmpresa(true)->toPhp() == '') {
             $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa());
         }
         if ($this->getIdCliente(true)->toPhp() == '') {
             $_pessoa = new Ca_DataView_Pessoa_MapperView();
             $_pessoa->setNome(_i18n('CONSUMIDOR'));
             $_pessoa->retrieve();
             $this->setIdCliente($_pessoa->getId());
         }
         if ($this->getIdClienteCon(true)->toPhp() == '') {
             $this->setIdClienteCon($this->getIdCliente());
         }
         if ($this->getIdUsuInc(true)->toPhp() == '') {
             $this->setIdUsuInc(Auth_Session_User::getInstance()->getId());
         }
         if ($this->getTipo(true)->toPhp() == '') {
             $this->setTipo('V');
         }
         if ($this->getStatus(true)->toPhp() == '') {
             $this->setStatus('A');
         }
         if ($this->getStatusEdi(true)->toPhp() == '') {
             $this->setStatusEdi('N');
         }
         if ($this->getDtEmis(true)->toPhp() == '') {
             $this->setDtEmis(ZendT_Type_Date::nowDate());
         }
         if ($this->getDhInc(true)->toPhp() == '') {
             $this->setDhInc(ZendT_Type_Date::nowDateTime());
         }
         $this->setIdUsuAlt(Auth_Session_User::getInstance()->getId());
         if ($this->getIdFuncionario(true)->toPhp() == '') {
             $_pessoa = new Ca_DataView_Pessoa_MapperView();
             $_pessoa->setEmail(Auth_Session_User::getInstance()->getLogin());
             $_pessoa->retrieve();
             $this->setIdFuncionario($_pessoa->getId());
         }
         if ($this->_action == 'update') {
             /*if ($this->getStatus()->toPhp() == 'A') {
                   $this->_pagamento = new Vendas_DataView_Pagamento_MapperView();
                   $this->_saldoPagto = $this->_pagamento->getSaldoPagar($this->getId());
                   if ($this->_saldoPagto == 0) {
                       $this->setStatus('P'); // pago
                   }
               }*/
         }
     }
     if ($this->_action == 'insert' && !$this->getNumero(true)->toPhp()) {
         $_numeracao = new Ca_Model_Numeracao_Mapper();
         $numero = $_numeracao->proximo(self::$table . '.numero', $this->getIdEmpresa()->toPhp());
         $this->setNumero($numero);
     }
 }
Exemple #2
0
 protected function _cliente($data)
 {
     $this->_pessoa->newRow();
     $this->_pessoa->setCodigo($data->cnpjCliente);
     $this->_pessoa->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa());
     if (!$this->_pessoa->exists()) {
         $this->_pessoa->setNome($data->razaoSocialCliente)->setPapelCliente('1')->insert();
     }
     return $this->_pessoa->getId();
 }
Exemple #3
0
 public function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->_action == 'insert' && !$this->getNumero(true)->toPhp()) {
         $_numeracao = new Ca_Model_Numeracao_Mapper();
         $numero = $_numeracao->proximo(self::$table . '.numero', $this->getIdEmpresa(true)->toPhp());
         $this->setNumero($numero);
     }
     if ($this->getIdEmpresa(true)->toPhp() == '') {
         $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa());
     }
     if ($this->getIdCliente(true)->toPhp() == '') {
         $_pessoa = new Ca_DataView_Pessoa_MapperView();
         $_pessoa->setNome(_i18n('CONSUMIDOR'));
         $_pessoa->retrieve();
         $this->setIdCliente($_pessoa->getId());
     }
 }