示例#1
0
文件: Mapper.php 项目: rtsantos/mais
 /**
  * Retorna o valor antigo do registro antes de realizar a atualização
  *
  * @return Ca_Model_Numeracao_Mapper
  */
 public function getValueOld()
 {
     if (!$this->_dataOld instanceof Ca_Model_Numeracao_Mapper) {
         $this->_dataOld = new Ca_Model_Numeracao_Mapper();
         $this->_dataOld->setId($this->getId());
         $this->_dataOld->retrive();
     }
     return $this->_dataOld;
 }
示例#2
0
文件: Mapper.php 项目: rtsantos/mais
 public function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->_action == 'insert' && !$this->getCodigo(true)->toPhp()) {
         $_numeracao = new Ca_Model_Numeracao_Mapper();
         $codigo = $_numeracao->proximo(self::$table . '.codigo', $this->getIdEmpresa());
         $this->setCodigo($codigo);
     }
 }
示例#3
0
文件: Mapper.php 项目: rtsantos/mais
 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());
     }
 }
示例#4
0
文件: Mapper.php 项目: rtsantos/mais
 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);
     }
 }