public function __construct() { $this->DbAppraiser = DbTable_AppraiserEnterprise::getInstance(); $this->DbChecker = DbTable_CheckerEnterprise::getInstance(); $this->DbEnterprise = DbTable_Enterprise::getInstance(); $this->DbApeEvaluation = DbTable_ApeEvaluation::getInstance(); $this->DbCheckerEvaluation = DbTable_CheckerEvaluation::getInstance(); $this->DbApeEvaluationVerificador = DbTable_ApeEvaluationVerificador::getInstance(); }
private function checkAppraiserEnterpriseCount($status, $userId) { if ($status != 'able') { $appraiserEnterprises = DbTable_AppraiserEnterprise::getInstance()->getByUserIdAndProgramaId($userId, date('Y')); if (count($appraiserEnterprises) > 0) { throw new Exception('o avaliador já possui empresas associadas'); } } }
public function deleteUser($userRow) { DbTable_User::getInstance()->getAdapter()->beginTransaction(); try { /* Deleta todos os UserLocality */ $whereDeleteUserLocality = array('UserId = ?' => $userRow->getId()); DbTable_UserLocality::getInstance()->delete($whereDeleteUserLocality); /* Deleta todos as UserRole */ $whereDeleteUserRole = array('UserId = ?' => $userRow->getId()); DbTable_UserRole::getInstance()->delete($whereDeleteUserRole); $queryApE = DbTable_AppraiserEnterprise::getInstance()->select()->from(array('ApE' => 'AppraiserEnterprise'), array('AppraiserEnterprise' => 'ApE.UserId'))->where('ApE.UserId = ?', $userRow->getId()); $objResultApE = DbTable_Question::getInstance()->fetchRow($queryApE); if ($objResultApE) { return array('status' => false, 'messageError' => 'Usuário não pode ser deletado, há empresas relacionadas ao mesmo.'); } $userRow->delete(); DbTable_User::getInstance()->getAdapter()->commit(); return array('status' => true); } catch (Vtx_UserException $e) { DbTable_User::getInstance()->getAdapter()->rollBack(); return array('status' => false, 'messageError' => $e->getMessage()); } catch (Exception $e) { DbTable_User::getInstance()->getAdapter()->rollBack(); throw new Exception($e); } }