/**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_AdminHome::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $privManager = new PrivilegeManager($this->viewer->getID());
     $dataAccessObject = new RowManager_EventManager();
     // go through events found for logged-in administrator (if lower level than super-admin)
     //         if ($privManager->isSuperAdmin()==false)	// check privilege level
     //         {
     // 	        $adminEvents = $privManager->getAdminEvents();
     // 	        if ($adminEvents != PrivilegeManager::ALL_EVENTS)
     // 	        {
     // 		        for ($i=0; $i < count($adminEvents); $i++)
     // 		        {
     // 		        		$condArray[$i] = $dataAccessObject->constructSearchCondition( 'event_id', '=', $adminEvents[$i]);
     // 		     		}
     // 	     	  		$dataAccessObject->constructSearchConditionFromArray( $condArray, 'OR', true );
     //      	  		}
     //   	  		}
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new EventList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_AdminHome::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_People::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //        $this->managerInit = $managerInit;
     // $dataAccessObject = new RowManager_PersonManager();
     $dataAccessObject = new MultiTableManager();
     $personManager = new RowManager_PersonManager();
     $dataAccessObject->addRowManager($personManager);
     if ($sortBy == '') {
         $sortBy = 'person_fname';
     }
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new PersonList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_People::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @param $template_id [STRING] The init data for the dataList obj
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $template_id = "")
 {
     parent::__construct(page_TemplateAdminPage::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //        $this->managerInit = $managerInit;
     $this->template_id = $template_id;
     $this->listManager = new EmailTemplateList($this->template_id, $sortBy);
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = moduleEmailTemplates::MULTILINGUAL_SERIES_KEY;
     $pageKey = moduleEmailTemplates::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_TemplateAdminPage::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $regID)
 {
     parent::__construct(page_ScholarshipDisplayList::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->registration_id = $regID;
     $dataAccessObject = new RowManager_ScholarshipAssignmentManager();
     $dataAccessObject->setRegID($this->registration_id);
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new ScholarshipAssignmentList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ScholarshipDisplayList::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $year_id = "", $campus_id = "")
 {
     parent::__construct(page_ViewStudentYearInSchool::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->year_id = $year_id;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // need to filter displayed data by campus associated with campus admin
     $campusAdminSearchCondition = '';
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $campusList = $campusAdminManager->getListIterator();
             //$multiTableManager->getListIterator();
             $campusArray = $campusList->getDataList();
             $campusIDsList = "";
             // init the CSV of campus IDs associated with admin
             reset($campusArray);
             foreach (array_keys($campusArray) as $k) {
                 $record = current($campusArray);
                 $campusIDsList .= $record['campus_id'] . ',';
                 // create list of admin campuses
                 next($campusArray);
             }
             $campusIDsList = substr($campusIDsList, 0, -1);
             // remove last comma
             $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $campusIDsList = "";
                 // init the CSV of campus IDs associated with admin
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $campusIDsList .= $campusAssignObject->getCampusID() . ',';
                     // create list of admin campuses
                 }
                 $campusIDsList = substr($campusIDsList, 0, -1);
                 // remove last comma
                 $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
             }
         }
     }
     $yearManager = new RowManager_YearInSchoolManager();
     $yearManager->setSortOrder('year_id');
     $this->yearValueList = $yearManager->getListIterator();
     $this->yearValues = $this->yearValueList->getDropListArray();
     // Add value to drop-list for showing person data for people not having person_year record
     $keys = array_keys($this->yearValues);
     $this->UNASSIGNED_IDX = $keys[count($this->yearValues) - 1] + 1;
     // assumes autoincrement is active on table
     $this->yearValues[$this->UNASSIGNED_IDX] = page_ViewStudentYearInSchool::UNASSIGNED;
     // 					echo 'values = <pre>'.print_r($this->yearValues, true).'</pre>';
     // modify the year_id if necessary
     if ($this->year_id == page_ViewStudentYearInSchool::DISPLAY_ALL_ID) {
         // setting the year_id to blank will get entries from all the years
         $this->year_id = '';
     } else {
         if ($this->year_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->yearValues as $key => $value) {
                 $this->year_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->year_id == '') {
                 die("ERROR - year_id not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     // Check if regular choice made (i.e. person has some year_in_school record)
     if ($this->year_id != $this->UNASSIGNED_IDX) {
         $personYearManager = new RowManager_PersonYearManager();
         $personYearManager->setYear($this->year_id);
         // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         $dataAccessObject->addRowManager($personYearManager);
         $yearManager = new RowManager_YearInSchoolManager();
         $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         $dataAccessObject->addRowManager($yearManager, $joinPair);
         $personManager = new RowManager_PersonManager();
         $joinPair1 = new JoinPair($personManager->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($personManager, $joinPair1);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personYearManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         if ($this->year_id != '') {
             $dataAccessObject->addSearchCondition('cim_hrdb_person_year.year_id = ' . $this->year_id);
         }
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         // 	        $personYearManager = new RowManager_PersonYearManager();
         // 	        $personYearManager->setYear($this->year_id);	// SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         // 	        $dataAccessObject->addRowManager( $personYearManager );
         //
         // 	        $yearManager = new RowManager_YearInSchoolManager();
         // 	        $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         // 	        $dataAccessObject->addRowManager( $yearManager, $joinPair );
         $personManager = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($personManager);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         // get sub-query data for filtering out registrants that have already been registered for event
         $subManager = new RowManager_PersonYearManager();
         $personYearManager = new MultiTableManager();
         $personYearManager->addRowManager($subManager);
         $personYearManager->setFieldList('person_id');
         $registered_SQL = $personYearManager->createSQL();
         //          echo "<br>CREATED SQL 1 = ".$registered_SQL;
         // actually creates the sub-query ensuring that registrants listed do NOT have personyear records
         $negateSubQuery = true;
         $addSubQuery = true;
         $dataAccessObject->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery);
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     }
     /** TEST **/
     //         $values = $this->listManager->getDataList();
     //         echo 'values found = <pre>'.print_r($values,true).'</pre>';
     /** END TEST **/
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewStudentYearInSchool::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $staffscheduletype_id)
 {
     parent::__construct(page_FormApprovalListing::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->formtype_id = $staffscheduletype_id;
     $this->sortBy = $sortBy;
     if ($this->sortBy == '') {
         $this->sortBy = 'staffschedule_approved,person_lname,person_fname';
     } else {
         if ($this->sortBy == 'person_id') {
             $this->sortBy = 'person_lname,person_fname';
         }
     }
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // Super-admin
     if ($this->adminManager->hasSitePriv()) {
         $dataAccessObject = new MultiTableManager();
         $schedules = new RowManager_StaffScheduleManager();
         $schedules->setFormID($this->formtype_id);
         $persons = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($schedules);
         $dataAccessObject->addRowManager($persons, new JoinPair($schedules->getJoinOnPersonID(), $persons->getJoinOnPersonID()));
         $dataAccessObject->setSortOrder($this->sortBy);
         //        $this->listManager = new StaffScheduleList( $sortBy );
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         if ($this->adminManager->isStaff($viewer->getID())) {
             $director_id = $this->getStaffIDfromViewerID();
             $staffManager = new RowManager_StaffDirectorManager();
             $staffManager->setDirectorID($director_id);
             /* Retrieve all directors under the current director */
             $hierarchy_result = $staffManager->getDirectorHierarchy($director_id);
             $hierarchy_result->setFirst();
             $hierarchy_array = array();
             $directed_staff = '';
             while ($hierarchy_result->moveNext()) {
                 $staff_ids = $hierarchy_result->getCurrentRow();
                 // 	           echo 'array = <pre>'.print_r($hierarchy_array,true).'</pre>';
                 for ($lvl = 1; $lvl <= MAX_DIRECTOR_LEVELS; $lvl++) {
                     $staff_id = $staff_ids['staff_lvl' . $lvl];
                     if ($staff_id != null) {
                         $directed_staff .= $staff_id . ',';
                     }
                 }
             }
             if ($directed_staff != '') {
                 $directed_staff = substr($directed_staff, 0, -1);
             } else {
                 $directed_staff = page_FormApprovalListing::NO_SUPERVISEES;
             }
             // 	        // Filter approval records by those staff persons found in the list of staff under the direction of the current viewer
             $schedules = new RowManager_StaffScheduleManager();
             $schedules->setFormID($this->formtype_id);
             $person_info = new RowManager_PersonManager();
             $staff = new RowManager_StaffManager();
             $dataAccessObject = new MultiTableManager();
             $dataAccessObject->addRowManager($staff);
             $dataAccessObject->addRowManager($person_info, new JoinPair($staff->getJoinOnPersonID(), $person_info->getJoinOnPersonID()));
             $dataAccessObject->addRowManager($schedules, new JoinPair($person_info->getJoinOnPersonID(), $schedules->getJoinOnPersonID()));
             $dataAccessObject->addSearchCondition('staff_id in (' . $directed_staff . ')');
             $dataAccessObject->setSortOrder($this->sortBy);
             $this->listManager = $dataAccessObject->getListIterator();
         } else {
             $dataAccessObject = new MultiTableManager();
             $schedules = new RowManager_StaffScheduleManager();
             $schedules->setFormID(page_FormApprovalListing::UNAUTHORIZED_DIRECTOR);
             $dataAccessObject->addRowManager($schedules);
             $dataAccessObject->setSortOrder($this->sortBy);
             //        $this->listManager = new StaffScheduleList( $sortBy );
             $this->listManager = $dataAccessObject->getListIterator();
         }
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_FormApprovalListing::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_ViewGroups::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //Get person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $this->personID = $accessManager->getPersonID();
     echo "ViewerID: " . $this->viewer->getViewerID() . " <br>personID: " . $this->personID . "<br>";
     /*
      * The code below contains the different permission cases for view groups.
      * 
      * Check 1 = check if the user is a SUPER ADMIN
      * Check 2 = check if the user is a STAFF and which campuses he/she is assigned to, taken from HRDB
      * Check 3 =check cim_sch_permissionCampusAdmin for which CAMPUSES this user is ADMIN for
      * Check 4 = check cim_sch_permissionGroupAdmin for which GROUPS this user is ADMIN for
      * If check 1-4 FAIL then ViewGroup will show nothing. (This user is a normal user and have not created any groups .
      */
     $multiTableManager = new MultiTableManager();
     $groupManager = new RowManager_GroupManager();
     $superAdminManager = new RowManager_PermissionsSuperAdminManager();
     //SUPER ADMIN
     //Check if user's Viewer_id is in the PermissionSuperAdmin table
     if ($superAdminManager->loadByViewerID($this->viewer->getViewerID())) {
         // the viewer is a super admin
         echo "ViewerID[" . $this->viewer->getViewerID() . "] is a super admin<br/>";
         $campusGroupManager = new RowManager_CampusGroupManager();
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
     } else {
         //STAFF
         // This array stores all the campuses associated to the user.
         //This array is continually populated
         $campusArray = array();
         //check HRDB if the user is a staff
         $assignmentManager = new RowManager_AssignmentsManager();
         $assignmentManager->setPersonID($this->personID);
         $assignmentManager->setAssignmentStatus(CA_STAFF);
         $assList = new ListIterator($assignmentManager);
         $assList->setFirst();
         while ($assList->moveNext()) {
             $assMan = $assList->getCurrent(new RowManager_AssignmentsManager());
             //for each campuses found, store in array
             $campusArray[] = $assMan->getCampusID();
         }
         //CAMPUS ADMIN
         //Check cim_sch_permissionsCampusAdmin for the viewer id of the user
         $permissionsCampusAdmin = new RowManager_PermissionsCampusAdminManager();
         $permissionsCampusAdmin->setViewerID($this->viewer->getViewerID());
         $campusAdminList = new ListIterator($permissionsCampusAdmin);
         $campusAdminList->setFirst();
         while ($campusAdminList->moveNext()) {
             $permCampus = $campusAdminList->getCurrent(new RowManager_PermissionsCampusAdminManager());
             //for each campuses found, store in array
             $campusArray[] = $permCampus->getCampusID();
         }
         //remove any duplicate campus ID in the array
         $campusArray = array_unique($campusArray);
         //GROUP ADMIN
         $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
         $campusGroupManager = new RowManager_CampusGroupManager();
         //send a list of campues and the viewer ID to constrict the search condition
         //The Viewer_id is use to check the cim_sch_permissionsGroupAdmin table for
         // groups that were created by the user
         $searchCond = $campusGroupManager->returnSearchCondition($campusArray, $this->viewer->getViewerID());
         //create the appropriate join between 3 tables
         //Join cim_sch_group and cim_sch_permissionsGroupAdmin and cim_sch_campusGroup
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addSearchCondition($searchCond);
     }
     /*Case 3: Group Admin - access to an individual group and can create other group admins 
     				(ex. DGL)
     				Normal User - can only submit schedule, assume this unless given other permissions
     					Check the group admin table 
     	
     				check cim_sch_permissiongroupadmin -> cim_sch_campusgroup -> cim_sch_group
     				filter on viewer id 
     
     
     		Case 4: All staff - implicit access to all groups on all campuses where their status is staff 
     				check cim_hrdb_staff table
     					if true
     						get all campuses from cim_hrdb_assignment where assignment status id = 3
     
     
             */
     /*$groupManager = new RowManager_GroupManager();
       $multiTableManager = new MultiTableManager();
       
       $campusGroupManager = new RowManager_CampusGroupManager();
       
       $multiTableManager->addRowManager( $campusGroupManager );
       $multiTableManager->addRowManager( $groupManager, new JoinPair( $campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT ) );*/
     // $dataAccessObject = $multiTableManager;
     $multiTableManager->setSortOrder('campus_id');
     //******Not sure this is the way to do it*****
     //       $this->listManager = new GroupList( $sortBy );
     $this->listManager = $multiTableManager->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_sch::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_sch::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewGroups::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $person_id, $ministry_id = '')
 {
     parent::__construct(page_HomePageEventList::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->sortBy = $sortBy;
     $this->person_id = $person_id;
     $this->ministry_id = $ministry_id;
     //        $this->managerInit = $managerInit;
     /** Disable events from being shown if registration date&time have passed **/
     // Filter for shown events that have closed registration or have already started
     // 		   $this->timeSearchCondition = '((event_regEnd < now()) or (event_startDate < now()))';
     //
     //          $events0 = new RowManager_EventManager();
     //          $events0->setOnHomePage('1');
     //          $events0->addSearchCondition($this->timeSearchCondition);
     //
     //          $disable_events_list = $events0->getListIterator();
     //          $disable_events_array = $disable_events_list->getDataList();
     //          reset($disable_events_array);
     //          foreach (array_keys($disable_events_array) as $k)	// go through all events and map user registered status
     //          {
     //             $record = current($disable_events_array);
     //             $eventID = $record['event_id'];
     //
     //      			$event_updater = new RowManager_EventManager($eventID);
     //
     //      			$updateValues = array();
     //      			$updateValues['event_onHomePage'] = '0';	// update the event row to DISABLE display
     //      			$event_updater->loadFromArray( $updateValues );
     //         		$event_updater->updateDBTable();
     //
     //             next($disable_events_array);
     //          }
     /*** Get the countries linked to the campuses that this viewer is associated with **/
     $eventFilter = new MultiTableManager();
     $assignments = new RowManager_AssignmentsManager();
     $assignments->setPersonID($this->person_id);
     $campuses = new RowManager_CampusManager();
     $regions = new RowManager_RegionManager();
     $countries = new RowManager_CountryManager();
     $eventFilter->addRowManager($countries);
     $eventFilter->addRowManager($regions, new JoinPair($countries->getJoinOnCountryID(), $regions->getJoinOnCountryID()));
     $eventFilter->addRowManager($campuses, new JoinPair($regions->getJoinOnRegionID(), $campuses->getJoinOnRegionID()));
     $eventFilter->addRowManager($assignments, new JoinPair($assignments->getJoinOnCampusID(), $campuses->getJoinOnCampusID()));
     $countryList = $eventFilter->getListIterator();
     $countryArray = $countryList->getDataList();
     $country_filter = '';
     reset($countryArray);
     foreach (array_keys($countryArray) as $k) {
         $record = current($countryArray);
         $country_filter .= $record['country_id'] . ',';
         next($countryArray);
     }
     $country_filter = substr($country_filter, 0, -1);
     $dataAccessObject = new RowManager_EventManager();
     // only display those rows that are supposed to be displayed on the home page
     $dataAccessObject->setOnHomePage(true);
     if ($this->ministry_id != '') {
         $dataAccessObject->setMinistryID($this->ministry_id);
     }
     if ($country_filter == '') {
         $country_filter = 1;
     }
     $this->countrySearchCondition = 'country_id in (' . $country_filter . ')';
     $dataAccessObject->addSearchCondition($this->countrySearchCondition);
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new EventList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     $events_array = $this->listManager->getDataList();
     if (count($events_array) > 0) {
         $this->isShowingEvents = true;
     } else {
         $this->isShowingEvents = false;
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_HomePageEventList::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $month_id = '')
 {
     parent::__construct(page_ViewScheduleCalendar::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     if ($month_id == '') {
         $month_id = date('n');
     }
     $this->month_id = $month_id;
     $this->year_id = date('Y');
     $this->first_weekday = page_ViewScheduleCalendar::SUNDAY;
     $this->monthValues = $this->getMonthValues();
     //$this->yearValueList->getDropListArray();
     // Now load the access Privilege manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // Super-admin
     if ($this->adminManager->hasSitePriv()) {
         $dataAccessObject = new MultiTableManager();
         $activities = new RowManager_StaffActivityManager();
         $activityTypes = new RowManager_ActivityTypeManager();
         $person_info = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($activities);
         $dataAccessObject->addRowManager($activityTypes, new JoinPair($activityTypes->getJoinOnActivityTypeID(), $activities->getJoinOnActivityTypeID()));
         $dataAccessObject->addRowManager($person_info, new JoinPair($person_info->getJoinOnPersonID(), $activities->getJoinOnPersonID()));
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         if ($this->adminManager->isStaff($viewer->getID())) {
             $director_id = $this->getStaffIDfromViewerID();
             // 	        $staffPersonManager = new MultiTableManager();
             $staffManager = new RowManager_StaffDirectorManager();
             $staffManager->setDirectorID($director_id);
             // 	        $staffInfoManager = new RowManager_StaffManager();
             // 	        $staffPersonManager->addRowManager($staffInfoManager);
             // 	        $staffPersonManager->addRowManager($staffManager, new JoinPair($staffManager->getJoinOnStaffID(),$staffInfoManager->getJoinOnStaffID()));
             // 	        $staffList = $staffPersonManager->getListIterator();
             // 	        $staffArray = $staffList->getDataList();
             /* Retrieve all directors under the current director */
             $hierarchy_result = $staffManager->getDirectorHierarchy($director_id);
             $hierarchy_result->setFirst();
             $hierarchy_array = array();
             $directed_staff = '';
             while ($hierarchy_result->moveNext()) {
                 $staff_ids = $hierarchy_result->getCurrentRow();
                 // 	           echo 'array = <pre>'.print_r($hierarchy_array,true).'</pre>';
                 for ($lvl = 1; $lvl <= MAX_DIRECTOR_LEVELS; $lvl++) {
                     $staff_id = $staff_ids['staff_lvl' . $lvl];
                     if ($staff_id != null) {
                         $directed_staff .= $staff_id . ',';
                     }
                 }
             }
             if ($directed_staff != '') {
                 $directed_staff .= $director_id;
                 //= substr( $directed_staff, 0, -1 );
             } else {
                 $directed_staff = $director_id;
                 //page_ViewScheduleCalendar::NON_DIRECTOR;
             }
             // 	        echo '<pre>'.print_r($staffArray,true).'</pre>';
             // 	        // Retrieve the list of staff supervised by current viewer
             // 	        $directed_staff = '';
             // 	        foreach (array_keys($staffArray) as $key)
             // 	        {
             // 		        $record = current($staffArray);
             // 		        $directed_staff .= $record['person_id'].',';
             // 		        next($staffArray);
             // 	        }
             // 	        $directed_staff = substr($directed_staff,0,-1);
             // 	        if ($directed_staff == '')
             // 	        {
             // 		        $directed_staff = page_FormApprovalListing::NO_SUPERVISEES;	// don't match any person IDs
             // 	        }
             // Filter activities by those staff persons found in the list of staff under the direction of the current viewer
             $dataAccessObject = new MultiTableManager();
             $schedules = new RowManager_StaffScheduleManager();
             // 	        $schedules->addSearchCondition('person_id in ('.$directed_staff.')');
             $schedule_activities = new RowManager_ActivityScheduleManager();
             $activities = new RowManager_StaffActivityManager();
             $activityTypes = new RowManager_ActivityTypeManager();
             $person_info = new RowManager_PersonManager();
             $staff = new RowManager_StaffManager();
             $dataAccessObject->addRowManager($activities);
             $dataAccessObject->addRowManager($schedule_activities, new JoinPair($activities->getJoinOnActivityID(), $schedule_activities->getJoinOnActivityID()));
             $dataAccessObject->addRowManager($schedules, new JoinPair($schedules->getJoinOnScheduleID(), $schedule_activities->getJoinOnScheduleID()));
             $dataAccessObject->addRowManager($activityTypes, new JoinPair($activityTypes->getJoinOnActivityTypeID(), $activities->getJoinOnActivityTypeID()));
             $dataAccessObject->addRowManager($person_info, new JoinPair($person_info->getJoinOnPersonID(), $activities->getJoinOnPersonID()));
             $dataAccessObject->addRowManager($staff, new JoinPair($staff->getJoinOnPersonID(), $person_info->getJoinOnPersonID()));
             $dataAccessObject->addSearchCondition('staff_id in (' . $directed_staff . ')');
             $dataAccessObject->setSortOrder($sortBy);
             $this->listManager = $dataAccessObject->getListIterator();
         } else {
             $dataAccessObject = new RowManager_StaffActivityManager(page_ViewScheduleCalendar::UNAUTHORIZED_DIRECTOR);
             $this->listManager = $dataAccessObject->getListIterator();
         }
     }
     $this->monthEvents = array();
     // 		  $eventsOfType = array();	// stores events/activities of a specific type
     // 		  $eventDetails = array();	// stores details for a specific person's event
     $eventsArray = $this->listManager->getDataList();
     reset($eventsArray);
     if (count($eventsArray) > 0) {
         // Search through found activities
         foreach (array_keys($eventsArray) as $key) {
             $record = current($eventsArray);
             $activity_id = $record['staffactivity_id'];
             $activity_desc = $record['activitytype_desc'];
             $person_name = $record['person_fname'] . ' ' . $record['person_lname'];
             $contact_phone = $record['staffactivity_contactPhone'];
             $activity_type = $record['activitytype_abbr'];
             // 		        $eventDetails[$activity_id][0] = $person_name;
             // 		        $eventDetails[$activity_id][1] = $contact_phone;
             //
             // 		        $eventsOfType[$activity_type] = $eventDetails;
             $startdate_parts = explode('-', $record['staffactivity_startdate']);
             $enddate_parts = explode('-', $record['staffactivity_enddate']);
             // Store event information by weekday
             for ($month_id = $startdate_parts[1]; $month_id <= $enddate_parts[1]; $month_id++) {
                 if ($this->month_id == $month_id) {
                     $start_day = $startdate_parts[2];
                     if (substr($start_day, 0, 1) == 0) {
                         $start_day = substr($start_day, 1);
                     }
                     $end_day = $enddate_parts[2];
                     if (substr($end_day, 0, 1) == 0) {
                         $end_day = substr($end_day, 1);
                     }
                     // Store the event data (name and contact #) for each valid day of the month
                     $init_day = page_ViewScheduleCalendar::FIRST_MONTH_DATE;
                     $last_day = page_ViewScheduleCalendar::MAX_MONTH_DATE;
                     if ($startdate_parts[1] == $enddate_parts[1]) {
                         $init_day = $start_day;
                         $last_day = $end_day;
                     } else {
                         if ($month_id == $startdate_parts[1]) {
                             $init_day = $start_day;
                             $last_day = page_ViewScheduleCalendar::MAX_MONTH_DATE;
                         } else {
                             if ($month_id == $enddate_parts[1]) {
                                 $init_day = page_ViewScheduleCalendar::FIRST_MONTH_DATE;
                                 $last_day = $end_day;
                             } else {
                                 $init_day = page_ViewScheduleCalendar::FIRST_MONTH_DATE;
                                 $last_day = page_ViewScheduleCalendar::MAX_MONTH_DATE;
                             }
                         }
                     }
                     // Use the init and last day values as set based on above conditions
                     for ($day_id = $init_day; $day_id <= $last_day; $day_id++) {
                         $this->monthEvents[$day_id][$activity_type][$activity_id][0] = $activity_desc;
                         $this->monthEvents[$day_id][$activity_type][$activity_id][1] = $person_name;
                         $this->monthEvents[$day_id][$activity_type][$activity_id][2] = $contact_phone;
                         //$this->monthEvents[$day_id] = $eventsOfType;
                     }
                 }
             }
             next($eventsArray);
         }
     }
     /** TEST **/
     //         $values = $this->listManager->getDataList();
     //         echo 'values found = <pre>'.print_r($values,true).'</pre>';
     /** END TEST **/
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewScheduleCalendar::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function isDataValid
  * <pre>
  * Verifies the returned data is valid.
  * </pre>
  * @return [BOOL]
  */
 function isDataValid()
 {
     $isValid = parent::isDataValid();
     /*
      * check here for specific cases not covered by simple Field
      * Definitions.
      */
     // Example : error checking
     // NOTE:  a custom error label [error_UniqueModuleName] is used
     // for the error.  This error label is created in the Page Labels
     // form.
     // Make sure that module name doesn't already exist...
     //        if ($isValid) {
     //            $isValid = $this->dataManager->isUniqueModuleName();
     //            $this->formErrors[ 'module_name' ] = $this->labels->getLabel( '[error_UniqueModuleName]');
     ///        }
     // now return result
     return $isValid;
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $customreport_id, $disable_heading = false)
 {
     $this->is_blank_page = false;
     $this->disable_heading = $disable_heading;
     // store field display types
     $DISPLAY_FIELDS = $this->getDisplayFields($customreport_id);
     parent::__construct($DISPLAY_FIELDS);
     //         parent::__construct( page_ViewCustomReport::DISPLAY_FIELDS );
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->disableHeading = $disable_heading;
     $this->customreport_id = $customreport_id;
     $this->fields_id_array = array();
     $this->listLabels = array();
     // Get fields for the custom report; required for retrieving data in column format
     //         $columns = 'customfields_id,report_id,cim_hrdb_customfields.fields_id,count(person_id)';
     $groupBy = 'cim_hrdb_customfields.fields_id';
     $dbFunction = 'COUNT';
     $funcParam = 'person_id';
     $reportFields = new MultiTableManager();
     $customfields = new RowManager_CustomFieldsManager();
     $customfields->setReportID($this->customreport_id);
     // TODO?  error checking on ID
     $fieldvalues = new RowManager_FormFieldValueManager();
     $reportFields->addRowManager($customfields);
     $reportFields->addRowManager($fieldvalues, new JoinPair($customfields->getJoinOnFieldID(), $fieldvalues->getJoinOnFieldID()));
     // use GROUP BY and $dbFunction = 'COUNT' to quickly get summary data per campus
     if ($groupBy != '') {
         $reportFields->setGroupBy($groupBy);
         //'campus_desc');
     }
     if ($dbFunction != '') {
         $reportFields->setFunctionCall($dbFunction, $funcParam);
     }
     $reportFields->setSortOrder('COUNT(person_id) DESC');
     // 	     $reportFields->setFieldList($columns);
     $customFieldsList = $reportFields->getListIterator();
     $customFieldsArray = $customFieldsList->getDataList();
     //         echo '<pre>'.print_r($customFieldsArray,true).'</pre>';
     $i = 0;
     foreach (array_keys($customFieldsArray) as $key) {
         $record = current($customFieldsArray);
         $this->fields_id_array[$i] = $record['fields_id'];
         $i++;
         next($customFieldsArray);
     }
     // Ensure that the custom report has been given at least one field
     if (count($this->fields_id_array) > 0) {
         // Default sorting: by person name, since this is the only standard field
         $this->sortBy = 'person_lname,person_fname';
         // TODO: need to add person table to allow person_name sorting
         // Now load the access Privilege manager of this viewer
         $this->adminManager = new RowManager_AdminManager();
         // Get the person ID
         $accessManager = new RowManager_AccessManager();
         $accessManager->loadByViewerID($this->viewer->getViewerID());
         $personID = $accessManager->getPersonID();
         // Get the permissions the person has.
         $this->adminManager->loadByPersonID($personID);
         $directed_staff = '';
         $directed_people = '';
         // Super-admin
         if ($this->adminManager->hasSitePriv()) {
             $this->access_level = page_ViewCustomReport::SUPERADMIN;
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $director_id = $this->getStaffIDfromViewerID();
                 $staffManager = new RowManager_StaffDirectorManager();
                 $staffManager->setDirectorID($director_id);
                 /* Retrieve all directors under the current director */
                 $hierarchy_result = $staffManager->getDirectorHierarchy($director_id);
                 $hierarchy_result->setFirst();
                 $hierarchy_array = array();
                 $directed_staff = '';
                 while ($hierarchy_result->moveNext()) {
                     $staff_ids = $hierarchy_result->getCurrentRow();
                     // 	           echo 'array = <pre>'.print_r($hierarchy_array,true).'</pre>';
                     for ($lvl = 1; $lvl <= MAX_DIRECTOR_LEVELS; $lvl++) {
                         $staff_id = $staff_ids['staff_lvl' . $lvl];
                         if ($staff_id != null) {
                             $directed_staff .= $staff_id . ',';
                         }
                     }
                 }
                 if ($directed_staff != '') {
                     $directed_staff = substr($directed_staff, 0, -1);
                     $this->access_level = page_ViewCustomReport::DIRECTOR;
                 } else {
                     $directed_staff = page_ViewCustomReport::NON_DIRECTOR;
                     $this->access_level = page_ViewCustomReport::NON_DIRECTOR;
                 }
                 $personGetter = new MultiTableManager();
                 $person_info = new RowManager_PersonManager();
                 $staff = new RowManager_StaffManager();
                 $personGetter->addRowManager($person_info);
                 $personGetter->addRowManager($staff, new JoinPair($staff->getJoinOnPersonID(), $person_info->getJoinOnPersonID()));
                 $personGetter->addSearchCondition('staff_id in (' . $directed_staff . ')');
                 $staffPersonList = $personGetter->getListIterator();
                 $staffPersonArray = $staffPersonList->getDataList();
                 foreach (array_keys($staffPersonArray) as $key) {
                     $record = current($staffPersonArray);
                     $directed_people .= $record['person_id'] . ',';
                     next($staffPersonArray);
                 }
                 $directed_people = substr($directed_people, 0, -1);
                 //remove last comma
             } else {
                 $this->access_level = page_ViewCustomReport::UNAUTHORIZED_DIRECTOR;
             }
         }
         // Retrieve custom report fields and store them in data columns for easy display
         $dataAccessObject = new MultiTableManager();
         $person_manager = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($person_manager);
         $fieldList = '';
         $temp_tables = array();
         for ($i = 0; $i < count($this->fields_id_array); $i++) {
             $tempTableCreationSQLmaker = new MultiTableManager();
             $fieldvalue_manager = new RowManager_FormFieldValueManager();
             $fieldvalue_manager->setFieldID($this->fields_id_array[$i]);
             // 			  if ($this->access_level == page_ViewCustomReport::UNAUTHORIZED_DIRECTOR)
             // 			  {
             //  			  		$fieldvalue_manager->setPersonID($personID);		// only show staff's own data
             // 		  	  }
             // 		  	  else if ($this->access_level == page_ViewCustomReport::DIRECTOR)
             // 		  	  {
             // 					$fieldvalue_manager->addSearchCondition('person_id in ('.$directed_people.')');
             // 		  	  }
             // 		  	  else if ($this->access_level == page_ViewCustomReport::NON_DIRECTOR)		// director with no underlings
             // 		  	  {
             // 			  	  $fieldvalue_manager->setPersonID($personID);		// only show staff's own data
             // 		  	  }
             // 		  	  else if ($this->access_level == page_ViewCustomReport::SUPERADMIN)
             // 		  	  {
             // 			  	  // no restrictions
             // 		  	  }
             // Create a temporary table from a SQL join retrieving the data for a particular form field
             $tempTableCreationSQLmaker->addRowManager($fieldvalue_manager);
             $fields_manager = new RowManager_FormFieldManager();
             $tempTableCreationSQLmaker->addRowManager($fields_manager, new JoinPair($fieldvalue_manager->getJoinOnFieldID(), $fields_manager->getJoinOnFieldID()));
             $customfields_manager = new RowManager_CustomFieldsManager();
             $customfields_manager->setReportID($this->customreport_id);
             $tempTableCreationSQLmaker->addRowManager($customfields_manager, new JoinPair($fieldvalue_manager->getJoinOnFieldID(), $customfields_manager->getJoinOnFieldID()));
             $tempFieldList = 'person_id,fieldvalues_value';
             $tempTableCreationSQLmaker->setFieldList($tempFieldList);
             $tempTableCreationSQL = $tempTableCreationSQLmaker->createSQL();
             $temp_tables[$i] = new TempTableManager('temptable' . $i, $tempTableCreationSQL, $tempFieldList, 'temptable' . $i);
             //$PRIMARY_ID=-1
             $temp_tables[$i]->createTable(true);
             // Join the temporary tables together to get a table of n+1 columns where n = count($this->field_ids_array) and the extra column stores person_id
             if ($i > 0) {
                 $fieldList .= ',temptable' . $i . '.fieldvalues_value as value' . $i;
                 $i_minus = $i - 1;
                 $dataAccessObject->addRowManager($temp_tables[$i], new JoinPair($temp_tables[$i_minus]->getJoinOnFieldX(page_ViewCustomReport::JOIN_FIELD), $temp_tables[$i]->getJoinOnFieldX(page_ViewCustomReport::JOIN_FIELD), JOIN_TYPE_LEFT));
             } else {
                 $fieldList .= 'cim_hrdb_person.person_id,temptable' . $i . '.fieldvalues_value as value' . $i;
                 $dataAccessObject->addRowManager($temp_tables[0], new JoinPair($person_manager->getJoinOnFieldX(page_ViewCustomReport::JOIN_FIELD), $temp_tables[0]->getJoinOnFieldX(page_ViewCustomReport::JOIN_FIELD)));
             }
         }
         // Filter results by directed people IDs (if viewer is NOT super-admin)
         if ($this->access_level != page_ViewCustomReport::SUPERADMIN) {
             // 			  	  for ($i=0; $i < count($this->fields_id_array); $i++)
             // 				  {
             // 					  if ($this->access_level == page_ViewCustomReport::UNAUTHORIZED_DIRECTOR)
             // 					  {
             // 						  	$dataAccessObject->addSearchCondition('temptable'.$i.'.person_id in ('.$personID.')');			// only show staff's own data
             // 				  	  }
             // 				  	  else if ($this->access_level == page_ViewCustomReport::DIRECTOR)
             // 				  	  {
             // 							$dataAccessObject->addSearchCondition('temptable'.$i.'.person_id in ('.$directed_people.')');
             // 				  	  }
             // 				  	  else if ($this->access_level == page_ViewCustomReport::NON_DIRECTOR)		// director with no underlings
             // 				  	  {
             // 						  	$dataAccessObject->addSearchCondition('temptable'.$i.'.person_id in ('.$personID.')');			// only show staff's own data
             // 				  	  }
             // 			  	  }
             $dataAccessObject->addSearchCondition('cim_hrdb_person.person_id in (' . $directed_people . ')');
         }
         // 	  	  echo '<pre>'.print_r($temp_tables[0]->getListIterator()->getDataList(),true).'</pre>';
         // $temp_tables[0]->db->runSQL('select * from temptable0');
         $dataAccessObject->setFieldList($fieldList);
         $dataAccessObject->setSortOrder($this->sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
         // 			echo '<pre>'.print_r($this->listManager->getDataList(),true).'</pre>';
     } else {
         $dataAccessObject = new MultiTableManager();
         $person_manager = new RowManager_PersonManager();
         $person_manager->setPersonID(page_ViewCustomReport::NO_FIELDS_SET);
         $dataAccessObject->addRowManager($person_manager);
         $dataAccessObject->setSortOrder($this->sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
         $this->is_blank_page = true;
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewCustomReport::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->listLabels = $this->getListLabels($this->customreport_id);
     // NOTE: parameter *required*
     //        foreach (array_keys($this->listLabels,true) as $key)
     //        {
     // 	       $label = current($this->listLabels);
     //        	 $this->labels->setLabelTag('[title_value0]', '<title in tool_setup>', 'Monthly Support Goal');   // NOTE: cannot be used because nothing set in tool_setup
     //        echo 'labels = <pre>'.print_r($this->listLabels,true).'</pre>';
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $campus_id = "")
 {
     parent::__construct(page_PeoplebyCampuses::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($campusAdminManager);
             $multiTableManager->setSortOrder('campus_desc');
             $campusManager = new RowManager_CampusManager();
             $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusAdminManager->getJoinOnCampusID()));
             $this->campusList = $multiTableManager->getListIterator();
             $this->accessibleCampuses = array();
             $this->campusList->setFirst();
             while ($this->campusList->moveNext()) {
                 $campusAdminObject = $this->campusList->getCurrent(new RowManager_CampusAdminManager());
                 $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                 $this->accessibleCampuses[$campusAdminObject->getCampusID()] = $campusObject->getLabel();
             }
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $this->accessibleCampuses = array();
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $this->accessibleCampuses[$campusAssignObject->getCampusID()] = $campusObject->getLabel();
                 }
             } else {
                 $campusManager = new RowManager_CampusManager();
                 $campusManager->setSortOrder('campus_desc');
                 $this->campusList = $campusManager->getListIterator();
                 $this->accessibleCampuses = $this->campusList->getDropListArray();
             }
         }
     }
     // modify the campus_id if necessary
     if ($this->campus_id == page_PeoplebyCampuses::DISPLAY_ALL_ID) {
         // setting the campus id to blank will get entries from all the campuses
         $this->campus_id = '';
     } else {
         if ($this->campus_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->accessibleCampuses as $key => $value) {
                 $this->campus_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->campus_id == '') {
                 die("ERROR - campusID not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     $assignmentsManager = new RowManager_AssignmentsManager();
     $assignmentsManager->setCampusID($this->campus_id);
     $dataAccessObject->addRowManager($assignmentsManager);
     $personManager = new RowManager_PersonManager();
     $joinPair = new JoinPair($personManager->getJoinOnPersonID(), $assignmentsManager->getJoinOnPersonID());
     $dataAccessObject->addRowManager($personManager, $joinPair);
     $this->accessManager = new RowManager_AccessManager();
     $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $this->accessManager->getJoinOnPersonID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->accessManager, $joinPair2);
     $this->viewerManager = new RowManager_UserManager();
     $joinPair3 = new JoinPair($this->accessManager->getJoinOnViewerID(), $this->viewerManager->getJoinOnViewerID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->viewerManager, $joinPair3);
     if ($sortBy == '') {
         $sortBy = 'person_lname';
     }
     $dataAccessObject->setSortOrder($sortBy);
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_PeoplebyCampuses::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $staffactivity_id = '', $activitytype_id = '', $disable_heading = false, $start_date = '', $end_date = '')
 {
     // remove activity types from page listing if there is only one common activity type
     if ($activitytype_id != '') {
         $DISPLAY_FIELDS = 'person_id,staffactivity_startdate,staffactivity_enddate,staffactivity_contactPhone';
         parent::__construct($DISPLAY_FIELDS);
     } else {
         parent::__construct(page_ViewStaffActivities::DISPLAY_FIELDS);
     }
     //         $this->testdate = $start_date;
     //         echo 'dates = '.$start_date.' and '.$end_date;
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->staffactivityID = $staffactivity_id;
     $this->activityTypeID = $activitytype_id;
     $this->disableHeading = $disable_heading;
     // Default sorting: person_id, start_date, end_date   // TODO: use person name not person_id
     if ($sortBy == '') {
         $sortBy = 'person_id,staffactivity_startdate,staffactivity_enddate';
     }
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // Super-admin
     if ($this->adminManager->hasSitePriv()) {
         /*** Setup basic details for Staff Activity data-access object **/
         if ($this->staffactivityID != '') {
             $dataAccessObject = new RowManager_StaffActivityManager($this->staffactivityID);
         } else {
             $dataAccessObject = new RowManager_StaffActivityManager();
         }
         if ($this->activityTypeID != '') {
             $dataAccessObject->setActivityTypeID($this->activityTypeID);
         }
         if ($start_date != '' && $end_date != '') {
             // Create sub-query 1: activity date-range falls exactly within (or equal to) the date-range parameters
             $activities1 = new RowManager_StaffActivityManager();
             $activities_manager1 = new MultiTableManager();
             $activities_manager1->addRowManager($activities1);
             $activities_manager1->setFieldList('staffactivity_id');
             $dateWithinRange = "staffactivity_startdate >= '" . $start_date . "' and staffactivity_enddate <= '" . $end_date . "'";
             $activities_manager1->addSearchCondition($dateWithinRange);
             $internalRange_subQuery = $activities_manager1->createSQL();
             // Create sub-query 2: activity date-range encloses (or is equal to) the date-range parameters
             $activities2 = new RowManager_StaffActivityManager();
             $activities_manager2 = new MultiTableManager();
             $activities_manager2->addRowManager($activities2);
             $activities_manager2->setFieldList('staffactivity_id');
             $dateWithinRange = "staffactivity_startdate <= '" . $start_date . "' and staffactivity_enddate >= '" . $end_date . "'";
             $activities_manager2->addSearchCondition($dateWithinRange);
             $containsRange_subQuery = $activities_manager2->createSQL();
             // Create final query condition which includes Case 3: date-range parameters are intersected by activity date-range
             $validDateConditions = "staffactivity_startdate between '" . $start_date . "' and '" . $end_date . "' or ";
             $validDateConditions .= "staffactivity_enddate between '" . $start_date . "' and '" . $end_date . "' or ";
             $validDateConditions .= "staffactivity_id in (" . $internalRange_subQuery . ") or ";
             $validDateConditions .= "staffactivity_id in (" . $containsRange_subQuery . ")";
             $dataAccessObject->addSearchCondition($validDateConditions);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         if ($this->adminManager->isStaff($viewer->getID())) {
             $director_id = $this->getStaffIDfromViewerID();
             // 	        $staffPersonManager = new MultiTableManager();
             $staffManager = new RowManager_StaffDirectorManager();
             $staffManager->setDirectorID($director_id);
             // 	        $staffInfoManager = new RowManager_StaffManager();
             // 	        $staffPersonManager->addRowManager($staffInfoManager);
             // 	        $staffPersonManager->addRowManager($staffManager, new JoinPair($staffManager->getJoinOnStaffID(),$staffInfoManager->getJoinOnStaffID()));
             // 	        $staffList = $staffPersonManager->getListIterator();
             // 	        $staffArray = $staffList->getDataList();
             /* Retrieve all directors under the current director */
             $hierarchy_result = $staffManager->getDirectorHierarchy($director_id);
             $hierarchy_result->setFirst();
             $hierarchy_array = array();
             $directed_staff = '';
             while ($hierarchy_result->moveNext()) {
                 $staff_ids = $hierarchy_result->getCurrentRow();
                 // 	           echo 'array = <pre>'.print_r($hierarchy_array,true).'</pre>';
                 for ($lvl = 1; $lvl <= MAX_DIRECTOR_LEVELS; $lvl++) {
                     $staff_id = $staff_ids['staff_lvl' . $lvl];
                     if ($staff_id != null) {
                         $directed_staff .= $staff_id . ',';
                     }
                 }
             }
             if ($directed_staff != '') {
                 $directed_staff .= $director_id;
                 //= substr( $directed_staff, 0, -1 );
             } else {
                 $directed_staff = $director_id;
                 //page_ViewScheduleCalendar::NON_DIRECTOR;
             }
             // Filter activities by those staff persons found in the list of staff under the direction of the current viewer
             $dataAccessObject = new MultiTableManager();
             $schedules = new RowManager_StaffScheduleManager();
             // 	        $schedules->addSearchCondition('person_id in ('.$directed_staff.')');
             $schedule_activities = new RowManager_ActivityScheduleManager();
             $activities = new RowManager_StaffActivityManager();
             if ($this->staffactivityID != '') {
                 $activities = new RowManager_StaffActivityManager($this->staffactivityID);
             }
             if ($this->activityTypeID != '') {
                 $activities->setActivityTypeID($this->activityTypeID);
             }
             $validDateConditions = '';
             if ($start_date != '' && $end_date != '') {
                 // Create sub-query 1: activity date-range falls exactly within (or equal to) the date-range parameters
                 $activities1 = new RowManager_StaffActivityManager();
                 $activities_manager1 = new MultiTableManager();
                 $activities_manager1->addRowManager($activities1);
                 $activities_manager1->setFieldList('staffactivity_id');
                 $dateWithinRange = "staffactivity_startdate >= '" . $start_date . "' and staffactivity_enddate <= '" . $end_date . "'";
                 $activities_manager1->addSearchCondition($dateWithinRange);
                 $internalRange_subQuery = $activities_manager1->createSQL();
                 // Create sub-query 2: activity date-range falls exactly within (or equal to) the date-range parameters
                 $activities2 = new RowManager_StaffActivityManager();
                 $activities_manager2 = new MultiTableManager();
                 $activities_manager2->addRowManager($activities2);
                 $activities_manager2->setFieldList('staffactivity_id');
                 $dateWithinRange = "staffactivity_startdate <= '" . $start_date . "' and staffactivity_enddate >= '" . $end_date . "'";
                 $activities_manager2->addSearchCondition($dateWithinRange);
                 $containsRange_subQuery = $activities_manager2->createSQL();
                 // Create final query condition which includes Case 3: date-range parameters are intersected by activity date-range
                 $validDateConditions = "staffactivity_startdate between '" . $start_date . "' and '" . $end_date . "' or ";
                 $validDateConditions .= "staffactivity_enddate between '" . $start_date . "' and '" . $end_date . "' or ";
                 $validDateConditions .= "cim_hrdb_staffactivity.staffactivity_id in (" . $internalRange_subQuery . ") or ";
                 $validDateConditions .= "cim_hrdb_staffactivity.staffactivity_id in (" . $containsRange_subQuery . ")";
                 // 	        	  $activities->addSearchCondition($validDateConditions);
             }
             // 	        $activityTypes = new RowManager_ActivityTypeManager();
             $person_info = new RowManager_PersonManager();
             $staff = new RowManager_StaffManager();
             $dataAccessObject->addRowManager($activities);
             $dataAccessObject->addRowManager($schedule_activities, new JoinPair($activities->getJoinOnActivityID(), $schedule_activities->getJoinOnActivityID()));
             $dataAccessObject->addRowManager($schedules, new JoinPair($schedules->getJoinOnScheduleID(), $schedule_activities->getJoinOnScheduleID()));
             // 	        $dataAccessObject->addRowManager($activityTypes, new JoinPair($activityTypes->getJoinOnActivityTypeID(), $activities->getJoinOnActivityTypeID()));
             $dataAccessObject->addRowManager($person_info, new JoinPair($person_info->getJoinOnPersonID(), $activities->getJoinOnPersonID()));
             $dataAccessObject->addRowManager($staff, new JoinPair($staff->getJoinOnPersonID(), $person_info->getJoinOnPersonID()));
             $dataAccessObject->addSearchCondition('staff_id in (' . $directed_staff . ')');
             // 	        $dataAccessObject->setFieldList('cim_hrdb_staffactivity.person_id,staffactivity_startdate,staffactivity_enddate,staffactivity_contactPhone');	//page_ViewStaffActivities::DISPLAY_FIELDS);
             if ($validDateConditions != '') {
                 $dataAccessObject->addSearchCondition($validDateConditions);
             }
             // 	    	 if (!isset($sortBy)||($sortBy == ''))
             // 			  {
             // 				  $sortBy = 'person_lname';		// TODO: remove this once we figure how to sort person even if name is cover for person_id
             // 			  }
             // 			  $dataAccessObject->setSortOrder( $sortBy );
             $list_iterator = $dataAccessObject->getListIterator();
             $data_array = $list_iterator->getDataList();
             // Go through the inefficient process of grabbing staff activity IDs  (could do min. as subquery)
             $staff_activities = '';
             reset($data_array);
             foreach (array_keys($data_array) as $key) {
                 $row = current($data_array);
                 $staff_activities .= $row['staffactivity_id'] . ',';
                 next($data_array);
             }
             if ($staff_activities != '') {
                 $staff_activities = substr($staff_activities, 0, -1);
             } else {
                 $staff_activities = page_ViewStaffActivities::NO_ACTIVITIES;
             }
             // 	        echo "<pre>".print_r($data_array,true)."</pre>";
             // 	        echo '<br>activities = '.$staff_activities.'<br>';
             /** Apparently we need to use single row manager for staff activity table:
                 therefore use found activity IDs... **/
             $activities2 = new RowManager_StaffActivityManager($this->staffactivityID);
             $activities2->addSearchCondition('staffactivity_id in (' . $staff_activities . ')');
             if (!isset($sortBy) || $sortBy == '' || $sortBy == 'person_id') {
                 $sortBy = 'person_lname';
                 // TODO: remove this once we figure how to sort person even if name is cover for person_id
             }
             $activities2->setSortOrder($sortBy);
             $this->listManager = $activities2->getListIterator();
             // dataAccessObject
             // 	        echo "<pre>".print_r($this->listManager->getDataList(),true)."</pre>";
         } else {
             $dataAccessObject = new RowManager_StaffActivityManager(page_ViewStaffActivities::UNAUTHORIZED_DIRECTOR);
             $this->listManager = $dataAccessObject->getListIterator();
         }
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewStaffActivities::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }