HOR-229-A-301 "Unassign User from a Department..." SOLVED

HOR-229-A-3018 "Unassign User from a Department..." SOLVED
This commit is contained in:
Luis Fernando Saisa Lopez
2016-02-11 14:25:18 -04:00
parent 7b2d2ba2aa
commit 180eefe01d
2 changed files with 27 additions and 5 deletions

View File

@@ -50,6 +50,27 @@ class Department
}
}
/**
* Verify if the User is not in a Department
*
* @param string $departmentUid
* @param string $userUid
*
* return void Throw exception user not exists
*/
private function throwExceptionUserNotExistsInDepartment($departmentUid, $userUid)
{
try {
$user = \UsersPeer::retrieveByPK($userUid);
if (is_null($user) || $user->getDepUid() != $departmentUid) {
throw new \Exception(\G::LoadTranslation('ID_USER_NOT_EXIST_DEPARTMENT', [$userUid]));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the title of a Department
*
@@ -253,6 +274,8 @@ class Department
$dep_uid = Validator::depUid($dep_uid);
$usr_uid = Validator::usrUid($usr_uid);
$this->throwExceptionUserNotExistsInDepartment($dep_uid, $usr_uid);
$dep = new \Department();
$dep->load( $dep_uid );
$manager = $dep->getDepManager();