/**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $staff_id, $campus_id = "", $semester_id = "")
 {
     parent::__construct();
     // initialzie the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->permManager = new PermissionManager($this->viewer->getViewerID());
     // for looking up the person_id of this staff member
     $this->staff_id = $staff_id;
     $staffManager = new RowManager_StaffManager($this->staff_id);
     // echo 'the staff_id['.$this->staff_id.']<br/>';
     // figure out what campuses to display
     $multiTableManager = new MultiTableManager();
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $isRT = $this->permManager->isRegional();
     if ($isRT) {
         // get all the campuses across the country
         $multiTableManager->addRowManager($campusManager);
     } else {
         // get only the campuses the staff is assigned to
         $assignmentManager = new RowManager_AssignmentsManager();
         $this->person_id = $staffManager->getPersonID();
         $assignmentManager->setPersonID($this->person_id);
         $assignmentManager->setAssignmentStatusID(CA_STAFF);
         $multiTableManager->addRowManager($assignmentManager);
         $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
     }
     $this->campusListIterator = $multiTableManager->getListIterator();
     if ($campus_id != '') {
         // echo 'campus_id is SET ['.$campus_id.']<br/>';
         $this->campus_id = $campus_id;
     } else {
         // set a default campus id
         // echo 'Choosing a default campus<br/>';
         $this->campusListIterator->setFirst();
         if ($this->campusListIterator->moveNext()) {
             $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager());
             $this->campus_id = $campusObject->getID();
         } else {
             die('ERROR - unable to set campus_id - page_StaffWeeklyReport');
         }
     }
     // echo 'the campus_id['.$this->campus_id.']<br/>';
     if ($semester_id != '') {
         $this->semester_id = $semester_id;
     } else {
         // set a default semester id
         $this->semester_id = 4;
         // TODO set this properly
     }
     // echo 'the semester_id['.$this->semester_id.']<br/>';
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_stats::MULTILINGUAL_SERIES_KEY;
     $pageKey = page_CampusWeeklyStatsReport::MULTILINGUAL_PAGE_KEY;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the Class ...
  * </pre>
  * @param $personyear_id [INTEGER] value used to initialize the list.
  * @param $sortBy [STRING] the field name to sort list by
  * @return [void]
  */
 function __construct($campus_id = -1, $assignment_status_list = '', $sortBy = '')
 {
     // NOTE: if you need to narrow the field of the search then uncommnet
     // the following and set the proper search criteria.
     if ($campus_id == '') {
         $campus_id = -1;
     }
     if ($sortBy == '') {
         $sortBy = 'personyear_id';
     }
     $personYearManager = new RowManager_PersonYearManager();
     $campusAssignments = new RowManager_AssignmentsManager();
     $campusAssignments->setCampusID($campus_id);
     $person = new RowManager_PersonManager();
     $searchManager = new MultiTableManager();
     //new RowManager_PersonYearManager();
     $searchManager->addRowManager($campusAssignments);
     $searchManager->addRowManager($personYearManager, new JoinPair($personYearManager->getJoinOnPersonID(), $campusAssignments->getJoinOnPersonID(), JOIN_TYPE_LEFT));
     $searchManager->addRowManager($person, new JoinPair($person->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID()));
     if ($assignment_status_list != '') {
         $searchManager->addSearchCondition('assignmentstatus_id in (' . $assignment_status_list . ')');
         // filter results by student-campus status
     }
     $searchManager->setSortOrder($sortBy);
     //         $this->resultSet = $searchManager->find();
     $foundIterator = $searchManager->getListIterator();
     $foundArray = $foundIterator->getDataList();
     /** Add new person year entries as required **/
     reset($foundArray);
     foreach (array_keys($foundArray) as $k) {
         $record = current($foundArray);
         $person_id = $record['person_id'];
         // person_id must exist given join condition, personyear_id and/or year_id may not
         $personyear_id = $record['personyear_id'];
         /** Add new person year entry if person doesn't have one yet **/
         if ($personyear_id == "") {
             $newPersonYear = new RowManager_PersonYearManager();
             $newPersonYear->setPersonID($person_id);
             $newPersonYear->setYear(RowManager_PersonYearManager::OTHER);
             $newPersonYear->createNewEntry();
         }
         next($foundArray);
     }
     $keepList = 'campus_id';
     $searchManager->deleteValuesExceptSome($keepList);
     $this->resultSet = $searchManager->find();
     //         echo "record array  = <pre>".print_r($foundArray,true)."</pre>";
     // 	     $searchManager->setValueByFieldName("campus_id", $campus_id );
     //$searchManager->setValueByFieldName('module_isCommonLook', '1' );
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $person_id, $ministry_id = '')
 {
     parent::__construct(page_HomePageEventList::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->sortBy = $sortBy;
     $this->person_id = $person_id;
     $this->ministry_id = $ministry_id;
     //        $this->managerInit = $managerInit;
     /** Disable events from being shown if registration date&time have passed **/
     // Filter for shown events that have closed registration or have already started
     // 		   $this->timeSearchCondition = '((event_regEnd < now()) or (event_startDate < now()))';
     //
     //          $events0 = new RowManager_EventManager();
     //          $events0->setOnHomePage('1');
     //          $events0->addSearchCondition($this->timeSearchCondition);
     //
     //          $disable_events_list = $events0->getListIterator();
     //          $disable_events_array = $disable_events_list->getDataList();
     //          reset($disable_events_array);
     //          foreach (array_keys($disable_events_array) as $k)	// go through all events and map user registered status
     //          {
     //             $record = current($disable_events_array);
     //             $eventID = $record['event_id'];
     //
     //      			$event_updater = new RowManager_EventManager($eventID);
     //
     //      			$updateValues = array();
     //      			$updateValues['event_onHomePage'] = '0';	// update the event row to DISABLE display
     //      			$event_updater->loadFromArray( $updateValues );
     //         		$event_updater->updateDBTable();
     //
     //             next($disable_events_array);
     //          }
     /*** Get the countries linked to the campuses that this viewer is associated with **/
     $eventFilter = new MultiTableManager();
     $assignments = new RowManager_AssignmentsManager();
     $assignments->setPersonID($this->person_id);
     $campuses = new RowManager_CampusManager();
     $regions = new RowManager_RegionManager();
     $countries = new RowManager_CountryManager();
     $eventFilter->addRowManager($countries);
     $eventFilter->addRowManager($regions, new JoinPair($countries->getJoinOnCountryID(), $regions->getJoinOnCountryID()));
     $eventFilter->addRowManager($campuses, new JoinPair($regions->getJoinOnRegionID(), $campuses->getJoinOnRegionID()));
     $eventFilter->addRowManager($assignments, new JoinPair($assignments->getJoinOnCampusID(), $campuses->getJoinOnCampusID()));
     $countryList = $eventFilter->getListIterator();
     $countryArray = $countryList->getDataList();
     $country_filter = '';
     reset($countryArray);
     foreach (array_keys($countryArray) as $k) {
         $record = current($countryArray);
         $country_filter .= $record['country_id'] . ',';
         next($countryArray);
     }
     $country_filter = substr($country_filter, 0, -1);
     $dataAccessObject = new RowManager_EventManager();
     // only display those rows that are supposed to be displayed on the home page
     $dataAccessObject->setOnHomePage(true);
     if ($this->ministry_id != '') {
         $dataAccessObject->setMinistryID($this->ministry_id);
     }
     if ($country_filter == '') {
         $country_filter = 1;
     }
     $this->countrySearchCondition = 'country_id in (' . $country_filter . ')';
     $dataAccessObject->addSearchCondition($this->countrySearchCondition);
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new EventList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     $events_array = $this->listManager->getDataList();
     if (count($events_array) > 0) {
         $this->isShowingEvents = true;
     } else {
         $this->isShowingEvents = false;
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_HomePageEventList::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $event_id [INTEGER] Value used to initialize the dataManager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $event_id, $campus_id = '', $to_email_opt = '', $base_opt_value = '')
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     //         $this->person_id = $person_id;
     $this->event_id = $event_id;
     $this->campus_id = $campus_id;
     if ($to_email_opt == '') {
         $this->to_email_choice = FormProcessor_EmailComposer::DEFAULT_RECIPIENTS;
     } else {
         $this->to_email_choice = $to_email_opt;
     }
     $this->base_opt_value = $base_opt_value;
     $this->viewer = $viewer;
     //         if ((!isset($person_id))||($person_id == ''))
     //         {
     // 	        $this->person_id = $this->getPersonIDfromViewerID();
     // 	        $formAction .= '&'.modulecim_reg::PERSON_ID.'='.$this->person_id;
     //         }
     //         if (($isInRegProcess == true)&&($registration_id == ''))
     //         {
     // 	         $this->setRegistrationID();	// get registration ID for the rest of the process
     //         		$formAction .= '&'.modulecim_reg::REG_ID.'='.$this->registration_id;
     //         		// also note that person_id is set above if it is also not set yet
     //         		if ($person_id == -1)
     //         		{
     // 	        		// pass on new person_id to GET parameters
     // 	        		$formAction = str_replace( modulecim_reg::PERSON_ID.'=-1', modulecim_reg::PERSON_ID.'='.$this->person_id, $formAction);
     //         		}
     //
     //      	  }
     $fieldList = FormProcessor_EmailComposer::FORM_FIELDS;
     $fieldDisplayTypes = FormProcessor_EmailComposer::FORM_FIELD_TYPES;
     parent::__construct($formAction, $fieldList, $fieldDisplayTypes);
     $this->pathModuleRoot = $pathModuleRoot;
     // if ($this->pageType == FormProcessor_EmailComposer::CAMPUS_EMAIL)
     if ($this->campus_id != '') {
         $this->TO_ADDRESS_OPTIONS = array('0' => 'All Campus Registrants', '1' => 'Campus Registrants - Completed', '2' => 'Campus Registrants - Incomplete', '3' => 'Campus Registrants - Cancelled', '4' => 'Campus Registrants - Males', '5' => 'Campus Registrants - Females', '6' => 'Custom List of Campus Registrants...');
         //, '6'=>'All Campus Club Students'
     } else {
         $this->TO_ADDRESS_OPTIONS = array('0' => 'All Event Registrants', '1' => 'Event Registrants - Completed', '2' => 'Event Registrants - Incomplete', '3' => 'Event Registrants - Cancelled', '4' => 'Event Registrants - Males', '5' => 'Event Registrants - Females', '6' => 'Custom List of Event Registrants...');
     }
     // To make sure this is not exploited to edit any other person's id.
     // If the user has no privileges, this sets the viewer id to be his/her own,
     // even if the variable given to it is not the viewer's person id.
     // NOTE: anyone with higher previliges can edit any person's info, by simply
     // changing the posted variable value.			// NOTE: this code was causing problems in app_cim_reg module
     // Now load the access Priviledge manager of this viewer
     //         $this->accessPrivManager = new RowManager_AdminManager( );
     //         // Get the person ID
     //         $accessManager = new RowManager_AccessManager( );
     //         $accessManager->loadByViewerID( $this->viewer->getViewerID( ) );
     //         $personID = $accessManager->getPersonID();
     //         // Get the permissions the person has.
     //         $this->accessPrivManager->loadByPersonID( $personID );
     //         if ( !$this->accessPrivManager->isLoaded() ) {
     //           $this->person_id=$personID;
     // /        }
     //End of check.
     // figure out the important fields for the dataManager
     //       $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new MultiTableManager();
     $persons = new RowManager_PersonManager();
     //$this->person_id
     $registrations = new RowManager_RegistrationManager();
     $registrations->setEventID($this->event_id);
     $this->dataManager->addRowManager($persons);
     $this->dataManager->addRowManager($registrations, new JoinPair($persons->getJoinOnPersonID(), $registrations->getJoinOnPersonID()));
     if ($this->campus_id != '') {
         $assignments = new RowManager_AssignmentsManager();
         $assignments->setCampusID($this->campus_id);
         $this->dataManager->addRowManager($assignments, new JoinPair($assignments->getJoinOnPersonID(), $persons->getJoinOnPersonID()));
     }
     $this->dataManager->setSortOrder('person_lname,person_fname');
     //       $this->dataManager->setFieldsOfInterest( $fieldsOfInterest );
     $this->formValues = $this->dataManager->getArrayOfValues();
     // echo "form values:<br><pre>".print_r($this->formValues,true)."</pre>";
     // 			$eventInfo = new RowManager_EventManager($this->event_id);
     // 			$event_email = $eventInfo->getEventEmail();
     // 			echo $event_email;
     $this->formValues['from_email'] = $this->getPersonEmailfromViewerID();
     $this->formValues['to_email'] = $this->base_opt_value . $this->to_email_choice;
     // set jumplist SELECTED value
     // 			$this->formValues['email_subject'] = $campus_name.' - '.$event_name.' Notice';
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_EmailComposer::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $weeklyReport_id [INTEGER] Value used to initialize the dataManager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $weeklyReport_id, $staff_id, $week_id = '', $campus_id = '')
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     $fieldList = FormProcessor_StaffAdditionalWeeklyStats::FORM_FIELDS;
     $fieldDisplayTypes = FormProcessor_StaffAdditionalWeeklyStats::FORM_FIELD_TYPES;
     parent::__construct($formAction, $fieldList, $fieldDisplayTypes);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->weeklyReport_id = $weeklyReport_id;
     $this->campus_id = $campus_id;
     $this->staff_id = $staff_id;
     if ($week_id != '') {
         // echo 'week_id is SET ['.$week_id.']<br/>';
         $this->week_id = $week_id;
     } else {
         // give a default value to the week id
         $weekManager = new RowManager_WeekManager();
         if ($weekManager->loadByDate(date('Y-m-d', time()))) {
             $this->week_id = $weekManager->getID();
         } else {
             die("ERROR - couldn't see week_id - page_StaffAdditionalWeeklyReport.php");
         }
     }
     // for looking up the person_id of this staff member
     $staffManager = new RowManager_StaffManager($this->staff_id);
     // setup the
     $assignmentManager = new RowManager_AssignmentsManager();
     $assignmentManager->setPersonID($staffManager->getPersonID());
     $assignmentManager->setAssignmentStatusID(CA_STAFF);
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($assignmentManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
     $this->campusListIterator = $multiTableManager->getListIterator();
     if ($campus_id != '') {
         // echo 'campus_id is SET ['.$campus_id.']<br/>';
         $this->campus_id = $campus_id;
     } else {
         // set a default campus id
         // echo 'Choosing a default campus<br/>';
         $this->campusListIterator->setFirst();
         if ($this->campusListIterator->moveNext()) {
             $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager());
             $this->campus_id = $campusObject->getID();
         } else {
             die('ERROR - unable to set campus_id - page_StaffWeeklyReport');
         }
     }
     // figure out the important fields for the dataManager
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_WeeklyReportManager($this->week_id, $this->staff_id, $this->campus_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_stats::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_stats::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_StaffAdditionalWeeklyStats::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 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);
     // 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);
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     /*
      * List related Template variables :
      */
     // Store the XML Node name for the Data Access Field List
     $xmlNodeName = RowManager_AssignmentsManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // 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_AssignmentsManager();
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new AssignmentsList( $this->sortBy );
     $dataAccessManager->setPersonID($this->person_id);
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      *  Set up any additional data transfer to the Template here...
      */
     //Replace Campus ID by Campus Name.
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $campusList = $campusManager->getListIterator();
     $campusArray = $campusList->getDropListArray();
     $this->template->set('list_campus_id', $campusArray);
     $templateName = 'siteAdminBox.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_CampusAssignments.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);
     // temporarily reset the form values so the defaults show up properly in the jumplists
     $this->formValues['week_id'] = $this->linkValues['weekJumpLink'] . $this->week_id;
     $this->formValues['campus_id'] = $this->linkValues['campusJumpLink'] . $this->campus_id;
     // 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->morestats_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_MoreStatsManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'morestats_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_MoreStatsManager();
     // echo 'This campus ID['.$this->campus_id.']<br/>';
     $dataAccessManager->setCampusID($this->campus_id);
     $dataAccessManager->setWeekID($this->week_id);
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new MoreStatsList( $this->sortBy );
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     // week list
     $jumpLink = $this->linkValues['weekJumpLink'];
     $weekManager = new RowManager_WeekManager();
     $weekManager->setSortOrder('week_endDate');
     $weekList = new ListIterator($weekManager);
     $jumpList = $weekList->getDropListArray(null, $jumpLink);
     $this->template->set('list_week_id', $jumpList);
     // for looking up the person_id of this staff member
     $staffManager = new RowManager_StaffManager($this->staff_id);
     // campus list
     $assignmentManager = new RowManager_AssignmentsManager();
     $assignmentManager->setPersonID($staffManager->getPersonID());
     $assignmentManager->setAssignmentStatusID(CA_STAFF);
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($assignmentManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
     $jumpLink = $this->linkValues['campusJumpLink'];
     $campusList = $multiTableManager->getListIterator();
     $campusArray = array();
     $campusList->setFirst();
     while ($campusList->moveNext()) {
         $campusObject = $campusList->getCurrent(new RowManager_CampusManager());
         $campusArray[$jumpLink . $campusObject->getID()] = $campusObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_campus_id', $campusArray);
     // method list
     $typeManager = new RowManager_ExposureTypeManager();
     $typeManager->setSortOrder('exposuretype_desc');
     $typeList = $typeManager->getListIterator();
     $typeArray = $typeList->getDropListArray();
     $this->template->set('list_exposuretype_id', $typeArray);
     $templateName = 'siteFormDataList.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_MoreStats.php';
     return $this->template->fetch($templateName);
 }
 protected function assignCampus($personID)
 {
     if (isset($this->campus_id) && $this->campus_id != '') {
         $campusAssign = new RowManager_AssignmentsManager();
         $campusAssign->setPersonID($personID);
         $campusAssign->setCampusID($this->campus_id);
         $updateValues = array();
         $updateValues['person_id'] = $personID;
         $updateValues['campus_id'] = $this->campus_id;
         // Store values in AssignmentsManager object
         $campusAssign->loadFromArray($updateValues);
         //              echo "<pre>".print_r($updateValues ,true)."</pre>";
         // store new information
         $campusAssign->createNewEntry();
     }
 }
 /**
  * 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('[Continue]'));
     // 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
      */
     // semester list
     $semesterManager = new RowManager_SemesterManager();
     $semesterList = $semesterManager->getListIterator();
     $semesterArray = $semesterList->getDropListArray();
     $this->template->set('list_semester_id', $semesterArray);
     // for looking up the person_id of this staff member
     $staffManager = new RowManager_StaffManager($this->staff_id);
     // campus list
     $assignmentManager = new RowManager_AssignmentsManager();
     $assignmentManager->setPersonID($staffManager->getPersonID());
     $assignmentManager->setAssignmentStatusID(CA_STAFF);
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($assignmentManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
     $campusList = $multiTableManager->getListIterator();
     $campusArray = array();
     $campusList->setFirst();
     while ($campusList->moveNext()) {
         $campusObject = $campusList->getCurrent(new RowManager_CampusManager());
         $campusArray[$campusObject->getID()] = $campusObject->getLabel();
     }
     $this->template->set('list_campus_id', $campusArray);
     // uncomment this line if you are creating a template for this page
     //$templateName = 'page_SelectPrcSemesterCampus.php';
     // otherwise use the generic admin box template
     $templateName = 'siteFormSingle.php';
     return $this->template->fetch($templateName);
 }
Example #10
0
 /**
  * function processData
  * <pre>
  * Processes the data for this form.
  * </pre>
  * @return [void]
  */
 function processData()
 {
     // save the value of the Foriegn Key(s)
     /*[RAD_ADMINBOX_FOREIGNKEY]*/
     // store values in table manager object.
     $this->dataManager->loadFromArray($this->formValues);
     // now update the DB with the values
     if (!$this->dataManager->isLoaded()) {
         // create the new admin entry
         $this->dataManager->createNewEntry();
         // get the primary key value of the newly created admin
         $adminID = $this->dataManager->getID();
         // echo 'adminID['.$adminID.']<br/>';
         // echo 'Creating new entry<br/>';
         // if priv is campus level
         if ($this->dataManager->hasCampusPriv()) {
             // echo 'CAMPUS LEVEL PRIV<br/>';
             $personID = $this->dataManager->getPersonID();
             // echo 'personID['.$personID.']<br/>';
             // find out all the campuses the person is assigned to
             $assignmentManager = new RowManager_AssignmentsManager();
             $assignmentManager->setPersonID($personID);
             // for each assigned campus, give campus level admin access
             $campusList = $assignmentManager->getListIterator();
             while ($campusAssignment = $campusList->getNext()) {
                 // echo 'found campus <br/>';
                 $campusAdminManager = new RowManager_CampusAdminManager();
                 $campusAdminManager->setAdminID($adminID);
                 $campusAdminManager->setCampusID($campusAssignment->getCampusID());
                 $campusAdminManager->createNewEntry();
             }
         } else {
             // echo 'SUPER ADMIN PRIV<br/>';
             // do nothing
         }
     } else {
         $this->dataManager->updateDBTable();
     }
 }
 /**
  * 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 displayGroups()
 {
     // This array get passed back to the template multiple time
     $groupCollectionArray = array();
     $multiTableManager = new MultiTableManager();
     $groupManager = new RowManager_GroupManager();
     $superAdminManager = new RowManager_PermissionsSuperAdminManager();
     //SUPER ADMIN
     //Check if user's Viewer_id is in the PermissionSuperAdmin table
     //If the user is a super admin then show all gorups per campus including public groups
     if ($superAdminManager->loadByViewerID($this->viewer->getViewerID())) {
         // the viewer is a super admin
         echo "ViewerID[" . $this->viewer->getViewerID() . "] is a super admin<br/>";
         $campusManager = new RowManager_CampusManager();
         $campusArray = array();
         $this->listIterator = $campusManager->getListIterator();
         $this->listIterator->setFirst();
         while ($this->listIterator->moveNext()) {
             $group = $this->listIterator->getCurrent(new RowManager_CampusManager());
             $campusArray[] = $group->getCampusID();
         }
         //echo "<pre>".print_r($campusArray)."</pre>";
         foreach ($campusArray as $key => $campusID) {
             $campusManager = new RowManager_CampusManager($campusID);
             $campusGroupManager = new RowManager_CampusGroupManager();
             $campusGroupManager->setCampusID($campusID);
             $groupManager = new RowManager_GroupManager();
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($groupManager);
             $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT));
             $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusGroupManager->getJoinOnCampusID(), JOIN_TYPE_RIGHT));
             //Go through the result and save all the groups of that campus to an array
             $campusGroupArray = array();
             $this->listIterator = $multiTableManager->getListIterator();
             $this->listIterator->setFirst();
             while ($this->listIterator->moveNext()) {
                 $group = $this->listIterator->getCurrent(new RowManager_CampusGroupManager());
                 $campusGroupArray[] = $group;
             }
             //set the campusID and CampusDesc for the $campusGroupArray
             $groupCollectionArray[] = new GroupCollection($campusManager->getShortDesc(), $campusID, $campusGroupArray);
         }
         //TODO - not a correct join
         //TODO - get all campus ID and groups
         //TODO - get all public groups
     } else {
         //STAFF OR STUDENT
         //If the user is a student or staff then they should have campus assignmnets in cim_hrdb_assignment
         //Find all the campuses and save them in the $campusAssigment array
         $campusAssignments = array();
         $statusArray = array();
         $statusArray[] = CA_STAFF;
         $statusArray[] = CA_STUDENT;
         foreach ($statusArray as $key => $statusID) {
             // filter from the cim_hrdb_assignment table
             $assignmentManager = new RowManager_AssignmentsManager();
             $assignmentManager->setPersonID($this->personID);
             $assignmentManager->setAssignmentStatus($statusID);
             $assignmentList = new ListIterator($assignmentManager);
             $assignmentList->setFirst();
             while ($assignmentList->moveNext()) {
                 $assManager = $assignmentList->getCurrent(new RowManager_AssignmentsManager());
                 $campusAssignments[] = $assManager->getCampusID();
             }
         }
         //CAMPUS ADMIN
         //some users can be admin to a campus that they are neither a student or staff for
         //Check cim_sch_permissionsCampusAdmin for the viewer id of the user
         //for each found save the campusID in the $campusAssignments table
         $permissionsCampusAdmin = new RowManager_PermissionsCampusAdminManager();
         $permissionsCampusAdmin->setViewerID($this->viewer->getViewerID());
         $campusAdminList = new ListIterator($permissionsCampusAdmin);
         $campusAdminList->setFirst();
         while ($campusAdminList->moveNext()) {
             $permCampus = $campusAdminList->getCurrent(new RowManager_PermissionsCampusAdminManager());
             //for each campuses found, store in array
             $campusAssignments[] = $permCampus->getCampusID();
         }
         //remove any duplicate campus ID in the array
         $campusAssignments = array_unique($campusAssignments);
         //After collection all the campusIDs lets go through each campusID and get the groups
         //for each campusID find all the groups in $campusGroupManager table
         //Save the groups in an array taged with the campusID, Shortdesc
         foreach ($campusAssignments as $key => $campusID) {
             //Set the campusID so we can get the shortDesc at the end
             $campusManager = new RowManager_CampusManager($campusID);
             //Join cim_sch_Group and cim_sch_campusgroup
             $campusGroupManager = new RowManager_CampusGroupManager();
             $campusGroupManager->setCampusID($campusID);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($campusGroupManager);
             $groupManager = new RowManager_GroupManager();
             $multiTableManager->addRowManager($groupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID()));
             //Go through the result and save all the groups of that campus to an array
             $campusGroupArray = array();
             $this->listIterator = $multiTableManager->getListIterator();
             $this->listIterator->setFirst();
             while ($this->listIterator->moveNext()) {
                 $group = $this->listIterator->getCurrent(new RowManager_GroupManager());
                 $campusGroupArray[] = $group;
             }
             //set the campusID and CampusDesc for the $campusGroupArray
             $groupCollectionArray[] = new GroupCollection($campusManager->getShortDesc(), $campusID, $campusGroupArray);
         }
         //GROUP ADMIN
         //The user might be a group admin so we should display that group as well
         //We have to find the which groups the user is admin for in cim_sch_permissionsGroupAdmin
         //For each of these gorups, look in cim_sch_campusGroup table and find and store the campusID in an array
         //Use the campusID array and for each campusID and only save the gorups with the same campusID
         //Save all the gorups in the $gorupCollectionArray
         //Set a fillter for only show results if its the user's ViewerID
         $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
         $permissionsGroupAdminManager->setViewerID($this->viewer->getViewerID());
         //Set Fillter to only show results that are a campus group
         $groupManager = new RowManager_GroupManager();
         $groupManager->setGroupTypeID(1);
         //Make the join of tables cim_sch_group, cim_sch_campusGroup, cim_sch_permissionsGroupAdmin
         $campusGroupManager = new RowManager_CampusGroupManager();
         $multiTableManager = new MultiTableManager();
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT));
         $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT));
         //Go through the results and save the campusID of that group
         $campusGroupArray = array();
         $this->listIterator = $multiTableManager->getListIterator();
         $this->listIterator->setFirst();
         while ($this->listIterator->moveNext()) {
             $group = $this->listIterator->getCurrent(new RowManager_CampusGroupManager());
             $campusGroupArray[] = $group->getCampusID();
         }
         //For each campus found, go through the result again and fillter by campusID
         //Only the groups of the same campusID are saved together
         foreach ($campusGroupArray as $key => $campusID) {
             //This allows us to get the campus shortDesc at the end
             $campusManager = new RowManager_CampusManager($campusID);
             //same code as before to join the tables
             $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
             $permissionsGroupAdminManager->setViewerID($this->viewer->getViewerID());
             $campusGroupManager = new RowManager_CampusGroupManager();
             $campusGroupManager->setCampusID($campusID);
             $groupManager = new RowManager_GroupManager();
             $groupManager->setGroupTypeID(1);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($groupManager);
             $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT));
             $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT));
             //go through the results and save the gorups
             $campusGroupArray = array();
             $this->listIterator = $multiTableManager->getListIterator();
             $this->listIterator->setFirst();
             while ($this->listIterator->moveNext()) {
                 $group = $this->listIterator->getCurrent(new RowManager_GroupManager());
                 $campusGroupArray[] = $group;
             }
             //set the campusID and CampusDesc for the $campusGroupArray
             $groupCollectionArray[] = new GroupCollection($campusManager->getShortDesc(), $campusID, $campusGroupArray);
         }
         //PUBLIC Groups
         //Show all groups in cim_sch_group with the groupTypeID of 2 (public)
         //The public gorup does not have a campus assign
         $campusID = 0;
         //The public gorup desc is public, this is shown in the template
         $publicGroupDesc = "Public";
         //Set the public gorup fillter
         $thisIsAPublicGroup = 2;
         $groupManager = new RowManager_GroupManager();
         $groupManager->setGroupTypeID($thisIsAPublicGroup);
         //go through the results and save the groups
         $groupArray = array();
         $this->listIterator = $groupManager->getListIterator();
         $this->listIterator->setFirst();
         while ($this->listIterator->moveNext()) {
             $group = $this->listIterator->getCurrent(new RowManager_GroupManager());
             $groupArray[] = $group;
         }
         //save the public groups to the array
         $groupCollectionArray[] = new GroupCollection($publicGroupDesc, $campusID, $groupArray);
     }
     //END OF IF
     //KSL
     //NORMAL
     /*
     		 $campusAssignments = array();
     
     		 $statusArray = array();
     		 $statusArray[] = CA_STAFF;
     		 $statusArray[] = CA_STUDENT;
     		 foreach( $statusArray as $key=>$statusID )
     		 {
     		 // filter from the cim_hrdb_assignment table
     		 $assignmentManager = new RowManager_AssignmentsManager();
     		 $assignmentManager->setPersonID( $this->personID );
     		 $assignmentManager->setAssignmentStatus( $statusID );
     
     		  
     
     		 $assignmentList = new ListIterator( $assignmentManager );
     		 $assignmentList->setFirst();
     		 while ( $assignmentList->moveNext() )
     		 {
     		 $assManager = $assignmentList->getCurrent( new RowManager_AssignmentsManager() );
     		 $campusAssignments[] = $assManager->getCampusID();
     		 }
     
     		 }
     		 // echo "<pre>".print_r($campusAssignments, true)."</pre>";
     
     		 // STEP 2:  get the appropriate groups
     		 foreach( $campusAssignments as $key=>$campusID )
     		 {
     		 $campusManager = new RowManager_CampusManager( $campusID );
     
     		 $campusGroupManager = new RowManager_CampusGroupManager();
     		 $campusGroupManager->setCampusID( $campusID );
     
     		 $multiTableManager = new MultiTableManager();
     		 $multiTableManager->addRowManager($campusGroupManager);
     		  
     		 $groupManager = new RowManager_GroupManager();
     		 $multiTableManager->addRowManager( $groupManager, new JoinPair( $campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID() ) );
     
     		 $campusGroupArray = array();
     		 $this->listIterator = $multiTableManager->getListIterator();
     		 $this->listIterator->setFirst();
     		 while( $this->listIterator->moveNext() )
     		 {
     		 $group = $this->listIterator->getCurrent(new RowManager_GroupManager());
     		 $campusGroupArray[] = $group;
     		 }
     
     		 $groupCollectionArray[] = new GroupCollection( $campusManager->getShortDesc(), $campusID, $campusGroupArray );
     		 }*/
     return $this->template->set('groupCollectionArray', $groupCollectionArray);
 }
 /**
  * function isBasicAdmin
  * <pre>
  * a simple check to determine if viewer is admin for *some* campus and *some* event
  * </pre>
  * @return [BOOL] 
  */
 function isBasicAdmin($eventID = 'DEFAULT')
 {
     // check if viewer is a super-admin
     if (isset($this->isCampusAdmin[PrivilegeManager::ALL_EVENTS]) && $this->isCampusAdmin[PrivilegeManager::ALL_EVENTS] == PrivilegeManager::ALL_CAMPUSES) {
         return true;
     }
     if (isset($this->isCampusAdmin)) {
         // if no event ID passed in (i.e. very basic check) or eventID is valid for this admin
         if ($eventID == 'DEFAULT' || isset($this->isCampusAdmin[$eventID])) {
             // *some* campus should have been stored in campus admin array
             // 		    echo "<pre>".print_r($this->isCampusAdmin[$evebt=true)."</pre>";
             if (count($this->isCampusAdmin) > 0) {
                 return true;
             }
         }
     }
     // otherwise check if viewer is staff at some campus
     // 		    $viewers = new RowManager_ViewerManager();
     // 		    $viewers->set($this->viewer_id);
     $access = new RowManager_AccessManager();
     $access->setViewerID($this->viewer_id);
     $person = new RowManager_PersonManager();
     $staff = new RowManager_StaffManager();
     $staff->setIsActive('1');
     $assign = new RowManager_AssignmentsManager();
     $assign->setAssignmentStatus(CA_STAFF);
     $campus = new RowManager_CampusManager();
     $multiTables = new MultiTableManager();
     $multiTables->addRowManager($access);
     $multiTables->addRowManager($person, new JoinPair($access->getJoinOnPersonID(), $person->getJoinOnPersonID()));
     $multiTables->addRowManager($staff, new JoinPair($person->getJoinOnPersonID(), $staff->getJoinOnPersonID()));
     $multiTables->addRowManager($assign, new JoinPair($assign->getJoinOnPersonID(), $person->getJoinOnPersonID()));
     $multiTables->addRowManager($campus, new JoinPair($assign->getJoinOnCampusID(), $campus->getJoinOnCampusID()));
     $campusList = $multiTables->getListIterator();
     $campusArray = $campusList->getDataList();
     // 		    echo 'campus array for user: <pre>'.print_r($campusArray, true).'</pre><br>';
     // some campus was found, so viewer is admin for this campus (for all events)
     if (isset($campusArray) && count($campusArray) > 0) {
         // store the viewer in the database as a campus id assigned to the current campus
         /*** TODO: low priority because it is an optimization ***/
         return true;
     }
     return false;
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_ViewGroups::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //Get person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $this->personID = $accessManager->getPersonID();
     echo "ViewerID: " . $this->viewer->getViewerID() . " <br>personID: " . $this->personID . "<br>";
     /*
      * The code below contains the different permission cases for view groups.
      * 
      * Check 1 = check if the user is a SUPER ADMIN
      * Check 2 = check if the user is a STAFF and which campuses he/she is assigned to, taken from HRDB
      * Check 3 =check cim_sch_permissionCampusAdmin for which CAMPUSES this user is ADMIN for
      * Check 4 = check cim_sch_permissionGroupAdmin for which GROUPS this user is ADMIN for
      * If check 1-4 FAIL then ViewGroup will show nothing. (This user is a normal user and have not created any groups .
      */
     $multiTableManager = new MultiTableManager();
     $groupManager = new RowManager_GroupManager();
     $superAdminManager = new RowManager_PermissionsSuperAdminManager();
     //SUPER ADMIN
     //Check if user's Viewer_id is in the PermissionSuperAdmin table
     if ($superAdminManager->loadByViewerID($this->viewer->getViewerID())) {
         // the viewer is a super admin
         echo "ViewerID[" . $this->viewer->getViewerID() . "] is a super admin<br/>";
         $campusGroupManager = new RowManager_CampusGroupManager();
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
     } else {
         //STAFF
         // This array stores all the campuses associated to the user.
         //This array is continually populated
         $campusArray = array();
         //check HRDB if the user is a staff
         $assignmentManager = new RowManager_AssignmentsManager();
         $assignmentManager->setPersonID($this->personID);
         $assignmentManager->setAssignmentStatus(CA_STAFF);
         $assList = new ListIterator($assignmentManager);
         $assList->setFirst();
         while ($assList->moveNext()) {
             $assMan = $assList->getCurrent(new RowManager_AssignmentsManager());
             //for each campuses found, store in array
             $campusArray[] = $assMan->getCampusID();
         }
         //CAMPUS ADMIN
         //Check cim_sch_permissionsCampusAdmin for the viewer id of the user
         $permissionsCampusAdmin = new RowManager_PermissionsCampusAdminManager();
         $permissionsCampusAdmin->setViewerID($this->viewer->getViewerID());
         $campusAdminList = new ListIterator($permissionsCampusAdmin);
         $campusAdminList->setFirst();
         while ($campusAdminList->moveNext()) {
             $permCampus = $campusAdminList->getCurrent(new RowManager_PermissionsCampusAdminManager());
             //for each campuses found, store in array
             $campusArray[] = $permCampus->getCampusID();
         }
         //remove any duplicate campus ID in the array
         $campusArray = array_unique($campusArray);
         //GROUP ADMIN
         $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
         $campusGroupManager = new RowManager_CampusGroupManager();
         //send a list of campues and the viewer ID to constrict the search condition
         //The Viewer_id is use to check the cim_sch_permissionsGroupAdmin table for
         // groups that were created by the user
         $searchCond = $campusGroupManager->returnSearchCondition($campusArray, $this->viewer->getViewerID());
         //create the appropriate join between 3 tables
         //Join cim_sch_group and cim_sch_permissionsGroupAdmin and cim_sch_campusGroup
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addSearchCondition($searchCond);
     }
     /*Case 3: Group Admin - access to an individual group and can create other group admins 
     				(ex. DGL)
     				Normal User - can only submit schedule, assume this unless given other permissions
     					Check the group admin table 
     	
     				check cim_sch_permissiongroupadmin -> cim_sch_campusgroup -> cim_sch_group
     				filter on viewer id 
     
     
     		Case 4: All staff - implicit access to all groups on all campuses where their status is staff 
     				check cim_hrdb_staff table
     					if true
     						get all campuses from cim_hrdb_assignment where assignment status id = 3
     
     
             */
     /*$groupManager = new RowManager_GroupManager();
       $multiTableManager = new MultiTableManager();
       
       $campusGroupManager = new RowManager_CampusGroupManager();
       
       $multiTableManager->addRowManager( $campusGroupManager );
       $multiTableManager->addRowManager( $groupManager, new JoinPair( $campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT ) );*/
     // $dataAccessObject = $multiTableManager;
     $multiTableManager->setSortOrder('campus_id');
     //******Not sure this is the way to do it*****
     //       $this->listManager = new GroupList( $sortBy );
     $this->listManager = $multiTableManager->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_sch::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_sch::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewGroups::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $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);
 }
