You can figure out how to best store the department information in PM Tables. What I would do is create the following two tables:
PMT_DEPARTMENTS:
1. DPT_ID, char(32)
2. DPT_NAME, char(64)
3. DPT_PARENT_ID, char(32), (only set if the department is a subdepartment of another department)
PMT_DEPARTMENT_MEMBERS:
1. DPT_ID, char(32)
2. MBR_ID, char(32), (You can set this to the same ID used by ProcessMaker users. See the USERS.USR_UID field in the database.)
3. MBR_USERNAME, char(50)
4. MBR_FIRST_NAME, char(64)
5. MBR_LAST_NAME, char(64)
6. IS_MANAGER, int(1), (set to 1 if manager or 0 if not a manager of the department)
Then, your trigger code to look up the manager(s) of the current logged-in user would be:
Code: Select all@=managers = array();
$userId = @@USER_LOGGED;
$sql = "SELECT * FROM PMT_DEPARTMENT_MEMBERS WHERE MBR_ID = '$userId'";
$result = executeQuery($sql);
if (!empty($result)) {
$departmentId = $result[1]['DPT_ID'];
$sql2 = "SELECT * FROM PMT_DEPARTMENT_MEMBERS WHERE DPT_ID = '$departmentId' AND IS_MANAGER=1";
$result2 = executeQuery($sql2);
foreach ($result2 as $manager) {
@=managers[] = $manager['MBR_ID'];
//another alternative is to do this if you need more information:
//@=managers[] = userInfo( $manager['MBR_ID'] );
}
}
// now @@managers can be the variable used in Self Service Value Based Assignment or
//the variable for Value Based Assignment in a task with a parallel marker