/** * function viewer_guid_conenct * <pre> * * If user has an exisitng intranet login ($new_viewer == false): * Given GUID and viewer_id, inject GUID into existing viewer * * If user never had an intranet login ($new_viewer == true): * Given a GUID, create new viewer, person, put into access group, etc. * * @param $guid [String] [user's GUID] * @param $viewer [Int] [user's view_id] * @param $new_viewer [BOO] [true when user never had an intranet login] * </pre> * @return [void] * * */ function viewer_guid_connect($guid, $viewer, $new_viewer) { if ($new_viewer) { // 1. create new viewer $viewerManager = new RowManager_ViewerManager(); $viewerManager->setGUID($guid); // GUID $viewerManager->setLanguageID(1); // english // TODO this value should not be hard-coded for the account group $viewerManager->setAccountGroupID(15); // the 'unknown' group $viewerManager->setIsActive(true); $viewerManager->createNewEntry(); $viewerID = $viewerManager->getID(); // get the ID of the newly created viewer // 2. put into the 'all' access group // PART A $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager(); $viewerAccessGroupManager->setViewerID($viewerID); $viewerAccessGroupManager->setAccessGroupID(ALL_ACCESS_GROUP); // add to the 'all' access group $viewerAccessGroupManager->createNewEntry(); // PART B $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager(); $viewerAccessGroupManager->setViewerID($viewerID); $viewerAccessGroupManager->setAccessGroupID(SPT_APPLICANT_ACCESS_GROUP); // add to the 'SPT-Student' access group $viewerAccessGroupManager->createNewEntry(); // 3. create new person (or grab person_id from existing record) $personManager = new RowManager_PersonManager(); $personManager->setFirstName(''); $personManager->setLastName(''); $personManager->setEmail(''); $personManager->setSortOrder('person_id'); $personManager->setAscDesc('DESC'); // sort by descending person IDs $personList = $personManager->getListIterator(); $personArray = $personList->getDataList(); //create new entry $personManager->createNewEntry(); $personID = $personManager->getID(); // get the ID of the newly created person // 4. create an access table entry for this (viewer,person) combo $accessManager = new RowManager_AccessManager(); $accessManager->setViewerID($viewerID); $accessManager->setPersonID($personID); $accessManager->createNewEntry(); } else { $viewerManager = new RowManager_ViewerManager($viewer); //echo ($viewerManager->getID()); $viewerManager->setGUID($guid); // GUID $viewerManager->updateDBTable(); } }
/** * 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_NewPerson::FORM_FIELDS; $fieldDisplayTypes = FormProcessor_NewPerson::FORM_FIELD_TYPES; parent::__construct($formAction, $fieldList, $fieldDisplayTypes); $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->person_id = $person_id; $fieldsOfInterest = implode(',', $this->formFields); // Using Join $dataAccessObject = new MultiTableManager(); $viewerManager = new RowManager_ViewerManager(); $dataAccessObject->addRowManager($viewerManager); $personManager = new RowManager_PersonManager(); $joinPair = new JoinPair($personManager->getJoinOnPersonID(), $viewerManager->getJoinOnPersonID()); $dataAccessObject->addRowManager($personManager, $joinPair); $dataAccessObject->setFieldsOfInterest($fieldsOfInterest); $this->formValues = $dataAccessObject->getArrayOfValues(); // Done using Join // figure out the important fields for the dataManager /*No Join used, only person manager. $this->dataManager = new RowManager_PersonManager( $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_NewPerson::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 processData * <pre> * Processes the data for this form. * </pre> * @return [void] */ function processData() { // initialize the variable storing process report data $reportDataDump = ''; $BR = '<BR>'; $HR = '<HR>'; if ($this->shouldDelete) { // TODO: delete all the dependent data records (otherwise FK constraints will *NOT* allow deletion) // see app_cim_reg/objects_pages/page_ConfirmDeleteRegistration.php $savedPersonID = $this->person_id; // the ID of the person whose records are to be deleted // $reportDataDump .= 'Unique person record tuple:'.$BR.' First Name = '.$person_fname.', Last Name = '.$person_lname.', E-mail = '.$person_email.$BR.$BR; // echo "PERSON NAME: ".$person_fname." ".$person_lname; // echo "PERSON: <pre>".print_r($person,true)."</pre>"; // search for a particular person to see if duplicate records exist // $indiv_person_manager = new RowManager_PersonManager(); $indiv_person_manager = new MultiTableManager(); $indiv_person_manager->addRowManager($this->person_manager); // $indiv_person_manager->setFirstName(addslashes($person_fname)); // use addslashes to escape special chars in string // $indiv_person_manager->setLastName(addslashes($person_lname)); // $indiv_person_manager->setEmail(addslashes($person_email)); // $indiv_person_manager->setSortOrder( 'person_id' ); // $indiv_person_manager->setAscDesc( 'DESC' ); // sort by descending person IDs $indiv_person_manager->addSearchCondition("person_id = '" . $this->person_id . "'"); // use GROUP BY to easily enforce distinct triplets of (person_fname, person_lname, person_email) $groupBy = "person_fname,person_lname,person_email"; $indiv_person_manager->setGroupBy($groupBy); $indivData = $indiv_person_manager->getListIterator(); $indivDataArray = $indivData->getDataList(); // echo " INDIV COUNT: ".count($indivDataArray)."<br><br>"; // echo "INDIV RECORDS: <pre>".print_r($indivDataArray,true)."</pre>"; $person_ids_list = ''; //return all the person's data into array (key = person_id) of arrays (and store total data stored?) if (isset($indivDataArray)) { if (count($indivDataArray) == 0) { echo "ERROR: person was found earlier and now NO records are found!"; } else { if (count($indivDataArray) == 1) { // echo "GREAT! This person only has one record."; reset($indivDataArray); $record = current($indivDataArray); $savedPersonID = $record['person_id']; $person_ids_list = $savedPersonID; $reportDataDump .= 'Unique person id found for tuple: ' . $savedPersonID . $BR . $BR; } else { if (count($indivDataArray) > 1) { // get the person IDs for this individual reset($indivDataArray); foreach (array_keys($indivDataArray) as $l) { $record = current($indivDataArray); $person_ids_list .= $record['person_id']; $person_ids_list .= ','; next($indivDataArray); } $person_ids_list = substr($person_ids_list, 0, -1); // remove final comma $reportDataDump .= 'Multiple person ids found for tuple: ' . $person_ids_list . $BR . $BR; } } } // Search for duplicate person-related entries - for 1 or more person_ids found for current person if ($person_ids_list != '') { // echo "<br> person ids list: ".$person_ids_list."<br>"; // $person_ids_array = explode($person_ids_list,','); // check access table using all the found person IDs - retrieve viewer ids with person id as key $foundViewerIDs = $this->getAccessRecords($person_ids_list); // can safely assume array ISSET // echo 'found viewer ids= <pre>'.print_r($foundViewerIDs,true).'</pre>'; /** IF 0 access table records were found: **/ if (count($foundViewerIDs) == 0) { // TODO?: notify admin that this/these person record(s) require a viewer account // Store the active (latest) person_id in special variable reset($indivDataArray); $savedPersonID = key($indivDataArray); // recall that person_ids are sorted in descending order } else { if (count($foundViewerIDs) >= 1) { /** store the active (access table) person_id in special variable **/ reset($foundViewerIDs); $personIDs = explode(',', $person_ids_list); $savedPersonID = current($personIDs); //current($foundViewerIDs); $reportDataDump .= 'Person ID of the record(s) to delete: ' . $savedPersonID . ' (associated with the most recent person record)' . $BR . $BR; // echo 'latest viewer ids = <pre>'.print_r($foundViewerIDs,true).'</pre>'; // echo 'saved person ID = '.$savedPersonID; $reportDataDump .= 'Changes made to <b>cim_hrdb_access table</b>: ' . $BR; /*** update the access table records to only use latest person ID **/ foreach (array_values($foundViewerIDs) as $person_id) { $viewer_id = key($foundViewerIDs); // echo 'viewer_id = '.$viewer_id; // only delete from the access table record if it needs a different person_id if ($person_id == $savedPersonID) { // get access ID(s) for the record to change $accessManager = new RowManager_AccessManager(); $accessManager->setViewerID($viewer_id); $accessManager->setPersonID(current($foundViewerIDs)); // or just use $person_id $accessData = $accessManager->getListIterator(); $accessDataArray = $accessData->getDataList(); // echo 'access data array = <pre>'.print_r($accessDataArray,true).'</pre>'; reset($accessDataArray); // deal with the unlikely case that we have redundant viewerID-personID records foreach (array_keys($accessDataArray) as $key) { $record = current($accessDataArray); $accessID = $record['access_id']; $reportDataDump .= 'Deleting access table entries linked to person_id = ' . $person_id; $accessDeleter = new RowManager_AccessManager($accessID); $accessDeleter->deleteEntry(); next($accessDataArray); } } $id = next($foundViewerIDs); // person_id if ($id === FALSE) { break; // no valid data found so break out of the loop } } } } /** <end> access table entry deletion **/ $baseRecord = $indivDataArray[$savedPersonID]; // echo "<br>base record: <pre>".print_r($baseRecord,true)."</pre><br>"; // $flagArray = $this->checkPersonRecordFields($baseRecord); // echo "<br>flag array: <pre>".print_r($flagArray,true)."</pre><br>"; /** NOTE: SKIP PERSON RECORD UPDATE SINCE WE ARE JUST DELETING A RECORD, *NOT* UPDATING **/ /** Go through various tables and clean out or update records related to the current person **/ // Update and clean-up the Person-Year table (cim_hrdb_person_year) // Step 1) Find the information stored for the active person_id $personYearArray = array(); $person_year_manager = new RowManager_PersonYearManager(); $person_year_manager->setPersonID($savedPersonID); $person_year_manager->setSortOrder('personyear_id'); $person_year_manager->setAscDesc('DESC'); // sort by descending personyear IDs // echo "<BR>".$savedPersonID.","; $personYearData = $person_year_manager->getListIterator(); $person_year_array = $personYearData->getDataList(); reset($person_year_array); foreach (array_keys($person_year_array) as $key) { $record = current($person_year_array); $person_year_id = $record['personyear_id']; $year_id = $record['year_id']; $personYearArray[$person_year_id] = $year_id; // store person_id associated with the person_year_id next($person_year_array); } // if (count($person_year_array) > 0) // { // echo "<br>Years for active person_id ".$savedPersonID.": <pre>".print_r($personYearArray,true)."</pre><br>"; // } // echo "Person IDs list: ".$person_ids_list."<br>"; $reportDataDump .= 'Changes made to <b>cim_hrdb_person_year table</b>: ' . $BR; // remove all person-year records (associated with active person id) if (count($personYearArray) >= 1) { reset($personYearArray); $person_year_id = key($personYearArray); // $reportDataDump .= 'Saving the first person year record associated with person ID '.$savedPersonID.$BR.$BR; // next($personYearArray); // keep the first record (most recent personyear_id foreach (array_keys($personYearArray) as $m) { $record = current($personYearArray); $personYearID = key($personYearArray); $reportDataDump .= "REMOVE person-year entry for person_id = " . $savedPersonID . " using key = " . key($personYearArray) . $BR . $BR; if (isset($personYearID) && $personYearID != '' && $personYearID > 0) { $reportDataDump .= 'Deleting person year record having year ID ' . $record . $BR . $BR; $personYearUpdater = new RowManager_PersonYearManager($personYearID); $personYearUpdater->deleteEntry(); } next($personYearArray); } } // Update the Emergency Contact table (cim_hrdb_emerg) // Step 1) Find the information stored for the active person_id $emergInfoArray = array(); $emerg_info_manager = new RowManager_EmergencyInfoManager(); $emerg_info_manager->setPersonID($savedPersonID); $emerg_info_manager->setSortOrder('emerg_id'); $emerg_info_manager->setAscDesc('DESC'); // sort by descending emerg IDs // echo "<BR>".$savedPersonID.","; $emergInfoData = $emerg_info_manager->getListIterator(); $emerg_info_array = $emergInfoData->getDataList(); reset($emerg_info_array); foreach (array_keys($emerg_info_array) as $l) { $record = current($emerg_info_array); $emerg_id = $record['emerg_id']; $emerg_info = array(); $fields = page_DeletePerson::EMERG_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the emergency info values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $emerg_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with emerg_id as key $emergInfoArray[$emerg_id] = $emerg_info; next($emerg_info_array); } // TEST CONDITION // if (count($emerg_info_array) > 0) // { // echo "<br>Emergency info for active person_id ".$savedPersonID.": <pre>".print_r($emergInfoArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_emerg table</b>: ' . $BR; // remove all emergency info records associated with active person id if (count($emergInfoArray) >= 1) { reset($emergInfoArray); // $reportDataDump .= 'Saving the emergency contact record associated with person ID '.$savedPersonID.$BR.$BR; // next($emergInfoArray); // keep the first record (most recent emerg_id) foreach (array_keys($emergInfoArray) as $m) { $record = current($emergInfoArray); $emergID = key($emergInfoArray); // echo "REMOVE person-emerg entry for person_id = ".$savedPersonID." using key = ".key($emergInfoArray); if (isset($emergID) && $emergID != '') { $emergUpdater = new RowManager_EmergencyInfoManager($emergID); $emergUpdater->deleteEntry(); $reportDataDump .= 'Deleting emergency contact record having emergency ID ' . $emergID . $BR . $BR; } next($emergInfoArray); } } /**** TODO: have code to deal with deleting person ids in 'cim_hrdb_admin' (LOW-PRIORITY DUE TO SMALL SIZE OF TABLE) **/ /*** Update the Campus Assignment table (cim_hrdb_assignment) **/ // Step 1) Find the information stored for the active person_id $campusAssignArray = array(); $campus_assign_manager = new RowManager_AssignmentsManager(); $campus_assign_manager->setPersonID($savedPersonID); $campus_assign_manager->setSortOrder('assignment_id'); $campus_assign_manager->setAscDesc('DESC'); // sort by descending assignment IDs $campusAssignData = $campus_assign_manager->getListIterator(); $campus_assign_array = $campusAssignData->getDataList(); reset($campus_assign_array); foreach (array_keys($campus_assign_array) as $id) { $record = current($campus_assign_array); $assign_id = $record['assignment_id']; $assignment_info = array(); $fields = page_DeletePerson::ASSIGNMENT_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the campus assignment values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $assignment_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with assign_id as key $campusAssignArray[$assign_id] = $assignment_info; next($campus_assign_array); } // TEST CONDITION // if (count($campus_assign_array) > 0) // { // echo "<br>Campus assignment info for active person_id ".$savedPersonID.": <pre>".print_r($campusAssignArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_assignment table</b>: ' . $BR; // TODO??: remove all but the most recent campus assignment record (associated with active person id) // REMEMBER: a student may be an alumni of one school or attend two schools at once... if (count($campusAssignArray) >= 1) { $campus_ids_list = array(); $idx = 0; reset($campusAssignArray); $row = current($campusAssignArray); $campus_ids_list[$idx++] = $row['campus_id']; // next($campusAssignArray); // keep the first record (most recent assign_id) foreach (array_keys($campusAssignArray) as $m) { $record = current($campusAssignArray); $assignID = key($campusAssignArray); $reportDataDump .= "REMOVE person-campus entry for person_id = " . $savedPersonID . " using key = " . key($campusAssignArray) . $BR . $BR; if (isset($assignID) && $assignID != '') { // remove entries having a campus_id for the active person record $assignUpdater = new RowManager_AssignmentsManager($assignID); $assignUpdater->deleteEntry(); $reportDataDump .= 'Deleting campus assignment record having campus ID ' . $record['campus_id'] . $BR . $BR; } next($campusAssignArray); } } $reportDataDump .= 'Changes made to <b>cim_reg_registration table</b>: ' . $BR; // Delete the registration records associated with the person ID $registration_manager2 = new RowManager_RegistrationManager(); $registration_manager2->addSearchCondition('person_id in (' . $savedPersonID . ')'); //$person_ids_list.')'); $registration_manager2->setSortOrder('person_id'); $registration_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $registrationData2 = $registration_manager2->getListIterator(); $registration_array2 = $registrationData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; // $eventIDs = array(); // $idx = 0; reset($registration_array2); foreach (array_keys($registration_array2) as $key) { $record = current($registration_array2); $personID = $record['person_id']; if ($personID == $savedPersonID) { // echo "FOUND person ".$personID; $registration_id = $record['registration_id']; // $event_id = $record['event_id']; // Delete associated records in registration-related tables $this->deleteAssociatedRegRecords($registration_id); $regRecordUpdater = new RowManager_RegistrationManager($registration_id); // // update the person ID for an campus assignment record (in database) // $updateValues = array(); // $updateValues['person_id'] = $savedPersonID; // $regRecordUpdater->loadFromArray( $updateValues ); // $regRecordUpdater->updateDBTable(); $regRecordUpdater->deleteEntry(); $reportDataDump .= 'Delete associated registration record for person ID ' . $savedPersonID . ',' . $BR; } next($registration_array2); } /*** Update the Staff table (cim_hrdb_staff) **/ // Step 1) Find the information stored for the active person_id $staff_manager = new RowManager_StaffManager(); $staff_manager->setPersonID($savedPersonID); $staff_manager->setSortOrder('staff_id'); $staff_manager->setAscDesc('DESC'); // sort by descending assignment IDs // echo "<BR>".$savedPersonID.","; $staffData = $staff_manager->getListIterator(); $staff_array = $staffData->getDataList(); // TEST CONDITION // if (count($staff_array) > 0) // { // echo "<br>Staff info for active person_id ".$savedPersonID.": <pre>".print_r($staff_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_staff table</b>: ' . $BR; // Step 2) Remove all but one of the staff records // if (count($staff_array) > 1) // remove ONLY records with redundant person-campus pairs // { reset($staff_array); // next($staff_array); // keep the first record (most recent staff_id for active person) // $reportDataDump .= 'Saving the first staff record associated with person ID '.$savedPersonID.$BR.$BR; // echo 'staff array = <pre>'.print_r($staff_array,true).'</pre>'; foreach (array_keys($staff_array) as $m) { $record = current($staff_array); $staffID = key($staff_array); // remove redundant entry $staffUpdater = new RowManager_StaffManager($staffID); $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting staff record having staff ID ' . $staffID . $BR . $BR; $id = next($staff_array); // staff ID if ($id === FALSE) { break; // no valid data found so break out of the loop } } // } /***** Remove redundant sub-group associations, otherwise rename person-id to active person-id ******************/ // Update the Person-DG table (sch_person_sub_group): still requires clean up // Step 1) Find the information stored for the active person_id $dg_campus_array = array(); $person_dg_manager = new RowManager_PersonDGManager(); $person_dg_manager->setPersonID($savedPersonID); $person_dg_manager->setSortOrder('person_sub_group_id'); $person_dg_manager->setAscDesc('DESC'); // sort by descending person_sub_group_IDs $personDGData = $person_dg_manager->getListIterator(); $personDGArray = $personDGData->getDataList(); reset($personDGArray); foreach (array_keys($personDGArray) as $l) { $record = current($personDGArray); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $dg_campus_array[$dg_id] = $campus_id; next($personDGArray); } // // if (count($dg_campus_array) > 0) // { // echo "<br>DG for active person_id ".$savedPersonID.": <pre>".print_r($personDGArray,true)."</pre><br>"; // // echo "<br>DG-Campus for active person_id ".$savedPersonID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>sch_person_sub_group table</b>: ' . $BR; // Step 2) Update the records having the non-active person ids for this person $person_dg_manager2 = new RowManager_PersonDGManager(); $person_dg_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_dg_manager2->setSortOrder('person_id'); $person_dg_manager2->setAscDesc('DESC'); // sort by descending person IDs $personDGData2 = $person_dg_manager2->getListIterator(); $personDGArray2 = $personDGData2->getDataList(); // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personDGArray2) < 1) // { // $updated = false; // } // $j = 0; // echo 'DG array results = <pre>'.print_r($personDGArray2,true).'</pre>'; // echo 'dg - campus array: <pre>'.print_r($dg_campus_array,true).'</pre>'; reset($personDGArray2); foreach (array_keys($personDGArray2) as $l) { $record = current($personDGArray2); $personID = $record['person_id']; if ($personID == $savedPersonID) { $personSubGroupID = $record['person_sub_group_id']; $personDGUpdater = new RowManager_PersonDGManager($personSubGroupID); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $personDGUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for person ID ' . $savedPersonID . $BR; } next($personDGArray2); } /*** Update the personal schedule table (sch_schedule) **/ // Step 1) Find the information stored for the active person_id $schedule_array = array(); $schedule_manager = new RowManager_ScheduleManager(); $schedule_manager->setPersonID($savedPersonID); $schedule_manager->setSortOrder('schedule_id'); $schedule_manager->setAscDesc('DESC'); // sort by descending schedule_IDs $personScheduleData = $schedule_manager->getListIterator(); $personScheduleArray = $personScheduleData->getDataList(); reset($personScheduleArray); $idx = 0; foreach (array_keys($personScheduleArray) as $l) { $record = current($personScheduleArray); $schedule_block = $record['schedule_block']; $schedule_array[$idx] = $schedule_block; next($personScheduleArray); $idx++; } // echo 'active person schedule = <pre>'.print_r($personScheduleArray,true).'</pre>'; // echo 'person blocks array = <pre>'.print_r($schedule_array,true).'</pre>'; $reportDataDump .= 'Changes made to <b>sch_schedule table</b>: ' . $BR; // Step 2) Create new records for active person ID from data linked to the non-active person ids for this person $schedules = new RowManager_ScheduleManager(); $schedule_manager2 = new MultiTableManager(); $schedule_manager2->addRowManager($schedules); $schedule_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $schedule_manager2->addSortField('person_id', 'DESC'); // $schedule_manager2->setAscDesc( 'DESC' ); // sort by descending person ID $personScheduleData2 = $schedule_manager2->getListIterator(); $personScheduleArray2 = $personScheduleData2->getDataList(); $updatePersonID = -1; reset($personScheduleArray2); foreach (array_keys($personScheduleArray2) as $l) { $record = current($personScheduleArray2); $personID = $record['person_id']; if ($personID == $savedPersonID) { $found_sch_block = $record['schedule_block']; $schedule_id = $record['schedule_id']; $personScheduleUpdater = new RowManager_ScheduleManager($schedule_id); $personScheduleUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for person ID ' . $savedPersonID . $BR . $BR; } next($personScheduleArray2); } /*** Remove all person records for person_id***/ $personIDs = explode(',', $person_ids_list); foreach (array_values($personIDs) as $personID) { if ($personID == $savedPersonID) { $personUpdater = new RowManager_PersonManager($personID); $personUpdater->deleteEntry(); $reportDataDump .= 'Deleting <b>cim_hrdb_person</b> record having person ID ' . $personID . $BR; } next($personIDs); } } // end if (isset($indivDataArray)) $reportDataDump = substr($reportDataDump, 0, -4); // remove the last <BR> $reportDataDump .= $HR; // next($personDataArray); // } } // end if (isset($indivDataArray)) // echo $reportDataDump; } // end 'should delete?' parent::processData(); // remove data from cim_hrdb_person table }
/** * 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); }
/** * 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); }
protected function setRegistrationID() { // get registration ID for the rest of the reg. process $regs = new RowManager_RegistrationManager(); $people = new RowManager_PersonManager(); $people->setPersonID($this->person_id); $events = new RowManager_EventManager(); $events->setEventID($this->event_id); $personRegs = new MultiTableManager(); $personRegs->addRowManager($regs); $personRegs->addRowManager($people, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID())); $personRegs->addRowManager($events, new JoinPair($regs->getJoinOnEventID(), $events->getJoinOnEventID())); $regsList = $personRegs->getListIterator(); $regsArray = $regsList->getDataList(); // echo "<pre>".print_r($regsArray,true)."</pre>"; reset($regsArray); foreach (array_keys($regsArray) as $k) { $registration = current($regsArray); $this->registration_id = $registration['registration_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) next($regsArray); } // create new registration record for this person (since none exists for current person-event combo) if (!isset($this->registration_id)) { // get status id for INITIAL_REG_STATUS $regStatus = new RowManager_StatusManager(); $regStatus->setStatusDesc(FormProcessor_EditMyInfo::INITIAL_REG_STATUS); $regStatusList = $regStatus->getListIterator(); $regStatusArray = $regStatusList->getDataList(); $statusID = 0; reset($regStatusArray); foreach (array_keys($regStatusArray) as $k) { $status = current($regStatusArray); $statusID = $status['status_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) next($regStatusArray); } // get the MAX(registration_id)... need to determine what insertion registration ID will be (used in confirmNum) $allRegs = new MultiTableManager(); $regs2 = new RowManager_RegistrationManager(); $allRegs->addRowManager($regs2); $allRegs->setFunctionCall('MAX', 'registration_id'); $allRegs->ignoreFields(); // only leave MAX(registration_id) in values to be returned $allRegsList = $allRegs->getListIterator(); $allRegsArray = $allRegsList->getDataList(); $maxID = -1; reset($allRegsArray); foreach (array_keys($allRegsArray) as $k) { $regRecord = current($allRegsArray); $maxID = $regRecord['MAX(registration_id)']; if ($maxID > -1) { break; // get out of the loop once MAX is found } next($allRegsArray); } // compile values needed for new registration record $regValues = array(); $nextRegID = $maxID + 1; $regValues['event_id'] = $this->event_id; // check if a new person record needs to be created if ($this->person_id == -1) { $this->person_id = $this->getNextPersonID(); // assumes processData() will properly use this value for insertion // create empty person record to start off... since otherwise FK constraint on cim_reg_registration is NOT satisfied $personManager = new RowManager_PersonManager($this->person_id); $personManager->loadFromArray($this->formValues); $personManager->setPersonID($this->person_id); $personManager->createNewEntry(true); //$this->assignCampus($this->person_id); -- save this step for when info properly entered into form } $regValues['person_id'] = $this->person_id; $timestamp = strtotime("now"); $date = date('Y-m-d H:i:s', $timestamp); // == NOW() : to bad I could pass that as non-string... $regValues['registration_date'] = $date; // set date-time to current date-time $regValues['registration_confirmNum'] = 'E' . $this->event_id . 'R' . $nextRegID . 'C' . $this->campus_id; $regValues['registration_status'] = $statusID; // store values in table manager object. $regs->loadFromArray($regValues); // set primary key to use for update (if maxID found) if ($maxID > -1) { $regValues['registration_id'] = $nextRegID; $regs->setRegID($regValues['registration_id']); } // now update the DB with the values if (!$regs->isLoaded()) { $regs->createNewEntry(true); // allow primary key to be set (in case auto_increment is off) $this->registration_id = $nextRegID; } // TODO: figure out how to show error if no registration made, or updated (IF it is even possible now...) } }
/** * function loadSideBar * <pre> * Choosses . * </pre> * @return [void] */ function loadSideBar() { $regStatus = RowManager_RegistrationManager::STATUS_INCOMPLETE; // get privileges for the current viewer $privManager = new PrivilegeManager($this->viewer->getID()); // students allowed to see sidebar for sign-up process if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP || $privManager->isCampusAdmin($this->EVENT_ID, $this->CAMPUS_ID) == true) { // $parameters['PERSON_ID'] = $personID; // find registration ID using person id and event_id //if ((!isset($this->REG_ID))||$this->REG_ID='') //{ if (isset($this->PERSON_ID) && $this->PERSON_ID != '' && (isset($this->EVENT_ID) && $this->EVENT_ID != '')) { // get registration ID for the rest of the reg. process $regs = new RowManager_RegistrationManager(); $people = new RowManager_PersonManager(); $people->setPersonID($this->PERSON_ID); $events = new RowManager_EventManager(); $events->setEventID($this->EVENT_ID); $personRegs = new MultiTableManager(); $personRegs->addRowManager($regs); $personRegs->addRowManager($people, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID())); $personRegs->addRowManager($events, new JoinPair($regs->getJoinOnEventID(), $events->getJoinOnEventID())); $regsList = $personRegs->getListIterator(); $regsArray = $regsList->getDataList(); // echo "<pre>".print_r($regsArray,true)."</pre>"; reset($regsArray); foreach (array_keys($regsArray) as $k) { $registration = current($regsArray); $this->REG_ID = $registration['registration_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) $regStatus = $registration['registration_status']; next($regsArray); } } //} $regCompleted = false; if ($regStatus == RowManager_RegistrationManager::STATUS_REGISTERED) { $regCompleted = true; } $this->sideBar = new obj_RegProcessSideBar($this->moduleRootPath, $this->viewer, $regCompleted); //, $isNewRegistrant ); $links = array(); // $adminLinks = array(); // $campusLevelLinks = array(); $parameters = array(); $parameters = array('MINISTRY_ID' => $this->MINISTRY_ID, 'IS_IN_REG_PROCESS' => $this->IS_IN_REG_PROCESS, 'EVENT_ID' => $this->EVENT_ID, 'REG_ID' => $this->REG_ID, 'PERSON_ID' => $this->PERSON_ID, 'CAMPUS_ID' => $this->CAMPUS_ID, 'PRIV_ID' => $this->PRIV_ID); //[RAD_CALLBACK_PARAMS] // 'PROVINCE_ID'=>$this->PROVINCE_ID, 'GENDER_ID'=>$this->GENDER_ID, 'STAFF_ID'=>$this->STAFF_ID, 'USER_ID'=>$this->USER_ID, 'ASSIGNMENT_ID'=>$this->ASSIGNMENT_ID, 'ADMIN_ID'=>$this->ADMIN_ID, 'CAMPUSADMIN_ID'=>$this->CAMPUSADMIN_ID // echo print_r($parameters,true); // GROUP 1: EVERYONE. // ALL viewers can access these links if ($regStatus == RowManager_RegistrationManager::STATUS_REGISTERED && $this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP) { $requestLink = $this->getCallBack(modulecim_reg::PAGE_CONFIRMCANCELREGISTRATION, '', $parameters); $links['[RegCancel]'] = $requestLink; } $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITPERSONALINFO, '', $parameters); $links['[editMyInfo]'] = $requestLink; // need to know if registration process requires new registrant personal info // since this means side-bar cannot have future registration step links yet if (isset($this->PERSON_ID) && $this->PERSON_ID == -1) { // show only first link } else { $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITCAMPUSASSIGNMENT, '', $parameters); $links['[editCampusInfo]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITFIELDVALUES, '', $parameters); $links['[editFieldValues]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_reg::PAGE_PROCESSFINANCIALTRANSACTIONS, '', $parameters); $links['[processFinances]'] = $requestLink; } /*** if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP) { $requestLink = $this->getCallBack( modulecim_reg::PAGE_REG_HOME, '' , $parameters); $links[ '[backToEventList]' ] = $requestLink; } else if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_OFFLINE_REG) { $requestLink = $this->getCallBack( modulecim_reg::PAGE_EDITCAMPUSREGISTRATIONS, '' , $parameters); $links[ '[backToRegList]' ] = $requestLink; } ****/ // // GROUP 2: CAMPUS ADMINS AND ABOVE ONLY. // if ( ( $this->accessPrivManager->hasSitePriv() ) || ( $this->accessPrivManager->hasCampusPriv() ) ){ // //$requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PEOPLE ); // //$campusLevelLinks[ '[PeopleList]' ] = $requestLink; // // TODO if you have 'hrdb campus' group access rights you can see these // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PEOPLEBYCAMPUSES ); // $campusLevelLinks[ '[PeopleByCampuses]' ] = $requestLink; // } // // GROUP 3: SUPER ADMINS ONLY. // if ( $this->accessPrivManager->hasSitePriv()){ // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_CAMPUSES ); // $adminLinks[ '[editCampuses]' ] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PROVINCES ); // $adminLinks[ '[editProvinces]' ] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PRIVILEGES ); // $adminLinks[ '[editPrivileges]' ] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_STAFF ); // $adminLinks[ '[Staff]' ] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_ADMINS ); // $adminLinks[ '[Admins]' ] = $requestLink; // // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENT ); // $adminLinks[ '[CampusAssignments]' ] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENTSTATUSTYPES ); // $adminLinks[ '[AssignStatusTypes]' ] = $requestLink; // // } // pass the links to the sidebar object $this->sideBar->setLinks($links); // $this->sideBar->setAdminLinks( $adminLinks ); // $this->sideBar->setCampusLevelLinks( $campusLevelLinks ); } }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // Otherwise use the standard Templates for the site: //$path = SITE_PATH_TEMPLATES; // The weeks $weekManager = new RowManager_WeekManager(); $weekManager->setSemesterID($this->semester_id); $weekManager->setSortByDate(); $staffArray = array(); // figure out all the people we want to report on $isCD = $this->permManager->isCD(); if ($isCD) { // get all the people from this campus who have reported stats $wklyReportManager = new RowManager_WeeklyReportManager(); $wklyReportManager->setCampusID($this->campus_id); $anotherWeekManager = new RowManager_WeekManager(); $anotherWeekManager->setSemesterID($this->semester_id); $multiTableManager = new MultiTableManager(); $multiTableManager->addRowManager($wklyReportManager); $multiTableManager->addRowManager($anotherWeekManager, new JoinPair($wklyReportManager->getJoinOnWeekID(), $anotherWeekManager->getJoinOnWeekID())); $this->listIterator = $multiTableManager->getListIterator(); $this->listIterator->setFirst(); while ($this->listIterator->moveNext()) { $reportRow = $this->listIterator->getCurrent(new RowManager_WeeklyReportManager()); $staffArray[] = $reportRow->getStaffID(); } $staffArray = array_unique($staffArray); // echo '<pre>'.print_r($staffArray, true).'</pre>'; } else { // just get the stats for the staff viewing the page $staffArray[] = $this->staff_id; } $infoArray = array(); foreach ($staffArray as $indx => $staffID) { //IndSemesterInfo $indInfo = new IndSemesterInfo(); $staffManager = new RowManager_StaffManager($staffID); $personID = $staffManager->getPersonID(); $personManager = new RowManager_PersonManager($personID); $personManager->setLabelTemplateLastNameFirstName(); $indInfo->staffName = $personManager->getLabel(); $indInfo->staffID = $staffID; // calendar $indInfo->calendar = array(); $currentMonth = 0; // actual data // dataArray[weekID] = arrayOfData $indInfo->dataArray = array(); $weekList = new ListIterator($weekManager); $weekList->setFirst(); while ($weekList->moveNext()) { $week = $weekList->getCurrent(new RowManager_WeekManager()); $weekID = $week->getID(); // setup stuff for the calendar in the report $endDate = $week->getEndDate(); list($year, $month, $day) = explode('-', $endDate); $month = ltrim($month, "0"); // $day = ltrim($day, "0"); if ($currentMonth != $month) { // echo 'start new array<br/>'; $currentMonth = $month; } $indInfo->calendar[$currentMonth][$day] = $weekID; // end calendar stuff // check if an entry exists in the table for $weeklyReport = new RowManager_WeeklyReportManager($weekID, $staffID, $this->campus_id); if ($weeklyReport->isLoaded()) { // echo $week->getEndDate() . ' loaded <br/>'; $indInfo->dataArray[$weekID] = $weeklyReport->getArrayOfValues(); // echo '<pre>'.print_r( $weeklyReport->getArrayOfValues() ).'</pre>'; } else { $indInfo->dataArray[$weekID] = null; // echo $week->getEndDate() . ' NOT loaded <br/>'; } } // echo '<pre>'.print_r($calendar,true).'</pre>'; $infoArray[] = $indInfo; } /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $campusJumpLinkSelectedValue = $this->linkValues['campusJumpLink'] . $this->campus_id; $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'] . $this->semester_id; // NOTE: this parent method prepares the $this->template with the // common Display data. $this->prepareTemplate($path); // $this->template->set( 'calendar', $calendar ); // $this->template->set( 'dataArray', $dataArray ); $this->template->set('infoArray', $infoArray); $this->template->set('campusJumpLinkSelectedValue', $campusJumpLinkSelectedValue); $this->template->set('semesterJumpLinkSelectedValue', $semesterJumpLinkSelectedValue); // campus list $jumpLink = $this->linkValues['campusJumpLink']; $campusArray = array(); $this->campusListIterator->setFirst(); while ($this->campusListIterator->moveNext()) { $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager()); $region_id = $campusObject->getRegionID(); if ($region_id == 1 || $region_id == 2 || $region_id == 3) { $campusArray[$jumpLink . $campusObject->getID()] = $campusObject->getLabel(); } } // echo '<pre>'.print_r($campusArray, true ).'</pre>'; $this->template->set('list_campus_id', $campusArray); // semester list $jumpLink = $this->linkValues['semesterJumpLink']; $semesterArray = array(); $semesterManager = new RowManager_SemesterManager(); $this->semesterListIterator = $semesterManager->getListIterator(); $this->semesterListIterator->setFirst(); while ($this->semesterListIterator->moveNext()) { $semesterObject = $this->semesterListIterator->getCurrent(new RowManager_SemesterManager()); $semesterArray[$jumpLink . $semesterObject->getID()] = $semesterObject->getLabel(); } // echo '<pre>'.print_r($campusArray, true ).'</pre>'; $this->template->set('list_semester_id', $semesterArray); // uncomment this line if you are creating a template for this page $templateName = 'page_StaffSemesterReport.php'; // otherwise use the generic site template //$templateName = ''; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object //$this->pathModuleRoot.'templates/'; // Replace $path with the following line if you want to create a // template tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); // $this->linkLabels[ 'edit' ] = $this->labels->getLabel( '[Edit]' ); // $this->linkLabels[ 'del' ] = $this->labels->getLabel( '[Delete]' ); if (!isset($this->linkLabels['cont'])) { $this->linkLabels['cont'] = $this->labels->getLabel('[Back]'); // [Continue] } // $this->linkLabels[ 'view' ] = 'new link label here'; $this->prepareTemplate($path); // Set form approval status message // $form_approved = "Approval Pending"; // if ($this->is_form_approved == true) // { // $form_approved = "Form Approved"; // } // $this->template->set('form_approval_msg', $form_approved ); // // Display message if form has just been submitted if ($this->form_submitted == true) { $statusMessage = 'Form information successfully submitted.'; $this->template->set('form_status_msg', $statusMessage); $this->form_submitted = false; } // Set the sub-page objects $this->template->set('basicStaffForm', $this->generateTopForm()); if ($this->has_activity_form == true) { $this->template->set('scheduledActivityForm', $this->generateBottomForm()); } // Set approval form information $is_approved = ''; $approved_by = ''; $last_change = ''; $approval_array = $this->listManager->getDataList(); reset($approval_array); foreach (array_keys($approval_array) as $k) { $record = current($approval_array); $approved = $record['staffschedule_approved']; if ($approved == '1') { $is_approved = 'CHECKED'; } $approved_by = $record['staffschedule_approvedby']; $last_change = $record['staffschedule_lastmodifiedbydirector']; $approval_notes = $record['staffschedule_approvalnotes']; next($approval_array); } $personManager = new RowManager_PersonManager($approved_by); $personManager->setSortOrder('person_lname'); $personManager->setLabelTemplateLastNameFirstName(); $approved_by = $personManager->getPersonFirstName() . ' ' . $personManager->getPersonLastName(); // $personList = $personManager->getListIterator( ); // $personArray = $personList->getDropListArray( ); // $this->template->set( 'list_approved_by', $personArray ); $this->template->set('approvalFormAction', $this->formAction); $this->template->set('is_approved', $is_approved); $this->template->set('approvalButtonText', 'Approve/Disapprove'); $this->template->set('approval_notes', $approval_notes); $this->template->set('director_field', 'Last Change By'); $this->template->set('approved_by', $approved_by); $this->template->set('time_field', 'Last Change At'); if ($last_change != '') { $date_regex = '/[2-9]([0-9]{3})\\-[0-9]{1,2}\\-[0-9]{1,2}/'; if (preg_match($date_regex, $last_change) >= 1) { $time = strtotime($last_change); $last_change = strftime("%d %b %Y %H:%M:%S", $time); } } $this->template->set('last_change', $last_change); // $this->template->set('last_change', $last_change); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', RowManager_RegistrationManager::XML_NODE_NAME ); $this->template->set('rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'person_id'); // TODO: somehow merge the primary join with the balance owing join.... for efficiency /* * Set up any additional data transfer to the Template here... */ // $this->template->set( 'dataList', $this->dataList); // Get the real form name $form_name = ''; if ($this->form_id != '') { $formContext = new RowManager_StaffScheduleTypeManager($this->form_id); $form_name = $formContext->getFormName(); } // Get the person's name $person_name = ''; if ($this->person_id != '') { $personInfo = new RowManager_PersonManager($this->person_id); $person_name = $personInfo->getPersonFirstName() . ' ' . $personInfo->getPersonLastName(); } // $form_notice = 'Please note that the "Update" button only updates the top form.<br>The bottom form is updated via its own buttons/links.'; $this->template->set('heading', $form_name); $this->template->set('subheading', $person_name); // $this->template->set( 'formsNotice', $form_notice); $templateName = 'page_ApproveStaffSchedule.tpl.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditCampusRegistrations.php'; return $this->template->fetch($templateName); }
protected function getFieldValuesArray($regID = '', $personID = '', $eventID = '') { $FALSE = 0; $fields = new RowManager_FieldManager(); $fvalues = new RowManager_FieldValueManager(); $ftypes = new RowManager_FieldTypeManager(); // echo "personID = ".$personID; // echo "eventID = ".$eventID; if ($regID != '') { //$fields->setEventID($eventID); $fvalues->setRegID($regID); } else { if ($eventID != '' && $personID != '') { $registrations = new RowManager_RegistrationManager(); // $registrations->setRegID($regID); $person = new RowManager_PersonManager(); $person->setPersonID($personID); $event = new RowManager_EventManager(); $event->setEventID($eventID); $personReg = new MultiTableManager(); $personReg->addRowManager($registrations); $personReg->addRowManager($person, new JoinPair($registrations->getJoinOnPersonID(), $person->getJoinOnPersonID())); $personReg->addRowManager($event, new JoinPair($registrations->getJoinOnEventID(), $event->getJoinOnEventID())); $valIterator = $personReg->getListIterator(); $valArray = $valIterator->getDataList(); // go through results and store field types reset($valArray); foreach (array_keys($valArray) as $k) { $regValue = current($valArray); $regID = $regValue['registration_id']; //NOTE: assumes only 1 registration per person per event next($valArray); } // $fields->setEventID($eventID); $fvalues->setRegID($regID); } } // $fvalues->setSortByFieldID(); $fieldInfo = new MultiTableManager(); $fieldInfo->addRowManager($fields); $fieldInfo->addRowManager($fvalues, new JoinPair($fvalues->getJoinOnFieldID(), $fields->getJoinOnFieldID())); $fieldInfo->addRowManager($ftypes, new JoinPair($fields->getJoinOnFieldTypeID(), $ftypes->getJoinOnFieldTypeID())); if ($this->show_hidden == false) { $fieldInfo->constructSearchCondition('fields_hidden', '=', $FALSE, true); } $fieldInfo->setSortOrder('fields_priority'); $valuesIterator = $fieldInfo->getListIterator(); $valuesArray = $valuesIterator->getDataList(); // echo "field values:<br><pre>".print_r($valuesArray,true)."</pre>"; // store field ids associated with values already in database $initializedFieldIds = array_keys($valuesArray); // since each field value is located in a DB row the result array has several arrays - one per field value // need to extract each field value and store it as a non-array record in a result array $fieldValues = array(); $idx = 0; /** Go through all event fields and map each to existing field value, otherwise create new field value record **/ $fieldsArray = array_values($this->formFieldToFieldIDmapper); // store field IDs (ASSUMES formFieldToFieldIDmapper is initialized) // echo 'fieldsArray = <pre>'.print_r($fieldsArray,true).'</pre>'; reset($fieldsArray); reset($valuesArray); foreach (array_keys($fieldsArray) as $k) { $fieldID = current($fieldsArray); $form_value = ''; // default blank field value if none found $form_value_id = -1; // to be replaced with existing or newly-created field values ID if (in_array($fieldID, $initializedFieldIds) == true) { $record = $valuesArray[$fieldID]; $form_value = $record['fieldvalues_value']; $form_value_id = $record['fieldvalues_id']; } else { $updateValues = array(); $updateValues['fields_id'] = $fieldID; $updateValues['fieldvalues_value'] = $form_value; $updateValues['registration_id'] = $regID; $fieldvalues_manager = new RowManager_FieldValueManager(); // store values in table manager object. $fieldvalues_manager->loadFromArray($updateValues); // now update the DB with the values if (!$fieldvalues_manager->isLoaded()) { $fieldvalues_manager->createNewEntry(true); $form_value_id = $fieldvalues_manager->getID(); } } $fieldValues['form_field' . $idx] = $form_value; // store mapping associating form field label with fieldvalues_id $this->formFieldToValueIDmapper['form_field' . $idx] = $form_value_id; next($fieldsArray); $idx++; } // echo 'labels-values = <pre>'.print_r($this->formFieldToValueIDmapper,true).'</pre>'; // echo 'labels-fields = <pre>'.print_r($this->formFieldToFieldIDmapper,true).'</pre>'; return $fieldValues; }
private function getPersonFullName() { $personManager = new RowManager_PersonManager($this->person_id); return $personManager->getPersonFirstName() . ' ' . $personManager->getPersonLastName(); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); $reg = $this->itemManager; // retrieve RegistrationManager set to a particular reg_id earlier // $reg->setEventID($this->event_id); $person = new RowManager_PersonManager(); $person->setLabelTemplateLastNameFirstName(); $event = new RowManager_EventManager(); // $event->setEventID($this->event_id); // create join on person and registration tables $multiTableManager = new MultiTableManager(); $multiTableManager->addRowManager($person); $multiTableManager->addRowManager($reg, new JoinPair($reg->getJoinOnPersonID(), $person->getJoinOnPersonID())); $listIterator = $multiTableManager->getListIterator(); $personArray = $listIterator->getDropListArray(); //$listIterator $this->template->set('list_person_id', $personArray); // echo print_r($personArray,true); // create join on event and registration tables $multiTableManager2 = new MultiTableManager(); $multiTableManager2->addRowManager($event); $multiTableManager2->addRowManager($reg, new JoinPair($reg->getJoinOnEventID(), $event->getJoinOnEventID())); $listIterator2 = $multiTableManager2->getListIterator(); $eventArray = $listIterator2->getDropListArray(); //$listIterator $this->template->set('list_event_id', $eventArray); // echo print_r($eventArray,true); // uncomment this line if you are creating a template for this page //$templateName = 'page_ConfirmDeleteRegistration.php'; // otherwise use the generic site template $templateName = 'siteDeleteConf.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. * * ON JAN 2, 2008 Russ made two changes to this page to restore the original functionality... they are documented below. * ON JAN 8, 2008 Hobbe added conditional statements to allow registration record searches IF viewer has Reg. Sys. Super Admin privs. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: $privManager = new PrivilegeManager($this->viewer->getID()); if ($privManager->isSuperAdmin() == true) { $path = SITE_PATH_TEMPLATES; } else { // Changed by RM from using the assignment below on Jan 2, 2008. $path = $this->pathModuleRoot . 'templates/'; } // Otherwise use the standard Templates for the site: // $path = SITE_PATH_TEMPLATES; /* * store the link values */ // example: // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); // $this->linkLabels[ 'cont' ] = $this->labels->getLabel( '[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; /* * store any additional link Columns */ // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); // store the statevar id to edit $this->template->set('editEntryID', $this->registration_id); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Form related Template variables: */ /* * Insert the date start/end values for the following date fields: */ // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * List related Template variables : */ // Store the XML Node name for the Data Access Field List $xmlNodeName = RowManager_RegistrationManager::XML_NODE_NAME; $this->template->set('rowManagerXMLNodeName', $xmlNodeName); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'registration_id'); // store data list to the template // NOTE: we initialize it here to make sure we capture any new data // from a recent processData() call. if ($this->person_id != '') { $dataAccessManager = new RowManager_RegistrationManager(); $dataAccessManager->setPersonID($this->person_id); $dataAccessManager->setSortOrder($this->sortBy); // $this->dataList = new PriceRuleList( $this->sortBy ); $this->dataList = $dataAccessManager->getListIterator(); $this->template->setXML('dataList', $this->dataList->getXML()); } // else // { // $this->dataList = array(); // // $this->template->setXML( 'dataList', $this->dataList->getXML() ); // } /* * Add any additional data required by the template here */ $person = new RowManager_PersonManager(); $person->setLabelTemplateLastNameFirstName(); // $field->setPersonID( $this->person_id); $person->setSortOrder('person_lname, person_fname'); $personList = new ListIterator($person); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); $notice = "<br><b>NOTE:</b> Duplicate names may appear if a person has multiple records."; $this->template->set('note_person_id', $notice); $event = new RowManager_EventManager(); // $field->setPersonID( $this->person_id); $eventList = new ListIterator($event); $eventArray = $eventList->getDropListArray(); $this->template->set('list_event_id', $eventArray); $status = new RowManager_StatusManager(); $statusList = new ListIterator($status); $statusArray = $statusList->getDropListArray(); $this->template->set('list_registration_status', $statusArray); // // $nameFields = 'person_lname,person_fname'; // $template = '[person_lname], [person_fname]'; // $this->dataManager->setLabelTemplate( $nameFields, $template ); if ($privManager->isSuperAdmin() == true) { $templateName = 'siteSearchFormDataList.php'; //'page_HrdbHome.php'; } else { // Changed by RM on Jan 2, 2008 - We can't have just anybody being able to access this data. $templateName = 'page_HrdbHome.php'; } // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditPriceRules.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); // store the Row Manager's XML Node Name $this->template->set('rowManagerXMLNodeName', RowManager_StaffActivityManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'staffactivity_id'); // disable the heading? $this->template->set('disableHeading', $this->disableHeading); // Set page sub-heading (i.e. activity type filter) if ($this->activityTypeID != '') { $activityTypes = new RowManager_ActivityTypeManager($this->activityTypeID); $sub_heading = $activityTypes->getActivityTypeDesc(); $this->template->set('subheading', $sub_heading); } /* * Set up any additional data transfer to the Template here... */ $person_manager = new RowManager_PersonManager(); $person_list = $person_manager->getListIterator(); $person_manager->setLabelTemplateLastNameFirstName(); $personArray = $person_list->getDropListArray(); $this->template->set('list_person_id', $personArray); $eventtypes_manager = new RowManager_ActivityTypeManager(); $types_list = $eventtypes_manager->getListIterator(); $typesArray = $types_list->getDropListArray(); $this->template->set('list_activitytype_id', $typesArray); $templateName = 'siteDataList.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_ViewStaffActivities.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // initialize the variable storing process report data $reportDataDump = ''; $BR = '<BR>'; $HR = '<HR>'; // Make a new Template object $path = $this->pathModuleRoot . 'templates/'; // $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['cont'] = $this->labels->getLabel('[GoBack]'); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); /** Get list of unique triples of first name, last name, and e-mail address **/ // $allPeople = array(); // NOT USED BECAUSE WE HAVE NESTED LOOP INSTEAD OF MULTIPLE LOOPS $personRecords = new MultiTableManager(); $personRecords->addRowManager($this->person_manager); $personRecords->setSortOrder('person_lname'); // echo 'filters = '.$this->filter_fname.', '.$this->filter_lname.', '.$this->filter_email; /**** DATA FILTERS: USED TO ENSURE 60 SEC TIME-OUT IS NOT VIOLATED ****/ $personRecords->addSearchCondition("person_fname like '" . $this->filter_fname . "%'"); $personRecords->addSearchCondition("person_lname like '" . $this->filter_lname . "%'"); $personRecords->addSearchCondition("person_email like '" . $this->filter_email . "%'"); // use GROUP BY to easily enforce distinct triplets of (person_fname, person_lname, person_email) $groupBy = "person_fname,person_lname,person_email"; $personRecords->setGroupBy($groupBy); $personData = $personRecords->getListIterator(); $personDataArray = $personData->getDataList(); /** Go through the list of names 1 by 1, running another query to find if duplicates exist **/ reset($personDataArray); foreach (array_keys($personDataArray) as $k) { $savedPersonID = -1; // the only person ID left in the database for this individual $person = current($personDataArray); $person_fname = $person['person_fname']; $person_lname = $person['person_lname']; $person_email = $person['person_email']; $reportDataDump .= 'Unique person record tuple:' . $BR . ' First Name = ' . $person_fname . ', Last Name = ' . $person_lname . ', E-mail = ' . $person_email . $BR . $BR; // echo "PERSON NAME: ".$person_fname." ".$person_lname; // echo "PERSON: <pre>".print_r($person,true)."</pre>"; // search for a particular person to see if duplicate records exist $indiv_person_manager = new RowManager_PersonManager(); $indiv_person_manager->setFirstName(addslashes($person_fname)); // use addslashes to escape special chars in string $indiv_person_manager->setLastName(addslashes($person_lname)); $indiv_person_manager->setEmail(addslashes($person_email)); $indiv_person_manager->setSortOrder('person_id'); $indiv_person_manager->setAscDesc('DESC'); // sort by descending person IDs $indivData = $indiv_person_manager->getListIterator(); $indivDataArray = $indivData->getDataList(); // echo " INDIV COUNT: ".count($indivDataArray)."<br><br>"; // echo "INDIV RECORDS: <pre>".print_r($indivDataArray,true)."</pre>"; $person_ids_list = ''; //return all the person's data into array (key = person_id) of arrays (and store total data stored?) if (isset($indivDataArray)) { if (count($indivDataArray) == 0) { echo "ERROR: person was found earlier and now NO records are found!"; } else { if (count($indivDataArray) == 1) { // echo "GREAT! This person only has one record."; reset($indivDataArray); $record = current($indivDataArray); $savedPersonID = $record['person_id']; $person_ids_list = $savedPersonID; $reportDataDump .= 'Unique person id found for tuple: ' . $savedPersonID . $BR . $BR; } else { if (count($indivDataArray) > 1) { // get the person IDs for this individual reset($indivDataArray); foreach (array_keys($indivDataArray) as $l) { $record = current($indivDataArray); $person_ids_list .= $record['person_id']; $person_ids_list .= ','; next($indivDataArray); } $person_ids_list = substr($person_ids_list, 0, -1); // remove final comma $reportDataDump .= 'Multiple person ids found for tuple: ' . $person_ids_list . $BR . $BR; } } } // Search for duplicate person-related entries - for 1 or more person_ids found for current person if ($person_ids_list != '') { // echo "<br> person ids list: ".$person_ids_list."<br>"; // $person_ids_array = explode($person_ids_list,','); // check access table using all the found person IDs - retrieve viewer ids with person id as key $foundViewerIDs = $this->getAccessRecords($person_ids_list); // can safely assume array ISSET // echo 'found viewer ids= <pre>'.print_r($foundViewerIDs,true).'</pre>'; /** IF 0 access table records were found: **/ if (count($foundViewerIDs) == 0) { // TODO?: notify admin that this/these person record(s) require a viewer account // Store the active (latest) person_id in special variable reset($indivDataArray); $savedPersonID = key($indivDataArray); // recall that person_ids are sorted in descending order } else { if (count($foundViewerIDs) >= 1) { // echo "<br>found viewer IDs: <pre>".print_r($foundViewerIDs, true)."</pre>"; /** Get the associated viewer_id with the most recent login date **/ // $viewers = new RowManager_ViewerManager(); // $viewer_ids = ''; // reset($foundViewerIDs); // foreach (array_keys($foundViewerIDs) as $key) // { // // $record = current($foundViewerIDs); // $viewer_ids .= $key.','; //$record // // next($foundViewerIDs); // } // $viewer_ids = substr($viewer_ids, 0, -1); // remove final comma // // echo 'viewer_ids list = '.$viewer_ids.'<br>'; // $viewers->addSearchCondition("viewer_id in (".$viewer_ids.")"); // // $viewersData = $viewers->getListIterator(); // $viewersArray = $viewersData->getDataList(); // // // echo 'viewers array data = <pre>'.print_r($viewersArray,true).'</pre>'; // // $mostRecentDate = '0000-00-00'; // $mostRecentViewer = -1; // reset($viewersArray); // foreach(array_keys($viewersArray) as $l) // { // $record = current($viewersArray); // $foundDate = $record['viewer_lastLogin']; // $viewerID = $record['viewer_id']; // // // update most recent date if a more recent login date was found // if ($foundDate > $mostRecentDate) // { // $mostRecentDate = $foundDate; // $mostRecentViewer = $viewerID; // set viewer_id to use // } // } // TODO: add loop here to check if all $foundViewerIDs (from access table) are in viewers table // <loop> // if (in_array($foundViewerIDs[index], array_keys($viewersArray))) // delete $foundViewerIDs[index] from access table // <end-loop> // echo 'most recent viewer id = '.$mostRecentViewer; // echo 'viewer ids from list = <pre>'.print_r(array_keys($foundViewerIDs),true).'</pre>'; /** store the active (access table) person_id in special variable **/ reset($foundViewerIDs); // // (NEW) == person_id associated with the viewer_id having the most recent login date // // ONLY IN THE CASE WHERE PERSON HAS MORE THAN 1 VIEWER_ID // if (($mostRecentViewer != -1)&&(count($viewersArray) > 1)) // { // $temp_viewerIDs = array_keys($foundViewerIDs); // gets the viewer ids // $temp_personIDs = array_values($foundViewerIDs); // gets the person ids // $index = array_search($mostRecentViewer, $temp_viewerIDs); // get index having most recent viewer_id // // $savedPersonID = $temp_personIDs[$index]; // $reportDataDump .= 'Person ID of the record to keep: '.$savedPersonID.' (associated with most recent login)'.$BR.$BR; // } // else // FORMERLY: (OLD) == latest viewer-associated person ID, since array is ordered by person_id (DESC) // { $personIDs = explode(',', $person_ids_list); $savedPersonID = current($personIDs); //current($foundViewerIDs); $reportDataDump .= 'Person ID of the record to keep: ' . $savedPersonID . ' (associated with the most recent person record)' . $BR . $BR; // } // echo 'latest viewer ids = <pre>'.print_r($foundViewerIDs,true).'</pre>'; // echo 'saved person ID = '.$savedPersonID; $reportDataDump .= 'Changes made to <b>cim_hrdb_access table</b>: ' . $BR; /*** update the access table records to only use latest person ID **/ foreach (array_values($foundViewerIDs) as $person_id) { $viewer_id = key($foundViewerIDs); // echo 'viewer_id = '.$viewer_id; // only update the access table record if it needs a different person_id if ($person_id != $savedPersonID) { // get access ID(s) for the record to change $accessManager = new RowManager_AccessManager(); $accessManager->setViewerID($viewer_id); $accessManager->setPersonID(current($foundViewerIDs)); // or just use $person_id $accessData = $accessManager->getListIterator(); $accessDataArray = $accessData->getDataList(); // echo 'access data array = <pre>'.print_r($accessDataArray,true).'</pre>'; reset($accessDataArray); // deal with the unlikely case that we have redundant viewerID-personID records foreach (array_keys($accessDataArray) as $key) { $record = current($accessDataArray); $accessID = $record['access_id']; // set the values to set in the record (using 'access_id' as search key) $updateValues = array(); $updateValues['access_id'] = $accessID; $updateValues['viewer_id'] = $viewer_id; $updateValues['person_id'] = $savedPersonID; // only data that is changed $reportDataDump .= 'Updating person_id ' . $person_id . ' to be ' . $savedPersonID . $BR . $BR; $accessManager->loadFromArray($updateValues); $accessManager->updateDBTable(); next($accessDataArray); } } $id = next($foundViewerIDs); // person_id if ($id === FALSE) { break; // no valid data found so break out of the loop } } } } /** <end> access table update **/ $baseRecord = $indivDataArray[$savedPersonID]; // echo "<br>base record: <pre>".print_r($baseRecord,true)."</pre><br>"; $flagArray = $this->checkPersonRecordFields($baseRecord); // echo "<br>flag array: <pre>".print_r($flagArray,true)."</pre><br>"; // Add data from other records to the stored latest person record, if required // (i.e. if latest data misses phone #, etc) reset($indivDataArray); foreach (array_keys($indivDataArray) as $id) { $record = current($indivDataArray); $personID = $record['person_id']; if ($personID != $savedPersonID) { $personUpdater = new RowManager_PersonManager(); $personUpdater->setPersonID($savedPersonID); $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $nextFlagArray = $this->checkPersonRecordFields($indivDataArray[$personID]); // echo "<br>next flag array: <pre>".print_r($nextFlagArray,true)."</pre><br>"; reset($flagArray); foreach (array_keys($flagArray) as $m) { // if field is empty in active record then // replace with most recent value - if one exists // (since we are going through a list of person ids // in descending order) $flag = current($flagArray); if ($flag == '0') { $fieldName = key($flagArray); // check if the replacement person record has a non-empty field if ($nextFlagArray[$fieldName] == '1') { $updateValues[$fieldName] = $record[$fieldName]; $flagArray[$fieldName] = '1'; // prevents less-recent person data to overwrite what was just written } } next($flagArray); } // echo "<br>update values: <pre>".print_r($updateValues,true)."</pre><br>"; // update the active person record (in database) if (count($updateValues) > 1) { $reportDataDump .= 'Adding the following data to our preferred <b>cim_hrdb_person</b> record (using given person_id): '; $reportDataDump .= '<pre>' . print_r($updateValues, true) . '</pre>' . $BR . $BR; $personUpdater->loadFromArray($updateValues); $personUpdater->updateDBTable(); } } next($indivDataArray); } } // end "if >1 person id found for the person data" /** Go through various tables and clean out or update records related to the current person **/ // Update and clean-up the Person-Year table (cim_hrdb_person_year) // Step 1) Find the information stored for the active person_id $personYearArray = array(); $person_year_manager = new RowManager_PersonYearManager(); $person_year_manager->setPersonID($savedPersonID); $person_year_manager->setSortOrder('personyear_id'); $person_year_manager->setAscDesc('DESC'); // sort by descending personyear IDs // echo "<BR>".$savedPersonID.","; $personYearData = $person_year_manager->getListIterator(); $person_year_array = $personYearData->getDataList(); reset($person_year_array); foreach (array_keys($person_year_array) as $key) { $record = current($person_year_array); $person_year_id = $record['personyear_id']; $year_id = $record['year_id']; $personYearArray[$person_year_id] = $year_id; // store person_id associated with the person_year_id next($person_year_array); } // if (count($person_year_array) > 0) // { // echo "<br>Years for active person_id ".$savedPersonID.": <pre>".print_r($personYearArray,true)."</pre><br>"; // } // echo "Person IDs list: ".$person_ids_list."<br>"; $reportDataDump .= 'Changes made to <b>cim_hrdb_person_year table</b>: ' . $BR; // remove all but the most recent person-year record (associated with active person id) if (count($personYearArray) > 1) { reset($personYearArray); $person_year_id = key($personYearArray); $reportDataDump .= 'Saving the first person year record associated with person ID ' . $savedPersonID . $BR . $BR; next($personYearArray); // keep the first record (most recent personyear_id foreach (array_keys($personYearArray) as $m) { $record = current($personYearArray); $personYearID = key($personYearArray); // echo "REMOVE person-year entry for person_id = ".$savedPersonID." using key = ".key($personYearArray); if (isset($personYearID) && $personYearID != '' && $personYearID > 0) { $reportDataDump .= 'Deleting redundant person year record having year ID ' . $record . $BR . $BR; $personYearUpdater = new RowManager_PersonYearManager($personYearID); $personYearUpdater->deleteEntry(); } next($personYearArray); } } // Step 2) Update the records having the non-active person ids for this person $person_year_manager2 = new RowManager_PersonYearManager(); $person_year_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_year_manager2->setSortOrder('person_id'); $person_year_manager2->setAscDesc('DESC'); // sort by descending person IDs $personYearData2 = $person_year_manager2->getListIterator(); $person_year_array2 = $personYearData2->getDataList(); // echo "<br>Years for ALL person_ids: <pre>".print_r($person_year_array2,true)."</pre><br>"; // If no record was found for the active person record - then set flag for updating $updated = true; if (count($personYearArray) < 1) { $updated = false; } reset($person_year_array2); $j = 0; foreach (array_keys($person_year_array2) as $l) { $record = current($person_year_array2); $personID = $record['person_id']; // We ignore records with the active person id - since we dealt with those redundancies already if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $person_year_id = $record['personyear_id']; $personYearUpdater = new RowManager_PersonYearManager($person_year_id); // $personYearUpdater->setPersonYearID($person_year_id); $person_id = $record['person_id']; $year_id = $record['year_id']; // check to see if identical information was already stored under active person_id // if (in_array($year_id, $personYearArray)) // { if ($updated == false) { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $updateValues['year_id'] = $year_id; // echo "<br>update values to ".$savedPersonID." from ".$person_id.": <pre>".print_r($person_year_array2,true)."</pre><br>"; // update the person ID for a person-DG record (in database) $personYearUpdater->loadFromArray($updateValues); $personYearUpdater->updateDBTable(); $updated = true; // prevents the new data from being overwritten with older data (and allows better efficiency) $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $person_id . $BR . $BR; } else { // echo "<br>TO BE DELETED FROM cim_hrdb_person_year: person_id = ".$personID.", year = ".$year_id."<br>"; $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; $personYearUpdater->deleteEntry(); } // else // add person-year data from other person-id-linked records // { // $updateValues = array(); // $updateValues['person_id'] = $savedPersonID; // just to make sure... // $updateValues['year_id'] = $year_id; // // echo "<br>update values to ".$savedPersonID." from ".$person_id.": <pre>".print_r($person_year_array2,true)."</pre><br>"; // // // update the person ID for a person-DG record (in database) // $personYearUpdater->loadFromArray( $updateValues ); // $personYearUpdater->updateDBTable(); // } } next($person_year_array2); } // Update the Emergency Contact table (cim_hrdb_emerg) // Step 1) Find the information stored for the active person_id $emergInfoArray = array(); $emerg_info_manager = new RowManager_EmergencyInfoManager(); $emerg_info_manager->setPersonID($savedPersonID); $emerg_info_manager->setSortOrder('emerg_id'); $emerg_info_manager->setAscDesc('DESC'); // sort by descending emerg IDs // echo "<BR>".$savedPersonID.","; $emergInfoData = $emerg_info_manager->getListIterator(); $emerg_info_array = $emergInfoData->getDataList(); reset($emerg_info_array); foreach (array_keys($emerg_info_array) as $l) { $record = current($emerg_info_array); $emerg_id = $record['emerg_id']; $emerg_info = array(); $fields = page_PersonRecordCleanUp::EMERG_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the emergency info values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $emerg_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // $emerg_info['person_id'] = $record['person_id']; // $emerg_info['emerg_passportNum'] = $record['emerg_passportNum']; // $emerg_info['emerg_passportOrigin'] = $record['emerg_passportOrigin']; // $emerg_info['emerg_passportExpiry'] = $record['emerg_passportExpiry']; // $emerg_info['emerg_contactName'] = $record['emerg_contactName']; // $emerg_info['emerg_contactRship'] = $record['emerg_contactRship']; // $emerg_info['emerg_contactHome'] = $record['emerg_contactHome']; // $emerg_info['emerg_contactWork'] = $record['emerg_contactWork']; // $emerg_info['emerg_contactMobile'] = $record['emerg_contactMobile']; // $emerg_info['emerg_contactEmail'] = $record['emerg_contactEmail']; // $emerg_info['emerg_birthdate'] = $record['emerg_birthdate']; // $emerg_info['emerg_medicalNotes'] = $record['emerg_medicalNotes']; // store array of record values in array with emerg_id as key $emergInfoArray[$emerg_id] = $emerg_info; next($emerg_info_array); } // TEST CONDITION // if (count($emerg_info_array) > 0) // { // echo "<br>Emergency info for active person_id ".$savedPersonID.": <pre>".print_r($emergInfoArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_emerg table</b>: ' . $BR; // remove all but the most recent emergency info record (associated with active person id) if (count($emergInfoArray) > 1) { reset($emergInfoArray); $reportDataDump .= 'Saving the emergency contact record associated with person ID ' . $savedPersonID . $BR . $BR; next($emergInfoArray); // keep the first record (most recent emerg_id) foreach (array_keys($emergInfoArray) as $m) { $record = current($emergInfoArray); $emergID = key($emergInfoArray); // echo "REMOVE person-emerg entry for person_id = ".$savedPersonID." using key = ".key($emergInfoArray); if (isset($emergID) && $emergID != '') { $emergUpdater = new RowManager_EmergencyInfoManager($emergID); $emergUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant emergency contact record having emergency ID ' . $emergID . $BR . $BR; } next($emergInfoArray); } } // Step 2) Update the emergency contact records having the non-active person ids for this person $emerg_info_manager2 = new RowManager_EmergencyInfoManager(); $emerg_info_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $emerg_info_manager2->setSortOrder('person_id'); $emerg_info_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $emergInfoData2 = $emerg_info_manager2->getListIterator(); $emerg_info_array2 = $emergInfoData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; $updateValues = array(); // $updateValues = $this->initRecord(page_PersonRecordCleanUp::EMERG_RECORD_FIELDS); // $updateID = -1; // // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personYearArray) < 1) // { // $updated = false; // } reset($emerg_info_array2); foreach (array_keys($emerg_info_array2) as $l) { $record = current($emerg_info_array2); $personID = $record['person_id']; $contactName = $record['emerg_contactName']; if ($personID != $savedPersonID) { $emerg_id = $record['emerg_id']; $personEmergUpdater = new RowManager_EmergencyInfoManager($emerg_id); // $personEmergUpdater->setPersonEmergID($emerg_id); $person_id = $record['person_id']; if (count($emergInfoArray) < 1) { // update the last-updated record with further information (if there was a last update) // if ($updateID != -1) // { // $personEmergUpdater = new RowManager_EmergencyInfoManager($updateID); // } // TODO: reactivate the above and then delete all entries but the first totally updated record $record['person_id'] = $savedPersonID; // require this to actually change person ID // // determine if some fields have been replaced previously // $flagArray = $this->checkRecordFields($updateValues, page_PersonRecordCleanUp::EMERG_RECORD_FIELDS); // // reset($flagArray); // foreach(array_keys($flagArray) as $m) // { // // if field is empty in update record then // // replace with most recent value - if one exists // // (since we are going through a list of person ids // // in descending order) // $flag = current($flagArray); // if ($flag == '0') // { // $fieldName = key($flagArray); // $updateValues[$fieldName] = $record[$fieldName]; // update the array (or replace empty with empty) // } // next($flagArray); // } // (BELOW) REMOVE WHEN USING ABOVE: $updateValues['person_id'] = $savedPersonID; // update the person ID for an emergency contact record (in database) $personEmergUpdater->loadFromArray($updateValues); $personEmergUpdater->updateDBTable(); // $updateID = $emerg_id; // TODO: ensure that we end up with only ONE record that is updated with latest data $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $person_id . $BR . $BR; } else { $contact_name = $record['emerg_contactHome']; // echo "<br>TO BE DELETED FROM cim_hrdb_emerg: person_id = ".$person_id.", contactName = ".$contact_name."<br>"; $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . ' having contact name = ' . $contactName . $BR . $BR; $personEmergUpdater->deleteEntry(); } } next($emerg_info_array2); } /**** TODO: have code to deal with redundant person ids in 'cim_hrdb_admin' (LOW-PRIORITY DUE TO SMALL SIZE OF TABLE) **/ /*** Update the Campus Assignment table (cim_hrdb_assignment) **/ // Step 1) Find the information stored for the active person_id $campusAssignArray = array(); $campus_assign_manager = new RowManager_AssignmentsManager(); $campus_assign_manager->setPersonID($savedPersonID); $campus_assign_manager->setSortOrder('assignment_id'); $campus_assign_manager->setAscDesc('DESC'); // sort by descending assignment IDs $campusAssignData = $campus_assign_manager->getListIterator(); $campus_assign_array = $campusAssignData->getDataList(); reset($campus_assign_array); foreach (array_keys($campus_assign_array) as $id) { $record = current($campus_assign_array); $assign_id = $record['assignment_id']; $assignment_info = array(); $fields = page_PersonRecordCleanUp::ASSIGNMENT_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the campus assignment values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $assignment_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with assign_id as key $campusAssignArray[$assign_id] = $assignment_info; next($campus_assign_array); } // TEST CONDITION // if (count($campus_assign_array) > 0) // { // echo "<br>Campus assignment info for active person_id ".$savedPersonID.": <pre>".print_r($campusAssignArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_assignment table</b>: ' . $BR; // TODO??: remove all but the most recent campus assignment record (associated with active person id) // REMEMBER: a student may be an alumni of one school or attend two schools at once... if (count($campusAssignArray) > 1) { $campus_ids_list = array(); $idx = 0; reset($campusAssignArray); $row = current($campusAssignArray); $campus_ids_list[$idx++] = $row['campus_id']; next($campusAssignArray); // keep the first record (most recent assign_id) foreach (array_keys($campusAssignArray) as $m) { $record = current($campusAssignArray); $assignID = key($campusAssignArray); // echo "REMOVE person-campus entry for person_id = ".$savedPersonID." using key = ".key($campusAssignArray); if (isset($assignID) && $assignID != '') { // remove entries having a campus_id already stored for the active person record if (in_array($record['campus_id'], $campus_ids_list)) { $assignUpdater = new RowManager_AssignmentsManager($assignID); $assignUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant campus assignment record having campus ID ' . $record['campus_id'] . $BR . $BR; } else { $campus_ids_list[$idx++] = $record['campus_id']; } } next($campusAssignArray); } } // Step 2) Update the campus assignment records having the non-active person ids for this person $campus_assign_manager2 = new RowManager_AssignmentsManager(); $campus_assign_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $campus_assign_manager2->setSortOrder('person_id'); $campus_assign_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $campusAssignData2 = $campus_assign_manager2->getListIterator(); $campus_assign_array2 = $campusAssignData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; $campusIDs = array(); $idx = 0; reset($campus_assign_array2); foreach (array_keys($campus_assign_array2) as $l) { $record = current($campus_assign_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $assignment_id = $record['assignment_id']; $campus_id = $record['campus_id']; $personAssignmentUpdater = new RowManager_AssignmentsManager($assignment_id); // $personEmergUpdater->setPersonEmergID($emerg_id); $person_id = $record['person_id']; if (count($campusAssignArray) < 1) { $record['person_id'] = $savedPersonID; // require this to actually change person ID // only create a new record with active person id if the campus ID not associated with the person yet if (!in_array($campus_id, $campusIDs)) { // update the person ID for an campus assignment record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $personAssignmentUpdater->loadFromArray($updateValues); $personAssignmentUpdater->updateDBTable(); $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ' (with campus ID ' . $campus_id . '),<br>'; $reportDataDump .= 'updating person ID for person ID ' . $person_id . $BR . $BR; $campusIDs[$idx++] = $campus_id; } else { // echo "<br>Delete op #1."; $personAssignmentUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; } } else { // echo "<br>TO BE DELETED FROM cim_hrdb_emerg: person_id = ".$person_id.", campus_id = ".$campus_id."<br>"; $personAssignmentUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; } } next($campus_assign_array2); } /*** Update the Registrations table (cim_reg_registration) **/ /** NOTE: Currenlty only use step 2, which simply replace associated person IDs with active person ID **/ // Step 1) Find the information stored for the active person_id // $regRecordsArray = array(); // $idx = 0; // // $registration_manager = new RowManager_RegistrationManager(); // $registration_manager->setPersonID($savedPersonID); // $registration_manager->setSortOrder( 'registration_id' ); // $registration_manager->setAscDesc( 'DESC' ); // sort by descending registration IDs // // // echo "<BR>".$savedPersonID.","; // $registrationData = $registration_manager->getListIterator(); // $regs_array = $registrationData->getDataList(); // reset($regs_array); // foreach(array_keys($regs_array) as $id) // { // $record = current($regs_array); // // $reg_id = $record['registration_id']; // // $registration_info = array(); // // // $fields = page_PersonRecordCleanUp::REGISTRATION_RECORD_FIELDS; // // $fieldsArray = explode(",",$fields); // // // // // store the campus assignment values in an array // // reset($fieldsArray); // // foreach(array_keys($fieldsArray) as $k) // // { // // $fieldName = current($fieldsArray); // // // // $registration_info[$fieldName] = $record[$fieldName]; // // // // next($fieldsArray); // // } // // // store array of record values in array with assign_id as key // // $regRecordsArray[$reg_id] = $registration_info; // $regRecordsArray[$idx++] = $reg_id; // // next($regs_array); // } // // // TEST CONDITION // if (count($regs_array) > 0) // { // echo "<br>Registration ids for active person_id ".$savedPersonID.": <pre>".print_r($regRecordsArray,true)."</pre><br>"; // } // TODO??: convert the code below to delete registration records that appear under same person_id (obviously with same event_id) // if (count($regRecordsArray) > 1) // remove ONLY records with redundant person-campus pairs // { // $campus_ids_list = array(); // $idx = 0; // reset($campusAssignArray); // $row = current($campusAssignArray); // $campus_ids_list[$idx++] = $row['campus_id']; // next($campusAssignArray); // keep the first record (most recent emerg_id) // // foreach(array_keys($campusAssignArray) as $m) // { // $record = current($campusAssignArray); // // $assignID = key($campusAssignArray); // // // echo "REMOVE person-campus entry for person_id = ".$savedPersonID." using key = ".key($campusAssignArray); // if ((isset($assignID))&&($assignID != '')) // { // // remove entries having a campus_id already stored for the active person record // if (in_array($record['campus_id'], $campus_ids_list)) // { // $assignUpdater = new RowManager_AssignmentsManager($assignID); // $assignUpdater->deleteEntry(); // } // else // store campus_id so as to remove any other records with this campus_id // { // $campus_ids_list[$idx++] = $record['campus_id']; // } // } // // next($campusAssignArray); // } // // } $reportDataDump .= 'Changes made to <b>cim_reg_registration table</b>: ' . $BR; // Step 2) Update the registration records having the non-active person ids for this person (TODO: work from here) $registration_manager2 = new RowManager_RegistrationManager(); $registration_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $registration_manager2->setSortOrder('person_id'); $registration_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $registrationData2 = $registration_manager2->getListIterator(); $registration_array2 = $registrationData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; // $eventIDs = array(); // $idx = 0; reset($registration_array2); foreach (array_keys($registration_array2) as $key) { $record = current($registration_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $registration_id = $record['registration_id']; // $event_id = $record['event_id']; $regRecordUpdater = new RowManager_RegistrationManager($registration_id); // $personEmergUpdater->setPersonEmergID($emerg_id); // if (count($regRecordsArray) < 1) // if active person ID doesn't have record yet, then update older record with active person ID // { // $record['person_id'] = $savedPersonID; // require this to actually change person ID // // only create a new record with active person id if the event_id not associated with the person yet // if (!in_array($event_id, $eventIDs)) // { // update the person ID for an campus assignment record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $regRecordUpdater->loadFromArray($updateValues); $regRecordUpdater->updateDBTable(); $reportDataDump .= 'Found registration record for alternative ID of person ID ' . $savedPersonID . ',' . $BR; $reportDataDump .= 'updating person ID for person ID ' . $personID . $BR . $BR; // $eventIDs[$idx++] = $event_id; // } // else // { // echo "<br>Delete op #1."; // $regRecordUpdater->deleteEntry(); // } // } // else // { // echo "<br>TO BE DELETED FROM cim_reg_registration: person_id = ".$personID.", event_id = ".$event_id."<br>"; // $regRecordUpdater->deleteEntry(); // } } next($registration_array2); } /*** Update the Staff table (cim_hrdb_staff) **/ // Step 1) Find the information stored for the active person_id $staff_manager = new RowManager_StaffManager(); $staff_manager->setPersonID($savedPersonID); $staff_manager->setSortOrder('staff_id'); $staff_manager->setAscDesc('DESC'); // sort by descending assignment IDs // echo "<BR>".$savedPersonID.","; $staffData = $staff_manager->getListIterator(); $staff_array = $staffData->getDataList(); // reset($staff_array); // foreach(array_keys($staff_array) as $id) // { // $record = current($staff_array); // // $staff_id = $record['staff_id']; // $staffRecordsArray[$idx++] = $staff_id; // // next($staff_array); // } // TEST CONDITION // if (count($staff_array) > 0) // { // echo "<br>Staff info for active person_id ".$savedPersonID.": <pre>".print_r($staff_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_staff table</b>: ' . $BR; // Step 2) Remove all but one of the staff records if (count($staff_array) > 1) { reset($staff_array); next($staff_array); // keep the first record (most recent staff_id for active person) $reportDataDump .= 'Saving the first staff record associated with person ID ' . $savedPersonID . $BR . $BR; // echo 'staff array = <pre>'.print_r($staff_array,true).'</pre>'; foreach (array_keys($staff_array) as $m) { $record = current($staff_array); $staffID = key($staff_array); // remove redundant entry $staffUpdater = new RowManager_StaffManager($staffID); $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant staff record having staff ID ' . $staffID . $BR . $BR; $id = next($staff_array); // staff ID if ($id === FALSE) { break; // no valid data found so break out of the loop } } } // Step 3) Delete the staff records having the non-active person ids for this person $staff_manager2 = new RowManager_StaffManager(); $staff_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $staff_manager2->setSortOrder('person_id'); $staff_manager2->setAscDesc('DESC'); // sort by descending person IDs $staffData2 = $staff_manager2->getListIterator(); $staff_array2 = $staffData2->getDataList(); $toUpdate = false; if (count($staff_array) < 1) { $toUpdate = true; } reset($staff_array2); foreach (array_keys($staff_array2) as $l) { $record = current($staff_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $staff_id = $record['staff_id']; $staffUpdater = new RowManager_StaffManager($staff_id); if ($toUpdate == true) { // $record['person_id'] = $savedPersonID; // require this to actually change person ID // update the person ID for a staff record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $staffUpdater->loadFromArray($updateValues); $staffUpdater->updateDBTable(); $toUpdate = false; $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $personID . $BR . $BR; } else { // echo "<br>TO BE DELETED FROM cim_hrdb_staff: person_id = ".$person_id.", staff_id = ".$staff_id."<br>"; $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $personID . $BR . $BR; } } next($staff_array2); } /***** Remove redundant sub-group associations, otherwise rename person-id to active person-id ******************/ // Update the Person-DG table (sch_person_sub_group): still requires clean up // Step 1) Find the information stored for the active person_id $dg_campus_array = array(); $person_dg_manager = new RowManager_PersonDGManager(); $person_dg_manager->setPersonID($savedPersonID); $person_dg_manager->setSortOrder('person_sub_group_id'); $person_dg_manager->setAscDesc('DESC'); // sort by descending person_sub_group_IDs $personDGData = $person_dg_manager->getListIterator(); $personDGArray = $personDGData->getDataList(); reset($personDGArray); foreach (array_keys($personDGArray) as $l) { $record = current($personDGArray); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $dg_campus_array[$dg_id] = $campus_id; next($personDGArray); } // // if (count($dg_campus_array) > 0) // { // echo "<br>DG for active person_id ".$savedPersonID.": <pre>".print_r($personDGArray,true)."</pre><br>"; // // echo "<br>DG-Campus for active person_id ".$savedPersonID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>sch_person_sub_group table</b>: ' . $BR; // Step 2) Update the records having the non-active person ids for this person $person_dg_manager2 = new RowManager_PersonDGManager(); $person_dg_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_dg_manager2->setSortOrder('person_id'); $person_dg_manager2->setAscDesc('DESC'); // sort by descending person IDs $personDGData2 = $person_dg_manager2->getListIterator(); $personDGArray2 = $personDGData2->getDataList(); // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personDGArray2) < 1) // { // $updated = false; // } // $j = 0; // echo 'DG array results = <pre>'.print_r($personDGArray2,true).'</pre>'; // echo 'dg - campus array: <pre>'.print_r($dg_campus_array,true).'</pre>'; reset($personDGArray2); foreach (array_keys($personDGArray2) as $l) { $record = current($personDGArray2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $personSubGroupID = $record['person_sub_group_id']; $personDGUpdater = new RowManager_PersonDGManager($personSubGroupID); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; // echo 'dg-id, campus-id = '.$dg_id.', '.$campus_id.'<br>'; // check to see if identical information was already stored under active person_id if (isset($dg_campus_array[$dg_id]) && $dg_campus_array[$dg_id] == $campus_id) { $personDGUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $personID . $BR; $reportDataDump .= 'since it has information already stored for primary person ID ' . $savedPersonID . $BR . $BR; // echo "<br>TO BE DELETED FROM sch_person_sub_group: person_id = ".$personID.", dg = ".$dg_id.", campus = ".$campus_id."<br>"; } else { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $updateValues['sub_group_id'] = $record['sub_group_id']; $updateValues['organization_id'] = $record['organization_id']; // echo "<br>update values from ".$personID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // TODO: deal with case where two non-active person-ids contain identical info (currently both are saved with active person id) // update the person ID for a person-DG record (in database) $personDGUpdater->loadFromArray($updateValues); $personDGUpdater->updateDBTable(); $reportDataDump .= 'Updating record for alternative person ID ' . $personID . $BR; $reportDataDump .= 'since it has new information: setting person ID to be ' . $savedPersonID . $BR . $BR; } } next($personDGArray2); } /*** Update the personal schedule table (sch_schedule) **/ // Step 1) Find the information stored for the active person_id $schedule_array = array(); $schedule_manager = new RowManager_ScheduleManager(); $schedule_manager->setPersonID($savedPersonID); $schedule_manager->setSortOrder('schedule_id'); $schedule_manager->setAscDesc('DESC'); // sort by descending schedule_IDs $personScheduleData = $schedule_manager->getListIterator(); $personScheduleArray = $personScheduleData->getDataList(); reset($personScheduleArray); $idx = 0; foreach (array_keys($personScheduleArray) as $l) { $record = current($personScheduleArray); $schedule_block = $record['schedule_block']; $schedule_array[$idx] = $schedule_block; next($personScheduleArray); $idx++; } // echo 'active person schedule = <pre>'.print_r($personScheduleArray,true).'</pre>'; // echo 'person blocks array = <pre>'.print_r($schedule_array,true).'</pre>'; $reportDataDump .= 'Changes made to <b>sch_schedule table</b>: ' . $BR; // Step 2) Create new records for active person ID from data linked to the non-active person ids for this person $schedules = new RowManager_ScheduleManager(); $schedule_manager2 = new MultiTableManager(); $schedule_manager2->addRowManager($schedules); $schedule_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $schedule_manager2->addSortField('person_id', 'DESC'); // $schedule_manager2->setAscDesc( 'DESC' ); // sort by descending person ID $personScheduleData2 = $schedule_manager2->getListIterator(); $personScheduleArray2 = $personScheduleData2->getDataList(); // echo 'other person-ids schedule array = <pre>'.print_r($personScheduleArray2,true).'</pre>'; $toUpdate = false; if (count($schedule_array) < 1) { $toUpdate = true; // echo 'Staff update needed'; } // echo 'schedule array = <pre>'.print_r($personScheduleArray2,true).'</pre>'; $updatePersonID = -1; reset($personScheduleArray2); foreach (array_keys($personScheduleArray2) as $l) { $record = current($personScheduleArray2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $found_sch_block = $record['schedule_block']; $schedule_id = $record['schedule_id']; $personScheduleUpdater = new RowManager_ScheduleManager($schedule_id); // $personScheduleUpdater->setPersonID($personID); // $personScheduleUpdater->setScheduleBlock($found_sch_block); // if the active person_id DOES NOT HAVE this schedule block, then update record with active person id // if (!in_array($found_sch_block, $schedule_array)) // COMMENTED OUT BECAUSE WE DON'T WANT TO MERGE SCHEDULES // { // if the active person_id DOES NOT HAVE **ANY** schedule block, then update record with active person id if ($toUpdate == true || $updatePersonID == $personID) { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // NEW VALUE $updateValues['schedule_block'] = $found_sch_block; // just to make sure... // update the person ID for a person-DG record (in database) $personScheduleUpdater->loadFromArray($updateValues); $personScheduleUpdater->updateDBTable(); if ($toUpdate == true) { $toUpdate = false; $updatePersonID = $personID; // set person ID whose schedule blocks to use for updating $reportDataDump .= 'No schedule block found for person ID ' . $savedPersonID . ',' . $BR; $reportDataDump .= 'updating using schedule blocks from person ID ' . $updatePersonID . $BR . $BR; } } else { // TODO: enable this code at mid-April 2008 // $personScheduleUpdater->deleteEntry(); // $reportDataDump .= 'Deleting record for alternative person ID '.$personID.$BR.$BR; // TODO: deal with case where two non-active person-ids contain identical info // (currently both are saved with active person id) } } next($personScheduleArray2); } /*** Remove all person records other than the active person ID (most often the one used in most-recent login) ***/ $personIDs = explode(',', $person_ids_list); foreach (array_values($personIDs) as $personID) { if ($personID != $savedPersonID) { $personUpdater = new RowManager_PersonManager($personID); $personUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant <b>cim_hrdb_person</b> record having person ID ' . $personID . $BR; } next($personIDs); } } // end if (isset($indivDataArray)) $reportDataDump = substr($reportDataDump, 0, -4); // remove the last <BR> $reportDataDump .= $HR; next($personDataArray); } $this->template->set('reportDataDump', $reportDataDump); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', RowManager_ReceiptManager::XML_NODE_NAME ); // store the primary key field name for the data being displayed // $this->template->set( 'primaryKeyFieldName', 'ccreceipt_sequencenum'); /* * Set up any additional data transfer to the Template here... */ $templateName = 'page_PersonRecordCleanUp.tpl.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_DisplayCCtransactionReceipt.php'; // send CC transaction confirmation e-mail (but first remove links) // $link_regex = '{<a.*?</a>}'; // $message_body = $this->template->fetch( $templateName ); // $message_body = preg_replace( $link_regex, '', $message_body); // // if (!defined('IGNORE_EMAILS')) // { // $this->sendCCTransactionEmail($message_body); // } return $this->template->fetch($templateName); }
/** * function __construct * This is the class constructor for Viewer class * Initialize a Viewer and determine if they are properly authenticated. * <pre><code> * Save the DB connection Info * If no session ID is set then * set the Session ID to empty string * end if * Get current viewer ID from session ID * If viewer ID is empty then * if isDestroySession is set then * Destroy the Session * end if * initialize Empty UnAuthorized Viewer ID * else * User Credientials are valid so ... * Mark as Valid Authentication * * Prepare an SQL statement to lookup the viewer info from the DB * Now load the Data from the DB * end if * </pre> * @param $isDestroySession [BOOL] Should we destroy the session data if not authenticated? * @param $dbName [STRING] The name of the database the viewer info is stored in * @param $dbPath [STRING] The path of the database the viewer info is stored in * @param $dbUser [STRING] The login ID for the database the viewer info is stored in * @param $dbPassword [STRING] The password of the database the viewer info is stored in */ function __construct($isDestroySession = true, $dbName = SITE_DB_NAME, $dbPath = SITE_DB_PATH, $dbUser = SITE_DB_USER, $dbPassword = SITE_DB_PWORD) { // if no session ID is set then if (!isset($_SESSION[SESSION_ID_ID])) { // set the Session ID to empty string $_SESSION[SESSION_ID_ID] = ''; } if ($_SESSION[SESSION_ID_ID] == '') { $_SESSION[SESSION_ID_ID] = 0; } // Get current viewer ID from session ID $this->viewerID = $_SESSION[SESSION_ID_ID]; // attempt to load a viewerManager object with current viewerID $this->viewerManager = new RowManager_ViewerManager($this->viewerID); if ($this->viewerManager->isLoaded()) { // Update current Session ID with current ViewerID $_SESSION[SESSION_ID_ID] = $this->viewerID; if ($this->viewerManager->isActive()) { $this->isAuthenticated = true; } else { $this->isAuthenticated = false; } } else { // Info not stored in session, get from GCX $this->isAuthenticated = false; if (CASUser::checkAuth()) { if (!empty($_SESSION['phpCAS']['guid'])) { if ($this->validateLogin($_SESSION['phpCAS']['guid'])) { // a user with this GUID exists in our system $this->isAuthenticated = true; } else { // code added by Russ September 11, 2009 // a user with this GUID does not exist in our system - create them $guid = $_SESSION['phpCAS']['guid']; // echo "The GUID[".$guid."]<br/>"; $gcxUsername = $_SESSION['phpCAS']['user']; // echo "The gcxUsername[".$gcxUsername."]<br/>"; // the gcxUsername is (supposed to be) an email // check to see if there is a cim_hrdb_person record with this email // the comparison needs to be case insensitive (since mysql is insensitive by default, no special doctoring is needed) // search for person record $personManager = new RowManager_PersonManager(); $foundPerson = $personManager->loadByEmail($gcxUsername); // get the personID of the person that was searched $personID = $personManager->getID(); // if record does not exist // create one // update the personID if (!$foundPerson) { // create a new person record $newpersonManager = new RowManager_PersonManager(); $newpersonManager->setEmail($gcxUsername); $newpersonManager->createNewEntry(); $personID = $newpersonManager->getID(); } // link the personID to the GUID/viewer in the cim_hrdb_access table // first, check to see if any entry already exists in the access table // if foundPerson is true above, it's possible (may have been linked to old viewer/username but not promoted to GCX account yet) $accessManager = new RowManager_AccessManager(); $accessEntryFound = $accessManager->loadByPersonID($personID); $viewerID = -1; $createNewViewer = true; if ($accessEntryFound) { $viewerID = $accessManager->getViewerID(); $viewerManager = new RowManager_ViewerManager($viewerID); // double check to make sure the viewer referenced in the access table actually exists $viewerAlreadyExists = $viewerManager->isLoaded(); if ($viewerAlreadyExists) { // no need to create a new viewer $createNewViewer = false; // update the existing viewer with the GUID and gcxUsername $viewerManager->setGUID($guid); $viewerManager->setUserID($gcxUsername); $viewerManager->setLastLogin(); $viewerManager->updateDBTable(); } // viewerAlreadyExists } // accessEntryFound if ($createNewViewer) { // create new viewer (user) $newviewerManager = new RowManager_ViewerManager(); $newviewerManager->setPassWord('xxx'); $newviewerManager->setUserID($gcxUsername); $newviewerManager->setLanguageID(1); // english // TODO this value should not be hard-coded for the account group $newviewerManager->setAccountGroupID(15); // the 'unknown' group $newviewerManager->setIsActive(true); $newviewerManager->setGUID($guid); $newviewerManager->setLastLogin(); $newviewerManager->createNewEntry(); $viewerID = $newviewerManager->getID(); // get the ID of the newly created viewer if ($accessEntryFound) { // update the access table to reference the newly created viewer for the persoa // this is the case where an access table entry may have been orphaned due to the deletion of a viewer $accessManager->setViewerID($viewerID); $accessManager->updateDBTable(); } else { // create an access table entry $newaccessManager = new RowManager_AccessManager(); $newaccessManager->setViewerID($viewerID); $newaccessManager->setPersonID($personID); $newaccessManager->createNewEntry(); } } // put into the 'all' access group $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager(); $viewerAccessGroupManager->setViewerID($viewerID); $viewerAccessGroupManager->setAccessGroupID(ALL_ACCESS_GROUP); // add to the 'all' access group $viewerAccessGroupManager->createNewEntry(); // Debugging code added by Russ Martin // echo "validate login failed<br/>"; // echo "<pre>".print_r($_SESSION,true)."</pre>"; // try again to see if everything updated correctly if ($this->validateLogin($guid)) { // a user/viewer with this GUID now exists in our system $this->isAuthenticated = true; } else { echo "Something has gone wrong: gcxUsername[" . $gcxUsername . "], guid[" . $guid . "]<br/>"; } } } else { // Debugging code added by Russ Martin // echo "session variable for storing GUID is empty<br/>"; } } else { // Debugging code added by Russ Martin // echo "CASUser::checkAuth() failed<br/>"; } } // set hasSession $this->hasSession = $this->viewerID != ''; // if no session if (!$this->hasSession) { // User Credentials are invalid so // if they want me to destroy the session then if ($isDestroySession == true) { // Remove session // session_destroy(); } } }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); $title = $this->labels->getLabel('[view_campuses]'); $columnLabel = $this->labels->getLabel('[view]'); $link = $this->linkValues['view']; $fieldName = 'admin_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); // store the Row Manager's XML Node Name $this->template->set('rowManagerXMLNodeName', RowManager_AdminManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'admin_id'); /* * Set up any additional data transfer to the Template here... */ // This changes the person ids to the person's first name and last name. $personManager = new RowManager_PersonManager(); $personManager->setSortOrder('person_lname'); $personManager->setLabelTemplateLastNameFirstName(); $personList = $personManager->getListIterator(); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); // priv list. $privManager = new RowManager_PrivManager(); $privManager->setSortOrder('priv_accesslevel'); $privList = $privManager->getListIterator(); $privArray = $privList->getDropListArray(); $this->template->set('list_priv_id', $privArray); $templateName = 'siteDataList.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_Admins.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; // store the page labels in XML format... // NOTE: use this location to update any label tags ... // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common Form data. $this->prepareTemplate($path); /* * Form related Template variables: */ // store the button label $this->template->set('buttonText', $this->labels->getLabel('[Update]')); // Insert the date start/end values for the following date fields: // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * Add any additional data required by the template here */ //priv list. $privManager = new RowManager_PrivManager(); $privManager->setSortOrder('priv_accesslevel'); $privList = $privManager->getListIterator(); $privArray = $privList->getDropListArray(); $this->template->set('list_priv_id', $privArray); //Person list. $personManager = new RowManager_PersonManager(); $personManager->setSortOrder('person_lname'); $personManager->setLabelTemplateLastNameFirstName(); $personList = $personManager->getListIterator(); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); // uncomment this line if you are creating a template for this page //$templateName = 'page_AddAdmin.php'; // otherwise use the generic admin box template $templateName = 'siteFormSingle.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; /* * store the link values */ // example: // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; /* * store any additional link Columns */ // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); // store the statevar id to edit $this->template->set('editEntryID', $this->person_id); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Form related Template variables: */ /* * Insert the date start/end values for the following date fields: */ // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * List related Template variables : */ // Store the XML Node name for the Data Access Field List $xmlNodeName = RowManager_PersonManager::XML_NODE_NAME; $this->template->set('rowManagerXMLNodeName', $xmlNodeName); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'person_id'); // store data list to the template // NOTE: we initialize it here to make sure we capture any new data // from a recent processData() call. $dataAccessManager = new RowManager_PersonManager(); $dataAccessManager->setSortOrder($this->sortBy); // $this->dataList = new PersonList( $this->sortBy ); $this->dataList = $dataAccessManager->getListIterator(); $this->template->setXML('dataList', $this->dataList->getXML()); /* * Add any additional data required by the template here */ $templateName = 'siteAdminBox.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditPeople.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; /* * store the link values */ // example: // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; /* * store any additional link Columns */ // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); // store the statevar id to edit $this->template->set('editEntryID', $this->assignment_id); $this->template->set('notice', $this->notice); $this->template->set('errorMessage', $this->error_message); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Form related Template variables: */ /* * Insert the date start/end values for the following date fields: */ // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * List related Template variables : */ // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'assignment_id'); // store data list to the template // NOTE: we initialize it here to make sure we capture any new data // from a recent processData() call. $dataAccessManager = new RowManager_EditCampusAssignmentManager(); $dataAccessManager->setPersonID($this->person_id); if ($this->campus_id != '') { $dataAccessManager->setCampusID($this->campus_id); } $dataAccessManager->setSortOrder($this->sortBy); $this->dataList = $dataAccessManager->getListIterator(); // Store the XML Node name for the Data Access Field List $xmlNodeName = $this->dataList->getRowManagerXMLNodeName(); //RowManager_EditCampusAssignmentManager::XML_NODE_NAME; $this->template->set('rowManagerXMLNodeName', $xmlNodeName); $this->template->setXML('dataList', $this->dataList->getXML()); // enable drop-down list for adding new person assignments $personManager = new RowManager_PersonManager(); $campusManager = new RowManager_CampusManager(); /* $combinedManager = new MultiTableManager(); $combinedManager->addRowManager($personManager); $combinedManager->addRowManager($dataAccessManager, new JoinPair($personManager->getJoinOnPersonID(),$dataAccessManager->getJoinOnPersonID())); // $combinedManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(),$dataAccessManager->getJoinOnCampusID())); if ($this->person_id!='') { $combinedManager->constructSearchCondition( 'person_id', '=', $this->person_id, true ); } if ($this->campus_id!='') { $combinedManager->constructSearchCondition( 'campus_id', '=', $this->campus_id, true ); } $dataList = $combinedManager->getListIterator(); $dataArray = $dataList->getDropListArray(); /**/ // $personManager = new RowManager_PersonManager($this->person_id); // $personList = $personManager->getListIterator(); // $personArray = $personList ->getDropListArray(); // $this->template->set( 'list_person_id', $personArray ); // $personList = $combinedManager->getListIterator(); $personManager->setPersonID($this->person_id); $personManager->setLabelTemplateLastNameFirstName(); $personList = $personManager->getListIterator(); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); // enable drop-down list for adding new campus assignments if ($this->campus_id != '') { $campusManager->setCampusID($this->campus_id); } $campusList = $campusManager->getListIterator(); // $campusList = $combinedManager->getListIterator(); $campusArray = $campusList->getDropListArray(); $this->template->set('list_campus_id', $campusArray); // enable drop-down list for adding new campus assignments $statusManager = new RowManager_CampusAssignmentStatusManager(); $statusList = $statusManager->getListIterator(); // $statusList = $combinedManager->getListIterator(); $statusArray = $statusList->getDropListArray(); $this->template->set('list_assignmentstatus_id', $statusArray); // $dataAccessManager->setPersonID($this->person_id); // $dataAccessManager->setCampusID($this->campus_id); // $this->dataList = new EditCampusAssignmentList( $this->sortBy ); // $this->dataList = $combinedManager->getListIterator(); /* * Add any additional data required by the template here */ // $this->displayValues = $templateName = 'siteAdminBox.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditCampusAssignment.php'; return $this->template->fetch($templateName); }
protected function getPersonID($person_email) { $personID = -1; $persons = new RowManager_PersonManager(); $persons->setEmail($person_email); $personsList = $persons->getListIterator(); $personsArray = $personsList->getDataList(); // grab the first person_id found reset($personsArray); if (count($personsArray) > 0) { $personRecord = current($personsArray); $personID = $personRecord['person_id']; } return $personID; }
function process_Form($sqlResult, $template, $errorMessages) { //get the names that are being searched $fName = $_REQUEST['fName']; $lName = $_REQUEST['lName']; //create the needed row managers $personM = new RowManager_PersonManager(); $accessM = new RowManager_AccessManager(); $viewerM = new RowManager_ViewerManager(); //setup the join pair needed $join = new JoinPair($personM->getJoinOnFieldX('person_id'), $accessM->getJoinOnFieldX('person_id')); //create the multi table manager and initialize it $MTM = new MultiTableManager(); $MTM->addRowManager($personM); $MTM->addRowManager($accessM, $join); //if there is a first name being searched - add that as a condition if ($fName != "") { $MTM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true); $personM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true); } //if there is a last name being searched - add that as a condition if ($lName != "") { $MTM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true); $personM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true); } //jump to a display function to show what was reteived from the person database //$sqlResult = $personM->find(); //$rows = showContents($sqlResult, $personM, $personM->getFields()); //jump to a display function to show what was reteived after joining the databases $sqlResult = $MTM->find(); //$rows = showContents($sqlResult, $personM, $personM->getFields()); $sqlResult->setFirst(); //create a new viewer manager to keep data pure $viewM = new RowManager_ViewerManager(); //loop through the results saving them to be displayed for ($i = 0; $i < $sqlResult->getRowCount(); $i++) { //get the next result and the values $sqlResult->getNext($personM); $f_name[] = $personM->getValueByFieldName('person_fname'); $l_name[] = $personM->getValueByFieldName('person_lname'); $person_id[] = $personM->getValueByFieldName('person_id'); //get the current accessManager values $sqlResult->getCurrent($accessM); //create the join for access table -> viewer table and search the database for the record $join = new JoinPair($accessM->getJoinOnFieldX('viewer_id'), $viewerM->getJoinOnFieldX('viewer_id')); $MTM = new MultiTableManager(); $MTM->addRowManager($accessM); $MTM->addRowManager($viewerM, $join); $MTM->constructSearchCondition('viewer_id', '=', $accessM->getValueByFieldName('viewer_id'), true); $sqlResult2 = $MTM->find(); //add the needed information to the arrays to be displayed in the template file $sqlResult2->getNext($viewM); $viewer_id[] = $viewM->getValueByFieldName('viewer_id'); $user_id[] = $viewM->getValueByFieldName('viewer_userID'); } //check if there was any result from the initial database query, if not add an error message if ($sqlResult->getRowCount() < 1) { $errorMessages = 'Failed to join database to get label'; $template->set('f_name', null); } else { //add the needed information to the template $template->set('f_name', $f_name); $template->set('l_name', $l_name); $template->set('viewer_id', $viewer_id); $template->set('person_id', $person_id); $template->set('user_id', $user_id); } }
* Person Table * * Manages data associated with a person. * * person_id [INTEGER] a person'd unique id * person_fname [STRING] A person's first name * person_lname [STRING] A person's last name * person_phone [STRING] A person's phone number * person_email [STRING] A person's email * person_addr [STRING] A person's address * person_city [STRING] A person's city. * province_id [INTEGER] The person's province. * person_pc [STRING] Person Postal Code * gender_id [INTEGER] The person's gender. */ $Person = new RowManager_PersonManager(); $Person->dropTable(); $Person->createTable(); /* * Gender Table * * Manages the gender table. * * gender_id [INTEGER] The id of the gender. * gedner_desc [STRING] The is the gender type. */ $Gender = new RowManager_GenderManager(); $Gender->dropTable(); $Gender->createTable(); /* * Admin Table
/** * 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 getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // store any additional link Columns $title = $this->labels->getLabel('[Access]'); $columnLabel = $this->labels->getLabel('[View]'); $link = $this->linkValues['view']; $fieldName = 'staffschedule_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); // store the Row Manager's XML Node Name $this->template->set('rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME); //RowManager_StaffScheduleManager // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'staffschedule_id'); // Get the real form name and add to page as sub-heading $form_name = ''; if ($this->formtype_id != '') { $formContext = new RowManager_StaffScheduleTypeManager($this->formtype_id); $form_name = $formContext->getFormName(); } $this->template->set('subheading', $form_name); /* * Set up any additional data transfer to the Template here... */ //TODO: replace this with a reference to a multi_lingual label constant array... $boolArray = array(); $boolArray['0'] = 'no'; $boolArray['1'] = 'yes'; $this->template->set('list_staffschedule_approved', $boolArray); $personManager = new RowManager_PersonManager(); $personManager->setSortOrder('person_lname'); $personManager->setLabelTemplateLastNameFirstName(); $personList = $personManager->getListIterator(); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); $templateName = 'siteDataList.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_FormApprovalListing.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object //$path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels // $this->linkLabels[ 'add' ] = $this->labels->getLabel( '[Add]' ); // $this->linkLabels[ 'edit' ] = $this->labels->getLabel( '[Edit]' ); // $this->linkLabels[ 'del' ] = $this->labels->getLabel( '[Delete]' ); // $this->linkLabels[ 'cont' ] = $this->labels->getLabel( '[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; $this->linkLabels['DownloadCustomReportCSV'] = $this->labels->getLabel('[DownloadCustomReportCSV]'); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); // Set the custom labels for the data columns $this->template->set('listLabels', $this->listLabels); // $this->template->set( 'dataFieldList', $this->getFieldArray($this->customreport_id)); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME ); $this->template->set('rowManagerXMLNodeName', $this->listManager->getRowManagerXMLNodeName()); // Store the XML Node name for the Data Access Field List // $xmlNodeName = $this->dataList->getRowManagerXMLNodeName(); // $this->template->set( 'rowManagerXMLNodeName', $xmlNodeName); // // $xmlNodeName = RowManager_FormFieldValueManager::XML_NODE_NAME; // // $this->template->set( 'rowManagerXMLNodeName', $xmlNodeName); // $this->template->setXML( 'dataList', $this->dataList->getXML() ); // // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'person_id'); // disable the heading? $this->template->set('disableHeading', $this->disableHeading); // Set page sub-heading (i.e. activity type filter) if ($this->customreport_id != '') { $customReports = new RowManager_CustomReportsManager($this->customreport_id); $sub_heading = $customReports->getReportName(); $this->template->set('subheading', $sub_heading); } /* * Set up any additional data transfer to the Template here... */ $person_manager = new RowManager_PersonManager(); $person_list = $person_manager->getListIterator(); $person_manager->setLabelTemplateLastNameFirstName(); $personArray = $person_list->getDropListArray(); /** Create and store download CSV link **/ if ($this->is_blank_page == false) { $downloadLink = array(); $downloadLink['DownloadCustomReportCSV'] = $this->linkValues['DownloadCustomReportCSV']; $this->template->set('linkLabels', $this->linkLabels); $this->template->set('downloadLink', $downloadLink); } $this->template->set('list_person_id', $personArray); // $templateName = 'siteDataList_dynamic.php'; // if you are creating a custom template for this page then // replace $templateName with the following: $templateName = 'page_ViewCustomReport.tpl.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); /* * Set up any additional data transfer to the Template here... */ //Display person names instead of person ids. $personManager = new RowManager_PersonManager(); $personManager->setSortOrder('person_lname'); $personManager->setLabelTemplateLastNameFirstName(); $personList = $personManager->getListIterator(); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); // uncomment this line if you are creating a template for this page //$templateName = 'page_DeleteAdmin.php'; // otherwise use the generic site template $templateName = 'siteDeleteConf.php'; return $this->template->fetch($templateName); }
function process_Form($sqlResult, $template, $errorMessages) { //get the names that are being searched $fName = $_REQUEST['fName']; $lName = $_REQUEST['lName']; //create the needed row managers $personM = new RowManager_PersonManager(); $accessM = new RowManager_AccessManager(); $viewerM = new RowManager_ViewerManager(); //setup the join pair needed $join = new JoinPair($personM->getJoinOnFieldX('person_id'), $accessM->getJoinOnFieldX('person_id')); //create the multi table manager and initialize it $MTM = new MultiTableManager(); $MTM->addRowManager($personM); $MTM->addRowManager($accessM, $join); //if there is a first name being searched - add that as a condition if ($fName != "") { $MTM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true); $personM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true); } //if there is a last name being searched - add that as a condition if ($lName != "") { $MTM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true); $personM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true); } //jump to a display function to show what was reteived from the database $rows = showContents($personM->find(), $personM, $personM->getFields()); echo '<b>' . $rows . ' accounts found in the person table.</b><br><br>'; //jump to a display function to show what was reteived from the database $sqlResult = $MTM->find(); echo '<b>' . $sqlResult->getRowCount() . ' connections made between person table and access groups.</b><br>'; $rows = showContents($sqlResult, $personM, $personM->getFields()); $sqlResult->setFirst(); $viewM = new RowManager_ViewerManager(); for ($i = 0; $i < $sqlResult->getRowCount(); $i++) { $sqlResult->getNext($personM); $f_name[] = $personM->getValueByFieldName('person_fname'); $l_name[] = $personM->getValueByFieldName('person_lname'); $person_id[] = $personM->getValueByFieldName('person_id'); $sqlResult->getCurrent($accessM); $join = new JoinPair($accessM->getJoinOnFieldX('viewer_id'), $viewerM->getJoinOnFieldX('viewer_id')); $MTM = new MultiTableManager(); $MTM->addRowManager($accessM); $MTM->addRowManager($viewerM, $join); $MTM->constructSearchCondition('viewer_id', '=', $accessM->getValueByFieldName('viewer_id'), true); $sqlResult2 = $MTM->find(); $sqlResult2->getNext($viewM); $viewer_id[] = $viewM->getValueByFieldName('viewer_id'); $user_id[] = $viewM->getValueByFieldName('viewer_userID'); } if ($sqlResult->getRowCount() < 1) { $errorMessages = 'Failed to join database to get label'; $template->set('f_name', null); } else { $template->set('f_name', $f_name); $template->set('l_name', $l_name); $template->set('viewer_id', $viewer_id); $template->set('person_id', $person_id); $template->set('user_id', $user_id); } }