Example #16
0
  * staff_id [INTEGER]  The id for the staff member.
  * person_id [INTEGER]  The id of the person who is staff.
  */
 $Staff = new RowManager_StaffManager();
 $Staff->dropTable();
 $Staff->createTable();
 /*
  * Assignments Table
  *
  * This manages the campus assignments table.
  *
  * assignment_id [INTEGER]  This is the key for this table.
  * person_id [INTEGER]  The is the person id for the person assigned to the campus.
  * campus_id [INTEGER]  The is the campus the person is assigned to.
  */
 $Assignments = new RowManager_AssignmentsManager();
 $Assignments->dropTable();
 $Assignments->createTable();
 /*
  * Access Table
  *
  * This manages the access table.
  *
  * access_id [INTEGER]  This is the key for the table
  * viewer_id [INTEGER]  This is the viewer(user) id of the user who is assigned to a person id.
  * person_id [INTEGER]  This is the person id connected to the viewer id.
  */
 $Access = new RowManager_AccessManager();
 $Access->dropTable();
 $Access->createTable();
 /*
 /**
  * function processData
  * <pre>
  * Processes the data for this form.
  * </pre>
  * @return [void]
  */
 function processData()
 {
     // save the value of the Foriegn Key(s)
     /*[RAD_ADMINBOX_FOREIGNKEY]*/
     // store values in table manager object.
     $this->dataManager->loadFromArray($this->formValues);
     // now update the DB with the values
     if (!$this->dataManager->isLoaded()) {
         $this->dataManager->createNewEntry();
         //Assign the person to a campus if this is a new entry.
         $personID = $this->dataManager->getPersonID();
         $assignmentManager = new RowManager_AssignmentsManager();
         $assignmentManager->setPersonID($personID);
         $assignmentManager->setCampusID($this->campus_id);
         $assignmentManager->createNewEntry();
     } else {
         $this->dataManager->updateDBTable();
     }
 }
