/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to this module's root directory * @param $viewer [OBJECT] The viewer object. * @param $formAction [STRING] The action on a form submit * @param $person_id [INTEGER] Value used to initialize the dataManager * @return [void] */ function __construct($pathModuleRoot, $viewer, $formAction, $person_id) { // NOTE: be sure to call the parent constructor before trying to // use the ->formXXX arrays... $fieldList = FormProcessor_EditMyInfo::FORM_FIELDS; $fieldDisplayTypes = FormProcessor_EditMyInfo::FORM_FIELD_TYPES; parent::__construct($formAction, $fieldList, $fieldDisplayTypes); $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->person_id = $person_id; // To make sure this is not exploited to edit any other person's id. // If the user has no privileges, this sets the viewer id to be his/her own, // even if the variable given to it is not the viewer's person id. // NOTE: anyone with higher previliges can edit any person's info, by simply // changing the posted variable value. // Now load the access Priviledge manager of this viewer $this->accessPrivManager = 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->accessPrivManager->loadByPersonID($personID); if (!$this->accessPrivManager->isLoaded()) { $this->person_id = $personID; } //End of check. // figure out the important fields for the dataManager $fieldsOfInterest = implode(',', $this->formFields); $this->dataManager = new RowManager_PersonManager($this->person_id); $this->dataManager->setFieldsOfInterest($fieldsOfInterest); $this->formValues = $this->dataManager->getArrayOfValues(); // 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 = FormProcessor_EditMyInfo::MULTILINGUAL_PAGE_KEY; $this->labels->loadPageLabels($pageKey); // load the site default form link labels $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS); }
/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to the module's root dir. * @param $viewer [OBJECT] The viewer object. * @return [void] */ function __construct($pathModuleRoot, $viewer, $formAction, $sortBy) { // NOTE: be sure to call the parent constructor before trying to // use the ->formXXX arrays... $fieldList = ''; //FormProcessor_ManageSuperAdmin::FORM_FIELDS; $fieldTypes = ''; //FormProcessor_ManageSuperAdmin::FORM_FIELD_TYPES; $displayFields = ''; //FormProcessor_ManageSuperAdmin::DISPLAY_FIELDS; parent::__construct($formAction, '', ''); // initialzie the object values $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; // 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 = page_MySchedule::MULTILINGUAL_PAGE_KEY; $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey); // init the person id // figure out the viewer's person ID $accessManager = new RowManager_AccessManager(); $accessManager->loadByViewerID($this->viewer->getViewerID()); $this->personID = $accessManager->getPersonID(); echo "Your person ID is:" . $this->personID . "<br/>"; // set the schedule id $scheduleManager = new RowManager_ScheduleManager(); $scheduleManager->setPersonID($this->personID); $scheduleList = new ListIterator($scheduleManager); $scheduleList->setFirst(); $this->scheduleID = -1; if ($scheduleList->moveNext()) { $schManager = $scheduleList->getCurrent(new RowManager_ScheduleManager()); $this->scheduleID = $schManager->getScheduleID(); echo "Schedule ID:" . $this->scheduleID . "<br/>"; } else { echo "ERROR finding schedule id.<br/>"; } }
/** * 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 loadData * * @abstract Provided function to allow object to load it's data. * */ function loadData() { /*[RAD_PAGE_STATEVAR_INIT]*/ // Now check to see if a Application ID was given // $this->appID = $this->getQSValue( modulecim_hrdb::APPID, '' ); // load the common page layout object $this->pageCommonDisplay = new CommonDisplay($this->moduleRootPath, $this->pathToRoot, $this->viewer); // load the module's page (DEFAULT = WELCOME) $this->page = $this->getQSValue(modulecim_hrdb::PAGE, modulecim_hrdb::PAGE_HRDBHOME); // load the module's sortBy parameter (DEFAULT = '') $this->sortBy = $this->getQSValue(modulecim_hrdb::SORTBY, ''); // load the module's PERSON_ID variable $this->PERSON_ID = $this->getQSValue(modulecim_hrdb::PERSON_ID, ""); // load the module's PROVINCE_ID variable $this->PROVINCE_ID = $this->getQSValue(modulecim_hrdb::PROVINCE_ID, ""); // load the module's GENDER_ID variable $this->GENDER_ID = $this->getQSValue(modulecim_hrdb::GENDER_ID, ""); // load the module's STAFF_ID variable $this->STAFF_ID = $this->getQSValue(modulecim_hrdb::STAFF_ID, ""); // load the module's CAMPUS_ID variable $this->CAMPUS_ID = $this->getQSValue(modulecim_hrdb::CAMPUS_ID, ""); // load the module's ADMIN_ID variable $this->ADMIN_ID = $this->getQSValue(modulecim_hrdb::ADMIN_ID, ""); // load the module's PRIV_ID variable $this->PRIV_ID = $this->getQSValue(modulecim_hrdb::PRIV_ID, ""); // load the module's CAMPUSADMIN_ID variable $this->CAMPUSADMIN_ID = $this->getQSValue(modulecim_hrdb::CAMPUSADMIN_ID, ""); // load the module's USER_ID variable $this->USER_ID = $this->getQSValue(modulecim_hrdb::USER_ID, ""); // load the module's ASSIGNMENT_ID variable $this->ASSIGNMENT_ID = $this->getQSValue(modulecim_hrdb::ASSIGNMENT_ID, ""); // load the module's REGION_ID variable $this->REGION_ID = $this->getQSValue(modulecim_hrdb::REGION_ID, ""); // load the module's EMERG_ID variable $this->EMERG_ID = $this->getQSValue(modulecim_hrdb::EMERG_ID, ""); // load the module's ASSIGNSTATUS_ID variable $this->ASSIGNSTATUS_ID = $this->getQSValue(modulecim_hrdb::ASSIGNSTATUS_ID, ""); // load the module's VIEWER_ID variable $this->VIEWER_ID = $this->getQSValue(modulecim_hrdb::VIEWER_ID, ""); // load the module's ACCESS_ID variable $this->ACCESS_ID = $this->getQSValue(modulecim_hrdb::ACCESS_ID, ""); // load the module's REG_ID variable $this->REG_ID = $this->getQSValue(modulecim_hrdb::REG_ID, ""); // load the module's YEAR_ID variable $this->YEAR_ID = $this->getQSValue(modulecim_hrdb::YEAR_ID, ""); // load the module's PERSON_YEAR_ID variable $this->PERSON_YEAR_ID = $this->getQSValue(modulecim_hrdb::PERSON_YEAR_ID, ""); // load the module's COUNTRY_ID variable $this->COUNTRY_ID = $this->getQSValue(modulecim_hrdb::COUNTRY_ID, ""); // load the module's STAFFSCHEDULE_ID variable $this->STAFFSCHEDULE_ID = $this->getQSValue(modulecim_hrdb::STAFFSCHEDULE_ID, ""); // load the module's STAFFACTIVITY_ID variable $this->STAFFACTIVITY_ID = $this->getQSValue(modulecim_hrdb::STAFFACTIVITY_ID, ""); // load the module's ACTIVITYTYPE_ID variable $this->ACTIVITYTYPE_ID = $this->getQSValue(modulecim_hrdb::ACTIVITYTYPE_ID, ""); // load the module's STAFFSCHEDULETYPE_ID variable $this->STAFFSCHEDULETYPE_ID = $this->getQSValue(modulecim_hrdb::STAFFSCHEDULETYPE_ID, ""); // load the module's ACTIVITYSCHEDULE_ID variable $this->ACTIVITYSCHEDULE_ID = $this->getQSValue(modulecim_hrdb::ACTIVITYSCHEDULE_ID, ""); // load the module's FIELD_ID variable $this->FIELD_ID = $this->getQSValue(modulecim_hrdb::FIELD_ID, ""); // load the module's FIELDVALUE_ID variable $this->FIELDVALUE_ID = $this->getQSValue(modulecim_hrdb::FIELDVALUE_ID, ""); // load the module's FIELDTYPE_ID variable $this->FIELDTYPE_ID = $this->getQSValue(modulecim_hrdb::FIELDTYPE_ID, ""); // load the module's DATATYPE_ID variable $this->DATATYPE_ID = $this->getQSValue(modulecim_hrdb::DATATYPE_ID, ""); // load the module's FIELDGROUP_ID variable $this->FIELDGROUP_ID = $this->getQSValue(modulecim_hrdb::FIELDGROUP_ID, ""); // load the module's FIELDGROUP_MATCHES_ID variable $this->FIELDGROUP_MATCHES_ID = $this->getQSValue(modulecim_hrdb::FIELDGROUP_MATCHES_ID, ""); // load the module's STAFFDIRECTOR_ID variable $this->STAFFDIRECTOR_ID = $this->getQSValue(modulecim_hrdb::STAFFDIRECTOR_ID, ""); // load the module's MONTH_ID variable $this->MONTH_ID = $this->getQSValue(modulecim_hrdb::MONTH_ID, ""); // load the module's REPORT_ID variable $this->REPORT_ID = $this->getQSValue(modulecim_hrdb::REPORT_ID, ""); // load the module's CUSTOMFIELD_ID variable $this->CUSTOMFIELD_ID = $this->getQSValue(modulecim_hrdb::CUSTOMFIELD_ID, ""); // load the module's MINISTRY_ID variable $this->MINISTRY_ID = $this->getQSValue(modulecim_hrdb::MINISTRY_ID, ""); /*[RAD_PAGE_LOAD_STATEVAR]*/ // load the module's DOWNLOAD_TYPE variable $this->DOWNLOAD_TYPE = $this->getQSValue(modulecim_hrdb::DOWNLOAD_TYPE, ""); // load the module's FORMLIST_TYPE variable $this->FORMLIST_TYPE = $this->getQSValue(modulecim_hrdb::FORMLIST_TYPE, ""); // load the module's SEARCH_STARTDATE variable $this->SEARCH_STARTDATE = $this->getQSValue(modulecim_hrdb::SEARCH_STARTDATE, ""); // load the module's SEARCH_ENDDATE variable $this->SEARCH_ENDDATE = $this->getQSValue(modulecim_hrdb::SEARCH_ENDDATE, ""); //Get person's permissions // Get the person ID $accessManager = new RowManager_AccessManager(); $accessManager->loadByViewerID($this->viewer->getViewerID()); $personID = $accessManager->getPersonID(); // Now load the access Priviledge manager of this viewer $this->accessPrivManager = new RowManager_AdminManager(); // Get the permissions the person has. $this->accessPrivManager->loadByPersonID($personID); //Now do overall stuff based on permissions //NOTE: Put the below 3 lines in the case statement for the page you want to block off from regular users. // if ( !$this->accessPrivManager->isLoaded() ) { // //PAGE_HRDBHOME can be replaced by the page you want to redirect the person to. // $this->page = modulecim_hrdb::PAGE_HRDBHOME;//PAGE_NOTALLOWED; // } //End of general permission checking. switch ($this->page) { /* * Not Authorized page */ case modulecim_reg::PAGE_NOTAUTHORIZED: $this->loadNotAuthorized(); break; /* * EditMyInfo */ /* * EditMyInfo */ case modulecim_hrdb::PAGE_EDITMYINFO: $this->loadEditMyInfo(); break; /* * HrdbHome */ /* * HrdbHome */ case modulecim_hrdb::PAGE_HRDBHOME: $this->loadHrdbHome(); break; /* * Provinces */ /* * Provinces */ case modulecim_hrdb::PAGE_PROVINCES: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadProvinces(); break; /* * ImportData */ /* * ImportData */ case modulecim_hrdb::PAGE_IMPORTDATA: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadImportData(); break; /* * Campuses */ /* * Campuses */ case modulecim_hrdb::PAGE_CAMPUSES: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadCampuses(); break; /* * NewPerson */ /* * NewPerson */ case modulecim_hrdb::PAGE_NEWPERSON: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadNewPerson(); break; /* * Privileges */ /* * Privileges */ case modulecim_hrdb::PAGE_PRIVILEGES: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPrivileges(); break; /* * People */ /* * People */ case modulecim_hrdb::PAGE_PEOPLE: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPeople(); break; /* * PeopleList */ /* * PeopleList */ case modulecim_hrdb::PAGE_PEOPLELIST: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPeopleList(); break; /* * DeletePerson */ /* * DeletePerson */ case modulecim_hrdb::PAGE_DELETEPERSON: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadDeletePerson(); break; /* * ViewStaff */ /* * ViewStaff */ case modulecim_hrdb::PAGE_VIEWSTAFF: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadViewStaff(); break; /* * AddAdmin */ /* * AddAdmin */ case modulecim_hrdb::PAGE_ADDADMIN: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadAddAdmin(); break; /* * EditPerson */ /* * EditPerson */ case modulecim_hrdb::PAGE_EDITPERSON: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadEditPerson(); break; /* * AddStaff */ /* * AddStaff */ case modulecim_hrdb::PAGE_ADDSTAFF: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadAddStaff(); break; /* * Staff */ /* * Staff */ case modulecim_hrdb::PAGE_STAFF: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadStaff(); break; /* * DeleteStaff */ /* * DeleteStaff */ case modulecim_hrdb::PAGE_DELETESTAFF: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadDeleteStaff(); break; /* * Admins */ /* * Admins */ case modulecim_hrdb::PAGE_ADMINS: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadAdmins(); break; /* * DeleteAdmin */ /* * DeleteAdmin */ case modulecim_hrdb::PAGE_DELETEADMIN: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadDeleteAdmin(); break; /* * ViewCampuses */ /* * ViewCampuses */ case modulecim_hrdb::PAGE_VIEWCAMPUSES: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadViewCampuses(); break; /* * CampusAssignments */ /* * CampusAssignments */ case modulecim_hrdb::PAGE_CAMPUSASSIGNMENTS: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadCampusAssignments(); break; /* * PersonInfo */ /* * PersonInfo */ case modulecim_hrdb::PAGE_PERSONINFO: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPersonInfo(); break; /* * PeopleCampus */ /* * PeopleCampus */ case modulecim_hrdb::PAGE_PEOPLECAMPUS: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPeopleCampus(); break; /* * PeoplebyCampuses */ /* * PeoplebyCampuses */ case modulecim_hrdb::PAGE_PEOPLEBYCAMPUSES: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadPeoplebyCampuses(); break; /* * AdminPrivs */ /* * AdminPrivs */ case modulecim_hrdb::PAGE_ADMINPRIVS: if (!$this->accessPrivManager->isLoaded()) { $this->page = modulecim_hrdb::PAGE_HRDBHOME; //PAGE_NOTALLOWED; } $this->loadAdminPrivs(); break; /* * NewAccount */ /* * NewAccount */ case modulecim_hrdb::PAGE_NEWACCOUNT: $this->loadNewAccount(); break; /* * EditMyEmergInfo */ /* * EditMyEmergInfo */ case modulecim_hrdb::PAGE_EDITMYEMERGINFO: $this->loadEditMyEmergInfo(); break; /* * EditCampusAssignmentStatusTypes */ /* * EditCampusAssignmentStatusTypes */ case modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENTSTATUSTYPES: $this->loadEditCampusAssignmentStatusTypes(); break; /* * EditCampusAssignment */ /* * EditCampusAssignment */ case modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENT: $this->loadEditCampusAssignment(); break; /* * EditRegion */ /* * EditRegion */ case modulecim_hrdb::PAGE_EDITREGION: $this->loadEditRegion(); break; /* * EditPeople */ /* * EditPeople */ case modulecim_hrdb::PAGE_EDITPEOPLE: $this->loadEditPeople(); break; /* * EditAccessAssignment */ /* * EditAccessAssignment */ case modulecim_hrdb::PAGE_EDITACCESSASSIGNMENT: $this->loadEditAccessAssignment(); break; /* * EditMyCampusAssignment */ /* * EditMyCampusAssignment */ case modulecim_hrdb::PAGE_EDITMYCAMPUSASSIGNMENT: $this->loadEditMyCampusAssignment(); break; /* * EditMyYearInSchool */ /* * EditMyYearInSchool */ case modulecim_hrdb::PAGE_EDITMYYEARINSCHOOL: $this->loadEditMyYearInSchool(); break; /* * EditStudentYearInSchool */ /* * EditStudentYearInSchool */ case modulecim_hrdb::PAGE_EDITSTUDENTYEARINSCHOOL: $this->loadEditStudentYearInSchool(); break; /* * ViewStudentYearInSchool */ /* * ViewStudentYearInSchool */ case modulecim_hrdb::PAGE_VIEWSTUDENTYEARINSCHOOL: $this->loadViewStudentYearInSchool(); break; /* * ViewStudentYearInSchool */ /* * ViewStudentYearInSchool */ case modulecim_hrdb::PAGE_COUNTRIES: $this->loadCountries(); break; /* * DownloadCSV */ /* * DownloadCSV */ case modulecim_hrdb::PAGE_DOWNLOADCSV: $this->loadDownloadCSV(); break; /* * HrdbForms */ /* * HrdbForms */ case modulecim_hrdb::PAGE_HRDBFORMS: $this->loadHrdbForms(); break; /* * EditFormFields */ /* * EditFormFields */ case modulecim_hrdb::PAGE_EDITFORMFIELDS: $this->loadEditFormFields(); break; /* * EditFormFields */ /* * EditFormFields */ case modulecim_hrdb::PAGE_EDITFORMFIELDVALUES: $this->loadEditFormFieldValues(); break; /* * EditStaffActivity */ /* * EditStaffActivity */ case modulecim_hrdb::PAGE_EDITSTAFFACTIVITY: $this->loadEditStaffActivity(); break; /* * EditStaffSchedule */ /* * EditStaffSchedule */ case modulecim_hrdb::PAGE_EDITSTAFFSCHEDULE: $this->loadEditStaffSchedule(); break; /* * ApproveStaffSchedule */ /* * ApproveStaffSchedule */ case modulecim_hrdb::PAGE_APPROVESTAFFSCHEDULE: $this->loadApproveStaffSchedule(); break; /* * FormApprovalListing */ /* * FormApprovalListing */ case modulecim_hrdb::PAGE_FORMAPPROVALLISTING: $this->loadFormApprovalListing(); break; /* * EditStaffFormContext */ /* * EditStaffFormContext */ case modulecim_hrdb::PAGE_EDITSTAFFFORMCONTEXT: $this->loadEditStaffFormContext(); break; /* * EditStaffFormInstructions */ /* * EditStaffFormInstructions */ case modulecim_hrdb::PAGE_EDITSTAFFFORMINSTRUCTIONS: $this->loadEditStaffFormInstructions(); break; /* * EditHrdbForm */ /* * EditHrdbForm */ case modulecim_hrdb::PAGE_EDITHRDBFORM: $this->loadEditHrdbForm(); break; /* * ViewScheduleCalendar */ /* * ViewScheduleCalendar */ case modulecim_hrdb::PAGE_VIEWSCHEDULECALENDAR: $this->loadViewScheduleCalendar(); break; /* * ViewStaffActivities */ /* * ViewStaffActivities */ case modulecim_hrdb::PAGE_VIEWSTAFFACTIVITIES: $this->loadViewStaffActivities(); break; /* * HrdbActivities */ /* * HrdbActivities */ case modulecim_hrdb::PAGE_HRDBACTIVITIES: $this->loadHrdbActivities(); break; /* * ViewActivitiesByDate */ /* * ViewActivitiesByDate */ case modulecim_hrdb::PAGE_VIEWACTIVITIESBYDATE: $this->loadViewActivitiesByDate(); break; /* * FormSubmittedListing */ /* * FormSubmittedListing */ case modulecim_hrdb::PAGE_FORMSUBMITTEDLISTING: $this->loadFormSubmittedListing(); break; /* * EditActivityTypes */ /* * EditActivityTypes */ case modulecim_hrdb::PAGE_EDITACTIVITYTYPES: $this->loadEditActivityTypes(); break; /* * EditCustomReports */ /* * EditCustomReports */ case modulecim_hrdb::PAGE_EDITCUSTOMREPORTS: $this->loadEditCustomReports(); break; /* * ViewCustomReport */ /* * ViewCustomReport */ case modulecim_hrdb::PAGE_VIEWCUSTOMREPORT: $this->loadViewCustomReport(); break; /* * CustomReportsListing */ /* * CustomReportsListing */ case modulecim_hrdb::PAGE_CUSTOMREPORTSLISTING: $this->loadCustomReportsListing(); break; /* * EditStaff */ /* * EditStaff */ case modulecim_hrdb::PAGE_EDITSTAFF: $this->loadEditStaff(); break; /* * EditCustomReportMetaData */ /* * EditCustomReportMetaData */ case modulecim_hrdb::PAGE_EDITCUSTOMREPORTMETADATA: $this->loadEditCustomReportMetaData(); break; /*[RAD_PAGE_LOAD_CALL]*/ /* * Just to make sure, default the pageDisplay to * the HrdbHome page. */ /*[RAD_PAGE_LOAD_CALL]*/ /* * Just to make sure, default the pageDisplay to * the HrdbHome page. */ default: $this->page = modulecim_hrdb::PAGE_HRDBHOME; $this->loadHrdbHome(); break; } /* * Load SideBar Information */ $this->loadSideBar(); /* * Load Form Values if a ProcessData field exists */ if (isset($_REQUEST[PerlFileUpload::DEF_QSPARAM_SID])) { // perlFileUploads don't retain the Process parameter // so we add it here $_REQUEST['Process'] = 'Y'; } if (isset($_REQUEST['Process'])) { $this->pageDisplay->loadFromForm(); } }
/** * 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, $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 __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); }
/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to this module's root directory * @param $viewer [OBJECT] The viewer object. * @param $formAction [STRING] The action on a form submit * @param $ [INTEGER] Value used to initialize the rowManager * @return [void] */ function __construct($pathModuleRoot, $viewer, $formAction, $person_id, $campus_id, $person_year_id = '') { // NOTE: be sure to call the parent constructor before trying to // use the ->formXXX arrays... parent::__construct($formAction, FormProcessor_EditStudentYearInSchool::FORM_FIELDS, FormProcessor_EditStudentYearInSchool::FORM_FIELD_TYPES); $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->formAction = $formAction; $this->campus_id = $campus_id; $this->person_id = $person_id; $this->person_year_id = $person_year_id; // if ($person_year_id == '') // { // if (isset($person_id)) // { // if (isset($campus_id)) // { // } // } // } /**** Check privileges and initialize campus drop-down list ***/ // 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 == FormProcessor_EditStudentYearInSchool::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/>"); } } } /*** end privilege checking and campus droplist setup ***/ // echo 'campus = '.$this->campus_id; // create new rowManager (a List Iterator obj.) $statuses = '0,1,6'; // filter by assignment status in ('undefined', 'current student', 'unknown') $this->rowManager = new PersonYearList($this->campus_id, $statuses, 'year_id,person_lname'); // figure out the important fields for the rowItems $fieldsOfInterest = implode(',', $this->formFields); $this->primaryIDs = array(); // for each row item ... $this->rowManager->setFirst(); $i = 0; $valid_values = explode(',', RowManager_PersonYearManager::FIELD_LIST); while ($rowItem = $this->rowManager->getNext()) { // make sure rowItems have valid entries in the DB if (!$rowItem->isLoaded()) { $rowItem->createNewEntry(); } // set the fields of interest ... $rowItem->setFieldsOfInterest($fieldsOfInterest); // get the primaryID of this rowItem $primaryID = $rowItem->getPrimaryKeyValue(); $this->primaryIDs[$i] = $primaryID; $person_id = -1; // now initialize beginning form values from rowItem object for ($indx = 0; $indx < count($this->formFields); $indx++) { $key = $this->formFields[$indx]; if (in_array($key, $valid_values)) { $this->formValues[$key . $primaryID] = $rowItem->getValueByFieldName($key); if ($key == 'person_id') { $person_id = $this->formValues[$key . $primaryID]; } } else { if ($person_id != '-1') { $person_manager = new RowManager_PersonManager($person_id); $this->formValues[$key . $primaryID] = $person_manager->getValueByFieldName($key); } else { $this->formValues[$key . $primaryID] = ""; } } } // next field $i++; } // next rowItem in rowManager // echo 'array = <pre>'.print_r($this->formValues,true).'</pre>'; // 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 = FormProcessor_EditStudentYearInSchool::MULTILINGUAL_PAGE_KEY; $this->labels->loadPageLabels($pageKey); // load the site default form link labels $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS); }