Example #18
0
 protected function setRegistrationStatus()
 {
     $backup_event_id = -1;
     $status_message = 'No registration created!';
     if (isset($this->reg_id) && $this->reg_id != '') {
         // check cim_hrdb_person to determine if a person has been affiliated with registration
         $regs = new RowManager_RegistrationManager();
         $regs->setRegID($this->reg_id);
         $person = new RowManager_PersonManager();
         $regCheck = new MultiTableManager();
         $regCheck->addRowManager($regs);
         $regCheck->addRowManager($person, new JoinPair($regs->getJoinOnPersonID(), $person->getJoinOnPersonID()));
         $regsList = $regCheck->getListIterator();
         $regsArray = $regsList->getDataList();
         // variables to be used for later checks
         $person_id = '';
         $confirm_num = '';
         $person_address = '';
         $person_email = '';
         $person_city = '';
         $person_province = '0';
         $person_pcode = '';
         $person_phone = '';
         reset($regsArray);
         // should be only one registration status (for 1 reg_id)
         foreach (array_keys($regsArray) as $k) {
             $record = current($regsArray);
             $backup_event_id = $record['event_id'];
             $person_id = $record['person_id'];
             $confirm_num = $record['registration_confirmNum'];
             $person_email = $record['person_email'];
             $person_address = $record['person_addr'];
             $person_city = $record['person_city'];
             $person_province = $record['province_id'];
             $person_pcode = $record['person_pc'];
             $person_phone = $record['person_phone'];
             next($regsArray);
         }
         // determine whether any person records were found for registration
         if (!isset($regsArray) || count($regsArray) < 1) {
             $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
             $status_message = 'No person record associated with registration.';
             // ASSUMPTION: set reg_id ==> created registration record
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         } else {
             if (isset($regsArray) && ($person_email == '' || $person_address == '' || $person_city == '' || $person_province == '' || $person_province == '0' || $person_pcode == '' || $person_phone == '')) {
                 $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
                 $status_message = 'Please ensure that you have entered the following data:' . '<br> name, e-mail address, permanent address, city, province, postal code, and phone number.';
                 return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
             }
         }
         // check cim_hrdb_assignment to determine that the person has been assigned to a campus
         $assign = new RowManager_AssignmentsManager();
         $assign->setPersonID($person_id);
         $status = new RowManager_CampusAssignmentStatusManager();
         $campusAssign = new MultiTableManager();
         $campusAssign->addRowManager($assign);
         $campusAssign->addRowManager($status, new JoinPair($assign->getJoinOnStatusID(), $status->getJoinOnStatusID()));
         $regsList = $campusAssign->getListIterator();
         $regsArray = $regsList->getDataList();
         // variables to be used for later checks
         $assignArray = array();
         $this->campus_id = '';
         reset($regsArray);
         // should be only one campus assignment status (for now, later maybe not)
         foreach (array_keys($regsArray) as $k) {
             $record = current($regsArray);
             if ($record['assignmentstatus_desc'] != RowManager_AssignmentsManager::UNKNOWN_STATUS) {
                 $this->campus_id = $record['campus_id'];
                 $assignArray[$this->campus_id] = $record['assignmentstatus_desc'];
             }
             next($regsArray);
         }
         // determine whether a campus assignment exists for the found person linked to the registration
         if (!isset($assignArray) || count($assignArray) < 1) {
             $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
             $status_message = "Please ensure that the registrant is assigned to a valid campus and has a valid status.";
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         }
         // check cim_reg_fieldvalues to determine whether field values have been set for the registration
         $fields = new RowManager_FieldManager();
         $fields->setEventID($this->event_id);
         $TRUE = 1;
         $fields->setIsRequired($TRUE);
         $fieldsList = $fields->getListIterator();
         $fieldsArray = $fieldsList->getDataList();
         // 		     reset($fieldsArray);	// should be only one campus assignment status (for now, later maybe not)
         // 		     foreach (array_keys($fieldsArray) as $k)
         // 		     {
         // 			     $record = current($fieldsArray);
         //
         // 			     next($fieldsArray);
         // 		     }
         $fieldValues = new RowManager_FieldValueManager();
         $fieldValues->setRegID($this->reg_id);
         $valuesList = $fieldValues->getListIterator();
         $valuesArray = $valuesList->getDataList();
         // 		     reset($regsArray);	// should be only one campus assignment status (for now, later maybe not)
         // 		     foreach (array_keys($regsArray) as $k)
         // 		     {
         // 			     $record = current($regsArray);
         //
         // 			     $assignArray[$record['campus_id'] = $record['assignmentstatus_desc']
         // 			     next($regsArray);
         // 		     }
         // ensure that the REQUIRED fields for an event all have a record for the particular registration
         if (count($valuesArray) < count($fieldsArray)) {
             $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
             $status_message = 'Some required event-specific field values were NOT set for the registration.';
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         }
         if (!isset($this->event_id) || $this->event_id == '') {
             $this->event_id = $backup_event_id;
             // should have been set earlier when retrieving reg. data...
         }
         // retrieve event deposit for later use
         $event = new RowManager_EventManager();
         $event->setEventID($this->event_id);
         $eventsList = $event->getListIterator();
         $eventsArray = $eventsList->getDataList();
         $event_deposit = -1;
         $event_basePrice = -1;
         reset($eventsArray);
         // should be only one event per event_id
         foreach (array_keys($eventsArray) as $k) {
             $record = current($eventsArray);
             $event_deposit = $record['event_deposit'];
             next($eventsArray);
         }
         if ($event_deposit == -1) {
             $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
             $status_message = 'Invalid event associated with registration.';
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         }
         // check cim_reg_cashtransaction and cim_reg_cctransaction tables to determine if event deposit has been paid
         $ccTransaction = new RowManager_CreditCardTransactionManager();
         $ccTransaction->setRegID($this->reg_id);
         $ccTransList = $ccTransaction->getListIterator();
         $ccTransArray = $ccTransList->getDataList();
         $ccAmount = 0;
         reset($ccTransArray);
         foreach (array_keys($ccTransArray) as $k) {
             $record = current($ccTransArray);
             $ccAmount += $record['cctransaction_amount'];
             next($ccTransArray);
         }
         // check cash
         $cashTransaction = new RowManager_CashTransactionManager();
         $cashTransaction->setRegID($this->reg_id);
         $cashTransList = $cashTransaction->getListIterator();
         $cashTransArray = $cashTransList->getDataList();
         $cashAmount = 0;
         reset($cashTransArray);
         foreach (array_keys($cashTransArray) as $k) {
             $record = current($cashTransArray);
             $cashAmount += $record['cashtransaction_amtPaid'];
             next($cashTransArray);
         }
         // check scholarship
         $scholarship = new RowManager_ScholarshipAssignmentManager();
         $scholarship->setRegID($this->reg_id);
         $scholarshipList = $scholarship->getListIterator();
         $scholarshipArray = $scholarshipList->getDataList();
         $scholarshipAmount = 0;
         reset($scholarshipArray);
         foreach (array_keys($scholarshipArray) as $k) {
             $record = current($scholarshipArray);
             $scholarshipAmount += $record['scholarship_amount'];
             next($scholarshipArray);
         }
         if ($ccAmount + $cashAmount + $scholarshipAmount < $event_deposit) {
             $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
             $status_message = 'The event deposit of $' . $event_deposit . ' has not been paid.';
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         }
         // check that confirmation # exists and is in proper format (check that format is 'E<event_id>R<reg_id>C<campus_id>')
         $anyNum = '[0-9]+';
         // allow any number for campus ID because person may have been assigned new campuses
         $pattern = '(E' . $this->event_id . 'R' . $this->reg_id . 'C' . $anyNum . ')';
         if (!isset($confirm_num) || preg_match($pattern, $confirm_num) < 1) {
             // if campus-id missing from confirm. # then
             // search for campus-id, since user may have created new campus assignment during process
             $pattern = '(E' . $this->event_id . 'R' . $this->reg_id . 'C)';
             if (preg_match($pattern, $confirm_num) >= 1) {
                 $campusAssigned = new RowManager_AssignmentsManager();
                 $campusAssigned->setPersonID($person_id);
                 $assignmentsList = $campusAssigned->getListIterator();
                 $assignmentsArray = $assignmentsList->getDataList();
                 $assignment = current($assignmentsArray);
                 $campusID = $assignment['campus_id'];
                 // retrieve latest campus_id assigned to registrant
                 // update confirmation # in database for the proper registration
                 $updateArray = array();
                 $updateArray['registration_id'] = $this->reg_id;
                 $updateArray['registration_confirmNum'] = $confirm_num . $campusID;
                 // append the new campus_ID
                 $regsManager = new RowManager_RegistrationManager($this->reg_id);
                 $regsManager->loadFromArray($updateArray);
                 $regsManager->updateDBTable();
             } else {
                 $this->storeRegStatus($this->reg_id, RowManager_StatusManager::INCOMPLETE);
                 $status_message = 'The confirmation number has not been properly set.';
                 return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
             }
         }
         // 			  $status = new RowManager_StatusManager();
         // 			  $status->setStatusDesc(RowManager_StatusManager::REGISTERED);
         //
         // 		     $statusList = $status->getListIterator();
         // 		     $statusArray = $statusList->getDataList();
         // 		     $status_id = -1;
         // 		     reset($statusArray);		// should be only 1 record for a particular status description
         // 		     foreach (array_keys($statusArray) as $k)
         // 		     {
         // 			     $record = current($statusArray);
         // 			     $status_id = $record['status_id'];
         //
         // 			     next($statusArray);
         // 		     }
         //
         // 		     if ($status_id == -1)
         // 		     {
         // 			     $status_message = 'The registration status could not be properly set to REGISTERED.';
         // 					return  RowManager_StatusManager::INCOMPLETE.'|'.$status_message;
         // 			  }
         //
         // 			  $updateValues = array();
         // 			  $updateValues['registration_id'] = $this->reg_id;
         // 			  $updateValues['registration_status'] = $status_id;	// mark registration as being REGISTERED
         //
         //             // Store values in RegistrationManager object
         //             $regs->loadFromArray( $updateValues );
         // //              echo "<pre>".print_r($this->formValues ,true)."</pre>";
         //
         //             // update information
         //              $regs->updateDBTable();
         $success = $this->storeRegStatus($this->reg_id, RowManager_StatusManager::REGISTERED);
         if ($success == false) {
             $status_message = 'The registration status could not be properly set to REGISTERED.';
             return RowManager_StatusManager::INCOMPLETE . '|' . $status_message;
         } else {
             $status_message = '';
             return RowManager_StatusManager::REGISTERED . '|' . $status_message;
         }
     } else {
         return RowManager_StatusManager::UNASSIGNED . '|' . $status_message;
     }
 }
 /**
  * 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 the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $year_id = "", $campus_id = "")
 {
     parent::__construct(page_ViewStudentYearInSchool::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->year_id = $year_id;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // need to filter displayed data by campus associated with campus admin
     $campusAdminSearchCondition = '';
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $campusList = $campusAdminManager->getListIterator();
             //$multiTableManager->getListIterator();
             $campusArray = $campusList->getDataList();
             $campusIDsList = "";
             // init the CSV of campus IDs associated with admin
             reset($campusArray);
             foreach (array_keys($campusArray) as $k) {
                 $record = current($campusArray);
                 $campusIDsList .= $record['campus_id'] . ',';
                 // create list of admin campuses
                 next($campusArray);
             }
             $campusIDsList = substr($campusIDsList, 0, -1);
             // remove last comma
             $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $campusIDsList = "";
                 // init the CSV of campus IDs associated with admin
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $campusIDsList .= $campusAssignObject->getCampusID() . ',';
                     // create list of admin campuses
                 }
                 $campusIDsList = substr($campusIDsList, 0, -1);
                 // remove last comma
                 $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
             }
         }
     }
     $yearManager = new RowManager_YearInSchoolManager();
     $yearManager->setSortOrder('year_id');
     $this->yearValueList = $yearManager->getListIterator();
     $this->yearValues = $this->yearValueList->getDropListArray();
     // Add value to drop-list for showing person data for people not having person_year record
     $keys = array_keys($this->yearValues);
     $this->UNASSIGNED_IDX = $keys[count($this->yearValues) - 1] + 1;
     // assumes autoincrement is active on table
     $this->yearValues[$this->UNASSIGNED_IDX] = page_ViewStudentYearInSchool::UNASSIGNED;
     // 					echo 'values = <pre>'.print_r($this->yearValues, true).'</pre>';
     // modify the year_id if necessary
     if ($this->year_id == page_ViewStudentYearInSchool::DISPLAY_ALL_ID) {
         // setting the year_id to blank will get entries from all the years
         $this->year_id = '';
     } else {
         if ($this->year_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->yearValues as $key => $value) {
                 $this->year_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->year_id == '') {
                 die("ERROR - year_id not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     // Check if regular choice made (i.e. person has some year_in_school record)
     if ($this->year_id != $this->UNASSIGNED_IDX) {
         $personYearManager = new RowManager_PersonYearManager();
         $personYearManager->setYear($this->year_id);
         // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         $dataAccessObject->addRowManager($personYearManager);
         $yearManager = new RowManager_YearInSchoolManager();
         $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         $dataAccessObject->addRowManager($yearManager, $joinPair);
         $personManager = new RowManager_PersonManager();
         $joinPair1 = new JoinPair($personManager->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($personManager, $joinPair1);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personYearManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         if ($this->year_id != '') {
             $dataAccessObject->addSearchCondition('cim_hrdb_person_year.year_id = ' . $this->year_id);
         }
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         // 	        $personYearManager = new RowManager_PersonYearManager();
         // 	        $personYearManager->setYear($this->year_id);	// SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         // 	        $dataAccessObject->addRowManager( $personYearManager );
         //
         // 	        $yearManager = new RowManager_YearInSchoolManager();
         // 	        $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         // 	        $dataAccessObject->addRowManager( $yearManager, $joinPair );
         $personManager = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($personManager);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         // get sub-query data for filtering out registrants that have already been registered for event
         $subManager = new RowManager_PersonYearManager();
         $personYearManager = new MultiTableManager();
         $personYearManager->addRowManager($subManager);
         $personYearManager->setFieldList('person_id');
         $registered_SQL = $personYearManager->createSQL();
         //          echo "<br>CREATED SQL 1 = ".$registered_SQL;
         // actually creates the sub-query ensuring that registrants listed do NOT have personyear records
         $negateSubQuery = true;
         $addSubQuery = true;
         $dataAccessObject->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery);
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     }
     /** TEST **/
     //         $values = $this->listManager->getDataList();
     //         echo 'values found = <pre>'.print_r($values,true).'</pre>';
     /** END TEST **/
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewStudentYearInSchool::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function processData
  * <pre>
  * Processes the data for this form.
  * </pre>
  * @return [void]
  */
 function processData()
 {
     // save the value of the Foriegn Key(s)
     /*[RAD_ADMINBOX_FOREIGNKEY]*/
     // store values in table manager object.
     $this->dataManager->loadFromArray($this->formValues);
     // now update the DB with the values
     if (!$this->dataManager->isLoaded()) {
         if ($this->campus_id != '') {
             $this->dataManager->createNewEntry();
             $assignManager = new RowManager_AssignmentsManager();
             // 	            $assignManager->setCampusID($this->campus_id);
             $values = array();
             $values['person_id'] = $this->dataManager->getID();
             $values['campus_id'] = $this->campus_id;
             $values['assignmentstatus_id'] = '6';
             $assignManager->loadFromArray($values);
             if (!$assignManager->isLoaded()) {
                 $assignManager->createNewEntry();
                 // associate person with the campus the viewer is viewing
             }
         }
     } else {
         $this->dataManager->updateDBTable();
     }
 }