function get_AG($template, $errorMessages)
{
    $accessGroupM = new RowManager_AccessGroupManager();
    $multilingualLabelL = new RowManager_MultilingualLabelManager();
    $join = new JoinPair($multilingualLabelL->getJoinOnFieldX('label_key'), $accessGroupM->getJoinOnFieldX('accessgroup_key'));
    $MTM = new MultiTableManager();
    $MTM->addRowManager($multilingualLabelL);
    $MTM->addRowManager($accessGroupM, $join);
    $MTM->constructSearchCondition('language_id', '=', '1', true);
    $result = $MTM->find();
    if (!isset($result)) {
        $errorMessages = 'Failed to join database to get label';
    } else {
        $result->setFirst();
        $count = 0;
        while ($resultMLM = $result->getNext($multilingualLabelL)) {
            $resultAGM = $result->getCurrent($accessGroupM);
            $agLabel[] = $resultMLM->getLabel();
            $agID[] = $resultAGM->getID();
        }
        $template->set('agLabel', $agLabel);
        $template->set('agID', $agID);
    }
    return $errorMessages;
}
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_People::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //        $this->managerInit = $managerInit;
     // $dataAccessObject = new RowManager_PersonManager();
     $dataAccessObject = new MultiTableManager();
     $personManager = new RowManager_PersonManager();
     $dataAccessObject->addRowManager($personManager);
     if ($sortBy == '') {
         $sortBy = 'person_fname';
     }
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new PersonList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_People::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the 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 this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $person_id [INTEGER] Value used to initialize the dataManager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $person_id)
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     $fieldList = FormProcessor_NewPerson::FORM_FIELDS;
     $fieldDisplayTypes = FormProcessor_NewPerson::FORM_FIELD_TYPES;
     parent::__construct($formAction, $fieldList, $fieldDisplayTypes);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->person_id = $person_id;
     $fieldsOfInterest = implode(',', $this->formFields);
     // Using Join
     $dataAccessObject = new MultiTableManager();
     $viewerManager = new RowManager_ViewerManager();
     $dataAccessObject->addRowManager($viewerManager);
     $personManager = new RowManager_PersonManager();
     $joinPair = new JoinPair($personManager->getJoinOnPersonID(), $viewerManager->getJoinOnPersonID());
     $dataAccessObject->addRowManager($personManager, $joinPair);
     $dataAccessObject->setFieldsOfInterest($fieldsOfInterest);
     $this->formValues = $dataAccessObject->getArrayOfValues();
     // Done using Join
     // figure out the important fields for the dataManager
     /*No Join used, only person manager.
             $this->dataManager = new RowManager_PersonManager( $person_id );
             $this->dataManager->setFieldsOfInterest( $fieldsOfInterest );
             $this->formValues = $this->dataManager->getArrayOfValues();
     */
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_NewPerson::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS);
 }
Beispiel #5
0
function process_Form($sqlResult, $template, $errorMessages)
{
    //get the names that are being searched
    $fName = $_REQUEST['fName'];
    $lName = $_REQUEST['lName'];
    //create the needed row managers
    $personM = new RowManager_PersonManager();
    $accessM = new RowManager_AccessManager();
    $viewerM = new RowManager_ViewerManager();
    //setup the join pair needed
    $join = new JoinPair($personM->getJoinOnFieldX('person_id'), $accessM->getJoinOnFieldX('person_id'));
    //create the multi table manager and initialize it
    $MTM = new MultiTableManager();
    $MTM->addRowManager($personM);
    $MTM->addRowManager($accessM, $join);
    //if there is a first name being searched - add that as a condition
    if ($fName != "") {
        $MTM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
        $personM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
    }
    //if there is a last name being searched - add that as a condition
    if ($lName != "") {
        $MTM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
        $personM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
    }
    //jump to a display function to show what was reteived from the person database
    //$sqlResult = $personM->find();
    //$rows = showContents($sqlResult, $personM, $personM->getFields());
    //jump to a display function to show what was reteived after joining the databases
    $sqlResult = $MTM->find();
    //$rows = showContents($sqlResult, $personM, $personM->getFields());
    $sqlResult->setFirst();
    //create a new viewer manager to keep data pure
    $viewM = new RowManager_ViewerManager();
    //loop through the results saving them to be displayed
    for ($i = 0; $i < $sqlResult->getRowCount(); $i++) {
        //get the next result and the values
        $sqlResult->getNext($personM);
        $f_name[] = $personM->getValueByFieldName('person_fname');
        $l_name[] = $personM->getValueByFieldName('person_lname');
        $person_id[] = $personM->getValueByFieldName('person_id');
        //get the current accessManager values
        $sqlResult->getCurrent($accessM);
        //create the join for access table -> viewer table and search the database for the record
        $join = new JoinPair($accessM->getJoinOnFieldX('viewer_id'), $viewerM->getJoinOnFieldX('viewer_id'));
        $MTM = new MultiTableManager();
        $MTM->addRowManager($accessM);
        $MTM->addRowManager($viewerM, $join);
        $MTM->constructSearchCondition('viewer_id', '=', $accessM->getValueByFieldName('viewer_id'), true);
        $sqlResult2 = $MTM->find();
        //add the needed information to the arrays to be displayed in the template file
        $sqlResult2->getNext($viewM);
        $viewer_id[] = $viewM->getValueByFieldName('viewer_id');
        $user_id[] = $viewM->getValueByFieldName('viewer_userID');
    }
    //check if there was any result from the initial database query, if not add an error message
    if ($sqlResult->getRowCount() < 1) {
        $errorMessages = 'Failed to join database to get label';
        $template->set('f_name', null);
    } else {
        //add the needed information to the template
        $template->set('f_name', $f_name);
        $template->set('l_name', $l_name);
        $template->set('viewer_id', $viewer_id);
        $template->set('person_id', $person_id);
        $template->set('user_id', $user_id);
    }
}
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Make a new Template object
     $path = SITE_PATH_TEMPLATES;
     // Replace $path with the following line if you want to create a
     // template tailored for this page:
     //$path = $this->pathModuleRoot.'templates/';
     // store the link values
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['add'] = $this->labels->getLabel('[Add]');
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     // store any additional link Columns
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     // echo "<pre>".print_r($this->linkValues, true)."</pre>";
     $title = $this->labels->getLabel('[Details]');
     $columnLabel = $this->labels->getLabel('[View]');
     $link = $this->linkValues['view'];
     $fieldName = 'event_id';
     $this->addLinkColumn($title, $columnLabel, $link, $fieldName);
     $REGISTERED = 2;
     //'true';
     $INCOMPLETE = 1;
     $NOT_REGISTERED = 0;
     //'false';
     /**  determine which events the user has already registered for...  **/
     $events = new RowManager_EventManager();
     $events->setOnHomePage('1');
     $events->addSearchCondition($this->countrySearchCondition);
     //             $events->setSortOrder( $this->sortBy );	// needed to sync lists
     $regs = new RowManager_RegistrationManager();
     $regs->setPersonID($this->person_id);
     $status = new RowManager_StatusManager();
     $status->setStatusDesc(RowManager_StatusManager::REGISTERED);
     $reg_events = new MultiTableManager();
     $reg_events->addRowManager($events);
     $reg_events->addRowManager($regs, new JoinPair($events->getJoinOnEventID(), $regs->getJoinOnEventID()));
     $reg_events->addRowManager($status, new JoinPair($regs->getJoinOnStatus(), $status->getJoinOnStatusID()));
     if (!isset($this->sortBy) || $this->sortBy == '') {
         $this->sortBy = 'event_id';
     }
     $reg_events->setSortOrder($this->sortBy);
     // needed to sync lists
     //             echo "reg events sql = ".$reg_events->createSQL();
     $regs_events_list = $reg_events->getListIterator();
     $regs_events_array = $regs_events_list->getDataList();
     /** determine which events the user has PARTIALLY completed registration for ***/
     $events2 = new RowManager_EventManager();
     $events2->setOnHomePage('1');
     $events2->addSearchCondition($this->countrySearchCondition);
     //             $events->setSortOrder( $this->sortBy );	// needed to sync lists
     $regs2 = new RowManager_RegistrationManager();
     $regs2->setPersonID($this->person_id);
     $status2 = new RowManager_StatusManager();
     $status2->setStatusDesc(RowManager_StatusManager::INCOMPLETE);
     $reg_events2 = new MultiTableManager();
     $reg_events2->addRowManager($events2);
     $reg_events2->addRowManager($regs2, new JoinPair($events2->getJoinOnEventID(), $regs2->getJoinOnEventID()));
     $reg_events2->addRowManager($status2, new JoinPair($regs2->getJoinOnStatus(), $status2->getJoinOnStatusID()));
     $reg_events2->setSortOrder($this->sortBy);
     // needed to sync lists
     //             echo "reg events sql = ".$reg_events->createSQL():
     $incomplete_regs_events_list = $reg_events2->getListIterator();
     $incompete_regs_events_array = $incomplete_regs_events_list->getDataList();
     //            echo '<pre>'.print_r($incompete_regs_events_array, true).'</pre>';
     // get full event-listing for mapping isRegistered to
     $allEvents = $this->listManager->getDataList();
     //
     //           echo 'reg events = <pre>'.print_r($regs_events_array,true).'</pre><br>';
     //             echo 'all events = <pre>'.print_r($allEvents, true).'</pre><br>';
     $eventName_isReg_array = array();
     reset($regs_events_array);
     reset($incompete_regs_events_array);
     reset($allEvents);
     foreach (array_keys($allEvents) as $k) {
         $record = current($allEvents);
         $currentEvent = $record['event_id'];
         $record2 = current($regs_events_array);
         $currentRegEvent = $record2['event_id'];
         $record3 = current($incompete_regs_events_array);
         $currentIncRegEvent = $record3['event_id'];
         $eventName = $record['event_name'];
         // store event in registered array if mapping found
         if ($currentEvent == $currentRegEvent) {
             $eventName_isReg_array[$eventName] = $REGISTERED;
             next($regs_events_array);
         } else {
             if ($currentEvent == $currentIncRegEvent) {
                 $eventName_isReg_array[$eventName] = $INCOMPLETE;
                 next($incompete_regs_events_array);
             } else {
                 $eventName_isReg_array[$eventName] = $NOT_REGISTERED;
             }
         }
         next($allEvents);
     }
     //             echo "events: <PRE>".print_r($eventName_isReg_array,true)."</PRE>";
     $title = $this->labels->getLabel('[RegisterAccess]');
     $columnLabels = array();
     $columnLabels[$NOT_REGISTERED] = $this->labels->getLabel('[Register]');
     $columnLabels[$INCOMPLETE] = $this->labels->getLabel('[FinishReg]');
     $columnLabels[$REGISTERED] = $this->labels->getLabel('[EditReg]');
     // formerly [CancelReg]
     $links = array();
     $links[$NOT_REGISTERED] = $this->linkValues['register'];
     $links[$INCOMPLETE] = $this->linkValues['complete'];
     $links[$REGISTERED] = $this->linkValues['edit_reg'];
     // formerly 'cancel'
     // field column names to map to link name (i.e. filter by event to determine if link name should change based on reg status)
     $fieldNames = array();
     $fieldNames[$NOT_REGISTERED] = 'event_id';
     $fieldNames[$INCOMPLETE] = 'event_id';
     $fieldNames[$REGISTERED] = 'event_id';
     //  OLD:           $this->addLinkColumn( $title, $columnLabel, $link, $fieldName,  $useAlt, $alt_label, $link_alt, $fieldAlt);
     $this->addDynamicLinkColumn($title, $columnLabels, $links, $fieldNames);
     // link an array of filters to a particular link column
     $linkColumnFilter[$title] = $eventName_isReg_array;
     //          echo '<pre>'.print_r($linkColumnFilter, true).'</pre>';
     // store the page labels
     // NOTE: use this location to update any label tags ...
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     $this->prepareTemplate($path);
     // set the filter list used to determine which events have 'register' links and which have 'cancel' links
     $this->template->set('linkColumnFilter', $linkColumnFilter);
     // store the Row Manager's XML Node Name
     $this->template->set('rowManagerXMLNodeName', RowManager_EventManager::XML_NODE_NAME);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'event_id');
     /*
      *  Set up any additional data transfer to the Template here...
      */
     $this->template->set('disableHeading', true);
     $templateName = 'siteDataList.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_HomePageEventList.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);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $year_id = "", $campus_id = "")
 {
     parent::__construct(page_ViewStudentYearInSchool::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->year_id = $year_id;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // need to filter displayed data by campus associated with campus admin
     $campusAdminSearchCondition = '';
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $campusList = $campusAdminManager->getListIterator();
             //$multiTableManager->getListIterator();
             $campusArray = $campusList->getDataList();
             $campusIDsList = "";
             // init the CSV of campus IDs associated with admin
             reset($campusArray);
             foreach (array_keys($campusArray) as $k) {
                 $record = current($campusArray);
                 $campusIDsList .= $record['campus_id'] . ',';
                 // create list of admin campuses
                 next($campusArray);
             }
             $campusIDsList = substr($campusIDsList, 0, -1);
             // remove last comma
             $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $campusIDsList = "";
                 // init the CSV of campus IDs associated with admin
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $campusIDsList .= $campusAssignObject->getCampusID() . ',';
                     // create list of admin campuses
                 }
                 $campusIDsList = substr($campusIDsList, 0, -1);
                 // remove last comma
                 $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
             }
         }
     }
     $yearManager = new RowManager_YearInSchoolManager();
     $yearManager->setSortOrder('year_id');
     $this->yearValueList = $yearManager->getListIterator();
     $this->yearValues = $this->yearValueList->getDropListArray();
     // Add value to drop-list for showing person data for people not having person_year record
     $keys = array_keys($this->yearValues);
     $this->UNASSIGNED_IDX = $keys[count($this->yearValues) - 1] + 1;
     // assumes autoincrement is active on table
     $this->yearValues[$this->UNASSIGNED_IDX] = page_ViewStudentYearInSchool::UNASSIGNED;
     // 					echo 'values = <pre>'.print_r($this->yearValues, true).'</pre>';
     // modify the year_id if necessary
     if ($this->year_id == page_ViewStudentYearInSchool::DISPLAY_ALL_ID) {
         // setting the year_id to blank will get entries from all the years
         $this->year_id = '';
     } else {
         if ($this->year_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->yearValues as $key => $value) {
                 $this->year_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->year_id == '') {
                 die("ERROR - year_id not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     // Check if regular choice made (i.e. person has some year_in_school record)
     if ($this->year_id != $this->UNASSIGNED_IDX) {
         $personYearManager = new RowManager_PersonYearManager();
         $personYearManager->setYear($this->year_id);
         // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         $dataAccessObject->addRowManager($personYearManager);
         $yearManager = new RowManager_YearInSchoolManager();
         $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         $dataAccessObject->addRowManager($yearManager, $joinPair);
         $personManager = new RowManager_PersonManager();
         $joinPair1 = new JoinPair($personManager->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($personManager, $joinPair1);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personYearManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         if ($this->year_id != '') {
             $dataAccessObject->addSearchCondition('cim_hrdb_person_year.year_id = ' . $this->year_id);
         }
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         // 	        $personYearManager = new RowManager_PersonYearManager();
         // 	        $personYearManager->setYear($this->year_id);	// SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         // 	        $dataAccessObject->addRowManager( $personYearManager );
         //
         // 	        $yearManager = new RowManager_YearInSchoolManager();
         // 	        $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         // 	        $dataAccessObject->addRowManager( $yearManager, $joinPair );
         $personManager = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($personManager);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         // get sub-query data for filtering out registrants that have already been registered for event
         $subManager = new RowManager_PersonYearManager();
         $personYearManager = new MultiTableManager();
         $personYearManager->addRowManager($subManager);
         $personYearManager->setFieldList('person_id');
         $registered_SQL = $personYearManager->createSQL();
         //          echo "<br>CREATED SQL 1 = ".$registered_SQL;
         // actually creates the sub-query ensuring that registrants listed do NOT have personyear records
         $negateSubQuery = true;
         $addSubQuery = true;
         $dataAccessObject->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery);
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     }
     /** TEST **/
     //         $values = $this->listManager->getDataList();
     //         echo 'values found = <pre>'.print_r($values,true).'</pre>';
     /** END TEST **/
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewStudentYearInSchool::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 protected function 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;
     }
 }
 protected function setPersonID($regID)
 {
     // determine if parameter has been set
     if (isset($regID)) {
         // get registration ID for the rest of the reg. process
         $regs = new RowManager_RegistrationManager();
         $regs->setRegID($regID);
         $people = new RowManager_PersonManager();
         $personRegs = new MultiTableManager();
         $personRegs->addRowManager($people);
         $personRegs->addRowManager($regs, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID()));
         $personList = $personRegs->getListIterator();
         $personArray = $personList->getDataList();
         //        echo "<pre>".print_r($personArray,true)."</pre>";
         reset($personArray);
         foreach (array_keys($personArray) as $k) {
             $person = current($personArray);
             $this->person_id = $person['person_id'];
             // NOTE: should only be one person per registration (ENFORCE??)
             $this->confirmNum = $person['registration_confirmNum'];
             next($personArray);
         }
     }
 }
 protected function createRegistrationRecord($eventID, $personID, &$regs)
 {
     if ($personID != -1 && $eventID != -1) {
         // 	        $regs = new RowManager_RegistrationManager();
         // get status id for INITIAL_REG_STATUS
         $regStatus = new RowManager_StatusManager();
         $regStatus->setStatusDesc(FormProcessor_Register::INITIAL_REG_STATUS);
         $regStatusList = $regStatus->getListIterator();
         $regStatusArray = $regStatusList->getDataList();
         $statusID = 0;
         reset($regStatusArray);
         foreach (array_keys($regStatusArray) as $k) {
             $status = current($regStatusArray);
             $statusID = $status['status_id'];
             // NOTE: should only be one reg. per person per event (ENFORCE??)
             next($regStatusArray);
         }
         // get the MAX(registration_id)... need to determine what insertion registration ID will be (used in confirmNum)
         $allRegs = new MultiTableManager();
         $allRegs->addRowManager($regs);
         $allRegs->setFunctionCall('MAX', 'registration_id');
         $allRegs->ignoreFields();
         // only leave MAX(registration_id) in values to be returned
         $allRegsList = $allRegs->getListIterator();
         $allRegsArray = $allRegsList->getDataList();
         $maxID = -1;
         reset($allRegsArray);
         foreach (array_keys($allRegsArray) as $k) {
             $regRecord = current($allRegsArray);
             $maxID = $regRecord['MAX(registration_id)'];
             if ($maxID > -1) {
                 break;
                 // get out of the loop once MAX is found
             }
             next($allRegsArray);
         }
         // compile values needed for new registration record
         $regValues = array();
         $nextRegID = $maxID + 1;
         $regValues['event_id'] = $eventID;
         // check if a new person record needs to be created
         // 				if ($this->person_id == -1)
         // 				{
         // 					$this->person_id = $this->getNextPersonID();	// assumes processData() will properly use this value for insertion
         // 				}
         $regValues['person_id'] = $personID;
         $timestamp = strtotime("now");
         $date = date('Y-m-d H:i:s', $timestamp);
         // == NOW() : to bad I could pass that as non-string...
         $regValues['registration_date'] = $date;
         // set date-time to current date-time
         $regValues['registration_confirmNum'] = 'E' . $eventID . 'R' . $nextRegID . 'AIA';
         $regValues['registration_status'] = $statusID;
         $this->confirmNum = $regValues['registration_confirmNum'];
         // TODO: change means of assigning to global
         // store values in table manager object.
         $regs->loadFromArray($regValues);
         // set primary key to use for update (if maxID found)
         if ($maxID > -1) {
             $regValues['registration_id'] = $nextRegID;
             $regs->setRegID($regValues['registration_id']);
         }
         // now update the DB with the values
         if (!$regs->isLoaded()) {
             $regs->createNewEntry(true);
             // allow primary key to be set (in case auto_increment is off)
             return $nextRegID;
         } else {
             return -1;
         }
         // TODO: figure out how to show error if no registration made, or updated (IF it is even possible now...)
     }
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     $regionJumpLinkSelectedValue = $this->linkValues['regionJumpLink'] . $this->region_id;
     $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'] . $this->semester_id;
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     $this->template->set('regionJumpLinkSelectedValue', $regionJumpLinkSelectedValue);
     $this->template->set('semesterJumpLinkSelectedValue', $semesterJumpLinkSelectedValue);
     // changed by RM on June 4, 2009 to reflect new reporting guidelines
     // $fieldsOfInterest = "weeklyReport_1on1SpConv,weeklyReport_1on1SpConvStd,weeklyReport_1on1GosPres,weeklyReport_1on1GosPresStd,weeklyReport_1on1HsPres,weeklyReport_1on1HsPresStd,weeklyReport_7upCompleted,weeklyReport_7upCompletedStd,weeklyReport_cjVideo,weeklyReport_mda,weeklyReport_otherEVMats,weeklyReport_rlk,weeklyReport_siq";
     $fieldsOfInterest = "weeklyReport_1on1SpConv,weeklyReport_1on1SpConvStd,weeklyReport_1on1GosPres,weeklyReport_1on1GosPresStd,weeklyReport_1on1HsPres";
     $fieldsArray = explode(",", $fieldsOfInterest);
     // changed by RM on June 4, 2009 to reflect new reporting guidelines, we are no longer collecting these measurements
     // $semesterReportFields = 'semesterreport_avgPrayer,semesterreport_avgWklyMtg,semesterreport_numStaffChall,semesterreport_numInternChall,semesterreport_numFrosh,semesterreport_numStaffDG,semesterreport_numInStaffDG,semesterreport_numStudentDG,semesterreport_numInStudentDG,semesterreport_numSpMultStaffDG,semesterreport_numSpMultStdDG';
     $semesterReportFields = '';
     $semesterReportFieldArray = explode(",", $semesterReportFields);
     // other 'weekly campus stats', based on exposure type
     /*
     // no longer need the exposure type fields of interest - RM June 4, 2009
             $exposureFieldsOfInterest = "";
             $exposureFieldsArray = array();
             $exposureTypePrefix = "expType";
             $isFirst = true;
             $exposureTypeManager = new RowManager_ExposureTypeManager();
             $exIt = $exposureTypeManager->getListIterator();
             $exIt->setFirst();
             while( $exIt->moveNext() )
             {
                 $anEx = $exIt->getCurrent( new RowManager_ExposureTypeManager() );
                 $typeID = $anEx->getID();
                 $fieldName = $exposureTypePrefix.$typeID;
                 $exposureFieldsArray[$typeID] = $fieldName;
                 if ( !$isFirst )
                 {
                     $exposureFieldsOfInterest .= ',';
                 }
                 $exposureFieldsOfInterest .= $fieldName;
                 $isFirst = false;
             } // while
     */
     // removed concatentation of $semesterReportFields and $exposureFieldsOfInterest - June 4, 2009 by RM
     // $fieldsOfInterest = 'prcTotal,'.$fieldsOfInterest . ',' . $semesterReportFields . ','. $exposureFieldsOfInterest;
     $fieldsOfInterest = 'prcTotal,' . $fieldsOfInterest;
     // get all the campuses for the given region
     $campusManager = new RowManager_CampusManager();
     $campusManager->setRegionID($this->region_id);
     $campusListIt = $campusManager->getListIterator();
     $campusInfoArray = array();
     $campusListIt->setFirst();
     while ($campusListIt->moveNext()) {
         $sumArray = array();
         foreach ($fieldsArray as $key => $fieldName) {
             $sumArray[$fieldName] = 0;
         }
         $campusObj = $campusListIt->getCurrent(new RowManager_CampusManager());
         $campusID = $campusObj->getID();
         $indCampusInfo = new IndCampusSemesterInfo();
         $indCampusInfo->campusID = $campusID;
         $indCampusInfo->shortName = $campusObj->getShortDesc();
         // check if an entry exists in the table for
         $weeklyReport = new RowManager_WeeklyReportManager();
         $weeklyReport->setCampusID($campusID);
         $weekManager = new RowManager_WeekManager();
         $weekManager->setSemesterID($this->semester_id);
         $multiTableManager = new MultiTableManager();
         $multiTableManager->addRowManager($weeklyReport);
         $multiTableManager->addRowManager($weekManager, new JoinPair($weeklyReport->getJoinOnWeekID(), $weekManager->getJoinOnWeekID()));
         $listIterator = $multiTableManager->getListIterator();
         $listIterator->setFirst();
         $dataArray = array();
         while ($listIterator->moveNext()) {
             $aWklyReport = $listIterator->getCurrent(new RowManager_WeeklyReportManager());
             $dataArray = $aWklyReport->getArrayOfValues();
             $this->combineValues($sumArray, $dataArray);
         }
         // $indCampusInfo->dataArray = array('weeklyReport_1on1SpConv'=>7,'weeklyReport_1on1SpConvStd'=>21);
         $indCampusInfo->dataArray = $sumArray;
         // get semster stats
         $semesterCampusReport = new RowManager_SemesterReportManager($this->semester_id, $campusID);
         $campusDataArray = $semesterCampusReport->getArrayOfValues();
         if (count($campusDataArray) <= 0) {
             // no data
             // echo 'no data<br/>';
             foreach ($semesterReportFieldArray as $key => $semFieldName) {
                 // put zeros into the array
                 $campusDataArray[$semFieldName] = 0;
             }
         }
         // echo '<pre>'.print_r($campusDataArray, true).'</pre>';
         // combine personal ministry totals array with other semester stats
         $indCampusInfo->dataArray = array_merge($indCampusInfo->dataArray, $campusDataArray);
         // add the 'campus weekly stats'
         $exposureTypeManager = new RowManager_ExposureTypeManager();
         $exIt = $exposureTypeManager->getListIterator();
         $exIt->setFirst();
         while ($exIt->moveNext()) {
             $anEx = $exIt->getCurrent(new RowManager_ExposureTypeManager());
             // echo $anEx->getLabel().'->'.$anEx->getID().'<br/>';
             $typeID = $anEx->getID();
             $sumThisType = 0;
             // get the sum of all the exposures of this type, this semester
             $moreManager = new RowManager_MoreStatsManager();
             $moreManager->setCampusID($campusID);
             $moreManager->setExposureTypeID($typeID);
             $wkManager = new RowManager_WeekManager();
             $wkManager->setSemesterID($this->semester_id);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($moreManager);
             $multiTableManager->addRowManager($wkManager, new JoinPair($moreManager->getJoinOnWeekID(), $wkManager->getJoinOnWeekID()));
             $listIterator = $multiTableManager->getListIterator();
             $listIterator->setFirst();
             while ($listIterator->moveNext()) {
                 $moreStatsObj = $listIterator->getCurrent(new RowManager_MoreStatsManager());
                 $sumThisType += $moreStatsObj->getNumExposures();
             }
             // while
             // echo 'campusID['.$campusID.'] semesterID['.$this->semester_id.'] typeID['.$typeID.'] total['.$sumThisType.']<br/>';
             $indCampusInfo->dataArray[$exposureFieldsArray[$typeID]] = $sumThisType;
         }
         // while
         // add the number of indicated decisions
         $prcManager = new RowManager_PRCManager();
         $prcManager->setSemester($this->semester_id);
         $prcManager->setCampus($campusID);
         $prcList = $prcManager->getListIterator();
         $numPRC = $prcList->getNumRows();
         // echo $numPRC.'<br/>';
         $indCampusInfo->dataArray['prcTotal'] = $numPRC;
         $campusInfoArray[] = $indCampusInfo;
     }
     $this->template->set('campusInfoArray', $campusInfoArray);
     $this->template->set('fieldsOfInterest', $fieldsOfInterest);
     $campusSummaryJumpLink = $this->linkValues['campusSummaryJumpLink'];
     $campusSummaryJumpLink = str_replace('SSS', $this->semester_id, $campusSummaryJumpLink);
     // in case where semester was not provided (usual case)
     // look up the year associated with this semester
     $semObj = new RowManager_SemesterManager($this->semester_id);
     $year_id = $semObj->getYearID();
     $campusSummaryJumpLink = str_replace('YYY', $year_id, $campusSummaryJumpLink);
     // in case where semester was not provided (usual case)
     /*$personalMinLink = $this->linkValues['campusPersonalJumpLink'];
             $personalMinLink = str_replace( 'SSS', $this->semester_id, $personalMinLink ); // in case where semester was not provided (usual case)
             
             $campusWideLink =  $this->linkValues['campusWideJumpLink'];
             $campusWideLink =  str_replace( 'SSS', $this->semester_id, $campusWideLink ); // in case where semester was not provided (usual case)
             
             $indicatedDecLink =  $this->linkValues['indicatedDecLink'];
             $indicatedDecLink =  str_replace( 'SSS', $this->semester_id, $indicatedDecLink ); // in case where semester was not provided (usual case)
     
             $this->template->set('linksArray', array('[personalMin]'=>$personalMinLink, '[campusWideMin]'=>$campusWideLink, '[decLink]'=>$indicatedDecLink ) );*/
     $this->template->set('linksArray', array('[campusSummaryJumpLink]' => $campusSummaryJumpLink));
     // semester list
     $jumpLink = $this->linkValues['semesterJumpLink'];
     $semesterArray = array();
     $semesterManager = new RowManager_SemesterManager();
     $semesterListIterator = $semesterManager->getListIterator();
     $semesterListIterator->setFirst();
     while ($semesterListIterator->moveNext()) {
         $semesterObject = $semesterListIterator->getCurrent(new RowManager_SemesterManager());
         $semesterArray[$jumpLink . $semesterObject->getID()] = $semesterObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_semester_id', $semesterArray);
     // region list
     $jumpLink = $this->linkValues['regionJumpLink'];
     $regionManager = new RowManager_RegionManager();
     $regionListIt = new ListIterator($regionManager);
     $regionArray = $regionListIt->getDropListArray(null, $jumpLink);
     // echo '<pre>'.print_r( $regionArray, true ).'</pre>';
     $this->template->set('list_region_id', $regionArray);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_RegionalSemesterReport.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
 protected function getPersonEmailfromViewerID()
 {
     $personEmailInfo = new MultiTableManager();
     $personInfo = new RowManager_PersonManager();
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $personEmailInfo->addRowManager($personInfo);
     $personEmailInfo->addRowManager($accessPriv, new JoinPair($personInfo->getJoinOnPersonID(), $accessPriv->getJoinOnPersonID()));
     $personEmailList = $personEmailInfo->getListIterator();
     $personEmailArray = $personEmailList->getDataList();
     $personID = '';
     reset($personEmailArray);
     foreach (array_keys($personEmailArray) as $k) {
         $record = current($personEmailArray);
         $personID = $record['person_id'];
         // can only be 1 person_id per viewer_id
         $personEmail = $record['person_email'];
         next($personEmailArray);
     }
     return $personEmail;
 }
 /**
  * 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
 }
Beispiel #15
0
 /**
  * function __construct
  * <pre>
  * Initialize the Class ...
  * </pre>
  * @param $sortBy [STRING] the field name to sort list by
  * @return [void]
  */
 function __construct($requireRegion = false, $getOnlyNS = false, $includeChildren = false, $includeAlumni = false, $sortBy = '', $excludeSpouse = false)
 {
     $this->requireRegion = $requireRegion;
     $multiTableManager = new MultiTableManager();
     // ----- STEP ONE: Deal with the ren table
     $renManager = new RowManager_HrdbRenManager();
     /*        if( $getOnlyNS )
             {
                 $renManager->setEmployeeStatus('NS');
             }
     */
     $multiTableManager->addRowManager($renManager);
     if ($getOnlyNS) {
         // we also need to
         $condition = $multiTableManager->constructSearchCondition($renManager->getFieldEmployeeStatus(), OP_EQUAL, 'NS');
         $condition .= ' OR ';
         $condition .= $multiTableManager->constructSearchCondition($renManager->getFieldEmployeeStatus(), OP_EQUAL, 'ANS');
         $multiTableManager->addSearchCondition($condition);
     }
     if (!$includeChildren) {
         $multiTableManager->constructSearchCondition($renManager->getFieldIdentifierFamilyPosition(), OP_NOT_EQUAL, "Child", true);
     }
     if ($excludeSpouse) {
         $multiTableManager->constructSearchCondition($renManager->getFieldIdentifierFamilyPosition(), OP_NOT_EQUAL, 'Spouse', true);
     }
     // STEP ONE COMPLETE
     // ----- STEP TWO: Join with the family table
     $familyManager = new RowManager_FamilyManager();
     if (!$includeAlumni) {
         // we want only those who are not alumni
         $familyManager->setAlumni(false);
     }
     $multiTableManager->addRowManager($familyManager, new JoinPair($renManager->getJoinOnFamilyID(), $familyManager->getJoinOnFamilyID()));
     // STEP TWO COMPLETE
     // ------ STEP THREE: Check if region is needed
     if ($requireRegion) {
         // assignment
         $assManager = new RowManager_HrdbAssignmentManager();
         $multiTableManager->addRowManager($assManager, new JoinPair($renManager->getJoinOnAssignmentID(), $assManager->getJoinOnAssignmentID()));
         // city
         $cityManager = new RowManager_HrdbCityManager();
         $multiTableManager->addRowManager($cityManager, new JoinPair($assManager->getJoinOnCityID(), $cityManager->getJoinOnCityID()));
         // province
         $provinceManager = new RowManager_ProvinceManager();
         $multiTableManager->addRowManager($provinceManager, new JoinPair($cityManager->getJoinOnProvinceID(), $provinceManager->getJoinOnProvinceID()));
         // region
         $regionManager = new RowManager_HrdbRegionManager();
         $multiTableManager->addRowManager($regionManager, new JoinPair($provinceManager->getJoinOnRegionID(), $regionManager->getJoinOnRegionID()));
     }
     // STEP THREE COMPLETE
     $multiTableManager->setSortOrder($sortBy);
     parent::__construct($multiTableManager, 'RowManager_HrdbRenManager');
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $campus_id = "")
 {
     parent::__construct(page_PeoplebyCampuses::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($campusAdminManager);
             $multiTableManager->setSortOrder('campus_desc');
             $campusManager = new RowManager_CampusManager();
             $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusAdminManager->getJoinOnCampusID()));
             $this->campusList = $multiTableManager->getListIterator();
             $this->accessibleCampuses = array();
             $this->campusList->setFirst();
             while ($this->campusList->moveNext()) {
                 $campusAdminObject = $this->campusList->getCurrent(new RowManager_CampusAdminManager());
                 $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                 $this->accessibleCampuses[$campusAdminObject->getCampusID()] = $campusObject->getLabel();
             }
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $this->accessibleCampuses = array();
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $this->accessibleCampuses[$campusAssignObject->getCampusID()] = $campusObject->getLabel();
                 }
             } else {
                 $campusManager = new RowManager_CampusManager();
                 $campusManager->setSortOrder('campus_desc');
                 $this->campusList = $campusManager->getListIterator();
                 $this->accessibleCampuses = $this->campusList->getDropListArray();
             }
         }
     }
     // modify the campus_id if necessary
     if ($this->campus_id == page_PeoplebyCampuses::DISPLAY_ALL_ID) {
         // setting the campus id to blank will get entries from all the campuses
         $this->campus_id = '';
     } else {
         if ($this->campus_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->accessibleCampuses as $key => $value) {
                 $this->campus_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->campus_id == '') {
                 die("ERROR - campusID not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     $assignmentsManager = new RowManager_AssignmentsManager();
     $assignmentsManager->setCampusID($this->campus_id);
     $dataAccessObject->addRowManager($assignmentsManager);
     $personManager = new RowManager_PersonManager();
     $joinPair = new JoinPair($personManager->getJoinOnPersonID(), $assignmentsManager->getJoinOnPersonID());
     $dataAccessObject->addRowManager($personManager, $joinPair);
     $this->accessManager = new RowManager_AccessManager();
     $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $this->accessManager->getJoinOnPersonID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->accessManager, $joinPair2);
     $this->viewerManager = new RowManager_UserManager();
     $joinPair3 = new JoinPair($this->accessManager->getJoinOnViewerID(), $this->viewerManager->getJoinOnViewerID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->viewerManager, $joinPair3);
     if ($sortBy == '') {
         $sortBy = 'person_lname';
     }
     $dataAccessObject->setSortOrder($sortBy);
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_PeoplebyCampuses::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // 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->campusaccess_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
     //
     // NOTE: Hobbe, here are the original two lines that I moved to below
     //
     // $xmlNodeName = RowManager_EventAdminCampusAssignmentManager::XML_NODE_NAME;
     // $this->template->set( 'rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'campusaccess_id');
     // Russ' Debugging Methodoloy
     // 1. Try and create a multi-table manager that returns the
     // result set I want and put it into and array.  Then figure
     // out why that is not making it through to the template.
     //
     // Result: Hobbe, indeed you were creating the multi-table
     // manager correctly (I just renamed the one row manager),
     // otherwise your code was fine.
     //
     // 2. Ok, try and figure out why the template doesn't like
     // XML it is getting.
     //
     // a. first I check another example (FormProcessor_AddSuperAdmin)
     // of where an adminbox type template is generated.  Yes, it
     // appears we are sending the xml properly
     //
     // b. i notice the call to ->set('primaryKeyFieldName', ... )
     // in the example I'm checking, that too seems to be okay
     //
     // c. I notice the xmlNodeName parameter being set in the
     // templates, i realize that we are not setting this properly
     // and refactor the code a little to get the xmlNodeName from
     // the multitablemanager instead.
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $campusAdminManager = new RowManager_EventAdminCampusAssignmentManager();
     //*** ADDED JOIN TO FILTER BY EVENT ***/
     $eventAdminManager = new RowManager_EventAdminAssignmentManager();
     // echo "The eventID is [".$this->event_id."]<br/>";
     $eventAdminManager->setEventID($this->event_id);
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($campusAdminManager);
     $multiTableManager->addRowManager($eventAdminManager, new JoinPair($eventAdminManager->getJoinOnEventAdminID(), $campusAdminManager->getJoinOnEventAdminID()));
     // code to check the result set in the multi-table manager
     // $i = 0;
     // $listIt = $multiTableManager->getListIterator();
     // $listIt->setFirst();
     // while( $listIt->moveNext() )
     // {
     //    echo "ith [".$i."] element";
     //    $i++;
     // }
     // end multi-table manager check
     // $this->dataList = $multiTableManager->getListIterator();
     // echo "<pre>List: ".print_r($this->dataList,true)."</pre>";
     //*** END ADD ***/
     $this->dataList = $multiTableManager->getListIterator();
     // Hobbe, I added/moved these two lines and now it works!
     // It has to do with how the template understands the
     // XML that it is passed
     $xmlNodeName = $this->dataList->getRowManagerXMLNodeName();
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     $eventAdmin = new RowManager_EventAdminAssignmentManager();
     $eventAdmin->setEventID($this->event_id);
     $viewer = new RowManager_ViewerManager();
     $multiTableManager2 = new MultiTableManager();
     $multiTableManager2->addRowManager($eventAdmin);
     $multiTableManager2->addRowManager($viewer, new JoinPair($eventAdmin->getJoinOnViewerID(), $viewer->getJoinOnViewerID()));
     //      $multiTableManager2->constructSearchCondition( 'event_id', '=', $this->event_id, true );
     $multiTableManager2->setSortOrder('viewer_userID');
     $multiTableManager2->setLabelTemplate('viewer_userID', '[viewer_userID]');
     $listIterator = $multiTableManager2->getListIterator();
     // code to check the result set in the multi-table manager
     /*        echo "<pre>List: ".print_r($listIterator,true)."</pre>";
                    
              $i = 0;
              $listIt = $multiTableManager2->getListIterator();
              $listIt->setFirst();
              while( $listIt->moveNext() )
              {
                 echo "ith [".$i."] element";
                 $i++;
              }
      */
     // end multi-table manager check
     //        echo print_r($listIterator,true);
     /*
             $viewer = new RowManager_ViewerManager();
             $viewer->setSortOrder( 'viewer_userID' );
             $viewerList = new ListIterator($viewer);	
             $viewerArray = $viewerList->getDropListArray();
     */
     $viewerArray = $listIterator->getDropListArray();
     //$listIterator
     $this->template->set('list_eventadmin_id', $viewerArray);
     //        echo print_r($viewerArray,true);
     $campus = new RowManager_CampusManager();
     //       $campus->setEventID( $this->event_id);
     $campus->setSortOrder('campus_id');
     $campusList = new ListIterator($campus);
     $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_AddCampusAdmin.php';
     return $this->template->fetch($templateName);
 }
 protected function getFieldValuesArray($scopeRefList, $freqID = '', $measID = '')
 {
     $statvalues = new RowManager_StatValueManager();
     $statvalues->setSortByStatID();
     $stats = new RowManager_StatisticManager();
     /** TODO
      * 	scopeID == ''  means we either don't proceed or assume all possible scopes
      *	   scopeRefID == '' can be ignored if the prev is true, otherwise could assume all values for given scope (i.e ministry, division, etc)
      *		freqID == '' means we don't proceed since we need to interpret frequency value properly
      *		measID == '' means we don't proceed since, for instance, Personal Ministry <> Team Ministry (or can we have stats count for both?)
      **/
     $fieldInfo = new MultiTableManager();
     $fieldInfo->addRowManager($statvalues);
     $fieldInfo->addRowManager($stats, new JoinPair($statvalues->getJoinOnStatID(), $stats->getJoinOnStatID()));
     // filter the statistic fields shown using the parameters
     $searchConditions = '';
     if (isset($scopeRefList)) {
         reset($scopeRefList);
         foreach (array_keys($scopeRefList) as $k) {
             $scopeID = key($scopeRefList);
             $scopeRefID = current($scopeRefList);
             $searchConditions .= '(p2c_stats_statistic.scope_id = ' . $scopeID;
             $searchConditions .= ' AND p2c_stats_statistic.scope_ref_id = ' . $scopeRefID . ')';
             $searchConditions .= ' OR ';
             next($scopeRefList);
         }
         $searchConditions = substr($searchConditions, 0, -4);
         // remove last OR
         $fieldInfo->addSearchCondition($searchConditions);
     }
     if ($freqID != '') {
         $fieldInfo->addSearchCondition('p2c_stats_statistic.freq_id = ' . $freqID);
     }
     if ($measID != '') {
         $fieldInfo->addSearchCondition('p2c_stats_statistic.meas_id = ' . $measID);
     }
     $valuesIterator = $fieldInfo->getListIterator();
     $valuesArray = $valuesIterator->getDataList();
     //        echo "field values:<br><pre>".print_r($valuesArray,true)."</pre>";
     // since each field value is located in a DB row the result array has several arrays - one per field value
     // need to extract each field value and store it as a non-array record in a result array
     $fieldValues = array();
     $record = array();
     $idx = 0;
     reset($valuesArray);
     foreach (array_keys($valuesArray) as $k) {
         $record = current($valuesArray);
         /*				if ($isIndexedByValueID == true)
         				{
         					$fieldValues[$record['fieldvalues_id']] = $record['fieldvalues_value'];
         				}
         				else
         				{		*/
         $fieldValues['form_field' . $idx] = $record['statvalues_value'];
         //$fieldValues['form_field'.$idx+1] = $record['freqvalue_id'];
         //				}
         // store mapping associating form field label with fieldvalues_id
         $this->formFieldToValueIDmapper['form_field' . $idx] = $record['statvalues_id'];
         //$this->formFieldToValueIDmapper['form_field'.++$idx] = $record['statvalues_id'];
         next($valuesArray);
         $idx++;
     }
     return $fieldValues;
 }
 /**
  * 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);
 }
 protected function getNextPersonID()
 {
     // get the MAX(person_id)... need to determine what insertion person ID will be (used to create new registration record)
     $person = new RowManager_PersonManager();
     $persons = new MultiTableManager();
     $persons->addRowManager($person);
     $persons->setFunctionCall('MAX', 'person_id');
     $persons->ignoreFields();
     // only leave MAX(person_id) in values to be returned
     $personsList = $persons->getListIterator();
     $personsArray = $personsList->getDataList();
     $maxID = -1;
     reset($personsArray);
     foreach (array_keys($personsArray) as $k) {
         $personRecord = current($personsArray);
         $maxID = $personRecord['MAX(person_id)'];
         if ($maxID > -1) {
             break;
             // get out of the loop once MAX is found
         }
         next($personsArray);
     }
     return $maxID + 1;
 }
Beispiel #21
0
 private function loadFieldValuesForm(&$form)
 {
     $fields = new RowManager_FieldManager();
     $fieldTypes = new RowManager_FieldTypeManager();
     $fieldValues = new RowManager_FieldValueManager();
     $fieldValues->setRegID($this->REG_ID);
     $formFieldValues = new MultiTableManager();
     $formFieldValues->addRowManager($fields);
     $formFieldValues->addRowManager($fieldTypes, new JoinPair($fields->getJoinOnFieldTypeID(), $fieldTypes->getJoinOnFieldTypeID()));
     $formFieldValues->addRowManager($fieldValues, new JoinPair($fields->getJoinOnFieldID(), $fieldValues->getJoinOnFieldID()));
     $formFieldValues->setSortOrder('fields_priority');
     $formFieldValuesList = $formFieldValues->getListIterator();
     $formFieldValuesArray = $formFieldValuesList->getDataList();
     $formFieldLabels = array();
     $formData = array();
     $fieldInfo = '';
     //		$isFirst = true;
     $fieldValue = '';
     reset($formFieldValuesArray);
     // (below) store registration-specific form values for event-specific fields
     foreach (array_keys($formFieldValuesArray) as $k) {
         $row = current($formFieldValuesArray);
         //			$field_value = $row['fieldvalues_value'];
         $fieldName = 'fields_id' . $row['fields_id'];
         $fieldInfo .= $fieldName . '|' . $row['fieldtypes_desc'] . '|' . $row['datatypes_id'] . '|' . $row['fields_reqd'] . '|' . $row['fields_invalid'] . '';
         $formFieldLabels[$fieldName] = $row['fields_desc'];
         $fieldValue = $row['fieldvalues_value'];
         $formData[$fieldName] = $fieldValue;
         $fieldInfo .= ',';
         next($formFieldValuesArray);
     }
     $fieldInfo = substr($fieldInfo, 0, -1);
     // remove final ','
     // set data in the form to be displayed
     $form->setFields($fieldInfo);
     $form->setFormData($formData);
     $form->setLabels($formFieldLabels);
     $form->setButtonText('Update');
     // setup form action based on AppController standards
     $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID);
     //[RAD_CALLBACK_PARAMS]
     $formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONFIELDVALUESFORM, $this->sortBy, $parameters);
     $form->setFormAction($formAction);
     return;
 }
 /**
  * function getListAccountPriviledgeAccess
  * <pre>
  * Returns a ListIterator for the list of accounts this viewer has access
  * to modify.
  * </pre>
  * @param $sortBy [STRING] the name of the field to sort by (can be a
  * comma seperated list).
  * @return [OBJECT]
  */
 function getListAccountPriviledgeAccess($sortBy)
 {
     $multiTable = new MultiTableManager();
     $genViewer = new RowManager_ViewerManager();
     $joinFieldA = $genViewer->getJoinOnViewerID();
     // if the current viewer is limited to the Group Access scope then
     // filter list based on current group.
     if ($this->hasGroupPriv()) {
         $viewerMgr = $this->getViewerManager();
         $genViewer->setAccountGroupID($viewerMgr->getAccountGroupID());
     }
     $multiTable->addRowManager($genViewer);
     $accessManager = new RowManager_AccountAdminAccessManager();
     $joinFieldB = $accessManager->getJoinOnViewerID();
     $joinPair = new JoinPair($joinFieldA, $joinFieldB);
     $multiTable->addRowManager($accessManager, $joinPair);
     $multiTable->constructSearchCondition('accountadminaccess_privilege', '<=', $this->getAccessPrivilege(), true);
     return $multiTable->getListIterator($sortBy);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Make a new Template object
     //$this->pathModuleRoot.'templates/';
     // Replace $path with the following line if you want to create a
     // template tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // store the link values
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['add'] = $this->labels->getLabel('[Add]');
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     //         $adminLink = $this->linkValues[ 'adminHome' ];
     //         $this->template->set('adminLink', $adminLink );
     // get pricing info
     // get base price for event participation
     $event = new RowManager_EventManager($this->event_id);
     $eventBasePrice = $event->getEventBasePrice();
     // get price rules for specific event
     $priceRules = new RowManager_PriceRuleManager();
     $priceRules->setEventID($this->event_id);
     $ruleManager = $priceRules->getListIterator();
     $priceRulesArray = $ruleManager->getDataList();
     //	echo "<pre>".print_r($priceRulesArray,true)."</pre>";
     // array storing the rules applied to a particular registrant
     $rulesApplied = array();
     $priceGetter = new FinancialTools();
     $basePriceForThisGuy = $priceGetter->getBasePriceForRegistrant($this->reg_id, $this->event_id, $this->campus_id, $eventBasePrice, $priceRulesArray, $rulesApplied);
     // get Personal Info
     $registration = new RowManager_RegistrationManager();
     $registration->setRegID($this->reg_id);
     $person = new RowManager_PersonManager();
     $assignment = new RowManager_AssignmentsManager();
     // assigns campus to person
     $campus = new RowManager_CampusManager();
     //   $campus->setCampusID($this->campus_id);
     $personalInfo = new MultiTableManager();
     $personalInfo->addRowManager($person);
     $personalInfo->addRowManager($assignment, new JoinPair($person->getJoinOnPersonID(), $assignment->getJoinOnPersonID()));
     $personalInfo->addRowManager($campus, new JoinPair($campus->getJoinOnCampusID(), $assignment->getJoinOnCampusID()));
     $personalInfo->addRowManager($registration, new JoinPair($registration->getJoinOnPersonID(), $person->getJoinOnPersonID()));
     $this->listManager = $personalInfo->getListIterator();
     $personInfoArray = $this->listManager->getDataList();
     //         echo "<pre>".print_r($this->listManager,true)."</pre>";
     //        echo "<pre>".print_r($personInfoArray,true)."</pre>";
     // cycle through registrations and store balance owing for each
     $this->owingArray = array();
     $priceGetter = new FinancialTools();
     reset($personInfoArray);
     foreach (array_keys($personInfoArray) as $k) {
         $personData = current($personInfoArray);
         $this->person_id = $personData['person_id'];
         $this->person_info['person_fname'] = '';
         $this->person_info['person_fname'] = $personData['person_fname'];
         $this->person_info['person_lname'] = '';
         $this->person_info['person_lname'] = $personData['person_lname'];
         $this->person_info['campus_desc'] = '';
         $this->person_info['campus_desc'] = $personData['campus_desc'];
         $this->person_info['person_email'] = '';
         $this->person_info['person_email'] = $personData['person_email'];
         $this->person_info['gender_id'] = '';
         $this->person_info['gender_id'] = $personData['gender_id'];
         $this->person_info['person_local_addr'] = '';
         $this->person_info['person_local_addr'] = $personData['person_local_addr'];
         $this->person_info['person_local_city'] = '';
         $this->person_info['person_local_city'] = $personData['person_local_city'];
         $this->person_info['person_local_province_id'] = '';
         $this->person_info['person_local_province_id'] = $personData['person_local_province_id'];
         $this->person_info['person_local_pc'] = '';
         $this->person_info['person_local_pc'] = $personData['person_local_pc'];
         $this->person_info['person_local_phone'] = '';
         $this->person_info['person_local_phone'] = $personData['person_local_phone'];
         $this->person_info['person_addr'] = '';
         $this->person_info['person_addr'] = $personData['person_addr'];
         $this->person_info['person_city'] = '';
         $this->person_info['person_city'] = $personData['person_city'];
         $this->person_info['province_id'] = '';
         $this->person_info['province_id'] = $personData['province_id'];
         $this->person_info['person_pc'] = '';
         $this->person_info['person_pc'] = $personData['person_pc'];
         $this->person_info['person_phone'] = '';
         $this->person_info['person_phone'] = $personData['person_phone'];
         $this->person_info['registration_status'] = $personData['registration_status'];
         next($personInfoArray);
     }
     $this->linkValues["EditPersonInfo"] .= $this->person_id;
     $this->prepareTemplate($path);
     // set current registration status ID
     $this->template->set('currentRegStatus', $this->person_info['registration_status']);
     // get list of registration statuses
     $regStatuses = new RowManager_StatusManager();
     $regStatusesList = $regStatuses->getListIterator();
     $regStatusesArray = $regStatusesList->getDataList();
     $statusList = array();
     reset($regStatusesArray);
     foreach (array_keys($regStatusesArray) as $k) {
         $record = current($regStatusesArray);
         $statusList[key($regStatusesArray)] = $record['status_desc'];
         next($regStatusesArray);
     }
     // 						echo 'status list = <pre>'.print_r($statusList, true).'</pre>';
     // set registration status information
     $this->template->set('statusFormAction', $this->formAction);
     $this->template->set('statusList', $statusList);
     $this->template->set('statusButtonText', 'Update');
     // set some variables calculated previously; placed here because I need to get PERSON_ID for link
     // which had to be set before prepareTemplate(), which has to be executed BEFORE setting variables...
     $this->template->set('eventBasePrice', $eventBasePrice);
     $this->template->set('priceRules', $rulesApplied);
     $this->template->set('basePriceForThisGuy', $basePriceForThisGuy);
     //$priceGetter->calcBalanceOwing($this->reg_id);		// NOT NEEDED BECAUSE TOTALS CALCULATED
     $this->template->set('person', $this->person_info);
     // get provinces and genders
     $provinces = new RowManager_ProvinceManager();
     $provinceList = $provinces->getListIterator();
     $provincesArray = $provinceList->getDataList();
     //        echo "<pre>".print_r($provincesArray,true)."</pre>";
     $province_info = array();
     reset($provincesArray);
     foreach (array_keys($provincesArray) as $k) {
         $province = current($provincesArray);
         $province_info[$province['province_id']] = $province['province_desc'];
         next($provincesArray);
     }
     $this->template->set('list_province_id', $province_info);
     $genders = new RowManager_GenderManager();
     $genderList = $genders->getListIterator();
     $genderArray = $genderList->getDataList();
     //        echo "<pre>".print_r($genderArray,true)."</pre>";
     $gender_info = array();
     reset($genderArray);
     foreach (array_keys($genderArray) as $k) {
         $gender = current($genderArray);
         $gender_info[$gender['gender_id']] = $gender['gender_desc'];
         next($genderArray);
     }
     $this->template->set('list_gender_id', $gender_info);
     // send in scholarships table, cash transactions table, and credit card transactions table
     $this->template->set('scholarshipsAdminBox', $this->generateScholarshipsTable());
     $this->template->set('cashTransAdminBox', $this->generateCashTransactionsTable());
     $this->template->set('ccTransAdminBox', $this->generateCCTransactionsTable());
     // get scholarship total
     $scholarships = new RowManager_ScholarshipAssignmentManager();
     $scholarships->setRegID($this->reg_id);
     $scholarshipTotal = new MultiTableManager();
     $scholarshipTotal->addRowManager($scholarships);
     $scholarshipTotal->setFunctionCall('SUM', 'scholarship_amount');
     $scholarshipTotal->setGroupBy('registration_id');
     $scholarshipsList = $scholarshipTotal->getListIterator();
     $scholarshipsArray = $scholarshipsList->getDataList();
     reset($scholarshipsArray);
     foreach (array_keys($scholarshipsArray) as $k) {
         $scholarshp = current($scholarshipsArray);
         $scholarship_total = $scholarshp['SUM(scholarship_amount)'];
         next($scholarshipsArray);
     }
     if (!isset($scholarship_total)) {
         $scholarship_total = 0;
     }
     $this->template->set('scholarshipTotal', $scholarship_total);
     // get cash total
     $cashTrans = new RowManager_CashTransactionManager();
     $cashTrans->setRegID($this->reg_id);
     $cashTrans->setReceived(true);
     $cashTransTotal = new MultiTableManager();
     $cashTransTotal->addRowManager($cashTrans);
     $cashTransTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid');
     $cashTransTotal->setGroupBy('reg_id');
     $cashTransList = $cashTransTotal->getListIterator();
     $cashTransArray = $cashTransList->getDataList();
     reset($cashTransArray);
     foreach (array_keys($cashTransArray) as $k) {
         $cash_trans = current($cashTransArray);
         $cash_total = $cash_trans['SUM(cashtransaction_amtPaid)'];
         next($cashTransArray);
     }
     if (!isset($cash_total)) {
         $cash_total = 0;
     }
     $this->template->set('cashTotal', $cash_total);
     // get cash owed
     $cashOwed = new RowManager_CashTransactionManager();
     $cashOwed->setRegID($this->reg_id);
     $cashOwed->setReceived(false);
     $cashOwedTotal = new MultiTableManager();
     $cashOwedTotal->addRowManager($cashOwed);
     $cashOwedTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid');
     $cashOwedTotal->setGroupBy('reg_id');
     $cashOwedList = $cashOwedTotal->getListIterator();
     $cashOwedArray = $cashOwedList->getDataList();
     reset($cashOwedArray);
     foreach (array_keys($cashOwedArray) as $k) {
         $cash_owed = current($cashOwedArray);
         $cash_owing = $cash_owed['SUM(cashtransaction_amtPaid)'];
         next($cashOwedArray);
     }
     if (!isset($cash_owing)) {
         $cash_owing = 0;
     }
     $this->template->set('cashOwed', $cash_owing);
     // get credit card total
     $ccTrans = new RowManager_CreditCardTransactionManager();
     $ccTrans->setProcessed(true);
     $ccTrans->setRegID($this->reg_id);
     $ccTransTotal = new MultiTableManager();
     $ccTransTotal->addRowManager($ccTrans);
     $ccTransTotal->setFunctionCall('SUM', 'cctransaction_amount');
     $ccTransTotal->setGroupBy('reg_id');
     $ccTransList = $ccTransTotal->getListIterator();
     $ccTransArray = $ccTransList->getDataList();
     reset($ccTransArray);
     foreach (array_keys($ccTransArray) as $k) {
         $cc_trans = current($ccTransArray);
         $cc_total = $cc_trans['SUM(cctransaction_amount)'];
         next($ccTransArray);
     }
     if (!isset($cc_total)) {
         $cc_total = 0;
     }
     $this->template->set('ccTotal', $cc_total);
     // TODO??: get credit card transactions NOT processed
     // set form for editing registration-specific form fields' values
     $this->template->set('eventFieldsFormSingle', $this->generateFieldValuesForm());
     // store any additional link Columns
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     // store the page labels
     // NOTE: use this location to update any label tags ...
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // store the Row Manager's XML Node Name
     //        $this->template->set( 'rowManagerXMLNodeName', RowManager_RegistrationManager::XML_NODE_NAME );
     $this->template->set('rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'registration_id');
     // Load over-payment message, if necessary
     if ($this->ccTrans_subPage->hasOverPaid()) {
         $this->template->set('attemptedOverpayment', true);
     }
     // TODO: somehow merge the primary join with the balance owing join.... for efficiency
     /*
      *  Set up any additional data transfer to the Template here...
      */
     //       $this->template->set( 'dataList', $this->dataList);
     $templateName = 'page_EditRegistrationDetails.tpl.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_EditCampusRegistrations.php';
     return $this->template->fetch($templateName);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // do the join
     // campuses
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($campusManager);
     // prcs
     $prcManager = new RowManager_PRCManager();
     $multiTableManager->addRowManager($prcManager, new JoinPair($campusManager->getJoinOnCampusID(), $prcManager->getJoinOnCampusID()));
     // semester
     $semesterManager = new RowManager_SemesterManager();
     // TODO update the semester
     $semesterManager->setSemesterID(1);
     $multiTableManager->addRowManager($semesterManager, new JoinPair($prcManager->getJoinOnSemesterID(), $prcManager->getJoinOnSemesterID()));
     // prc method
     $prcMethodManager = new RowManager_PrcMethodManager();
     $multiTableManager->addRowManager($prcMethodManager, new JoinPair($prcManager->getJoinOnPrcMethodID(), $prcMethodManager->getJoinOnPrcMethodID()));
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('PRC_FOR_SEMESTER');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'IndividualPRC');
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'PRCReport'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'prcReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ------- PART 2 --------
     // WEEKLY STATS
     $multiTableManager = new MultiTableManager();
     $weeklyManager = new RowManager_WeeklyReportManager();
     $multiTableManager->addRowManager($weeklyManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $weeklyManager->getJoinOnCampusID()));
     $weekManager = new RowManager_WeekManager();
     $multiTableManager->addRowManager($weekManager, new JoinPair($weekManager->getJoinOnWeekID(), $weeklyManager->getJoinOnWeekID()));
     $staffManager = new RowManager_StaffManager();
     $multiTableManager->addRowManager($staffManager, new JoinPair($weeklyManager->getJoinOnStaffID(), $staffManager->getJoinOnStaffID()));
     $personManager = new RowManager_PersonManager();
     $multiTableManager->addRowManager($personManager, new JoinPair($personManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('WEEKLY_FOR_SEMESTER');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'IndividualWeek');
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'Report'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'weeklyReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ------- PART 3 --------
     $multiTableManager = new MultiTableManager();
     $campusStatsManager = new RowManager_MoreStatsManager();
     $multiTableManager->addRowManager($campusStatsManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusStatsManager->getJoinOnCampusID()));
     $weekManager = new RowManager_WeekManager();
     $multiTableManager->addRowManager($weekManager, new JoinPair($campusStatsManager->getJoinOnWeekID(), $weekManager->getJoinOnWeekID()));
     $expTypeManager = new RowManager_ExposureTypeManager();
     $multiTableManager->addRowManager($expTypeManager, new JoinPair($campusStatsManager->getJoinOnExpTypeID(), $expTypeManager->getJoinOnExpTypeID()));
     $count = 0;
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('CAMPUS_REPORT');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'Activity');
         $count++;
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     echo 'the count is [' . $count . ']<br/>';
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'Report'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'campusReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ---------------
     // OK DONE!
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_Reports.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
 protected function getStaffIDfromViewerID()
 {
     $staffViewer = new MultiTableManager();
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $staff = new RowManager_StaffManager();
     $staffViewer->addRowManager($staff);
     $staffViewer->addRowManager($accessPriv, new JoinPair($staff->getJoinOnPersonID(), $accessPriv->getJoinOnPersonID()));
     $staffViewerList = $staffViewer->getListIterator();
     $staffViewerArray = $staffViewerList->getDataList();
     $staffID = '';
     reset($staffViewerArray);
     foreach (array_keys($staffViewerArray) as $k) {
         $record = current($staffViewerArray);
         $staffID = $record['staff_id'];
         // can only be 1 staff_id per viewer_id
         next($staffViewerArray);
     }
     return $staffID;
 }
 /**
  * function getBasePriceForRegistrant
  * <pre>
  * Returns registration cost for a particular registration, not including scholarship discounts
  * </pre>
  * Pre-condition: all variables must be initialized with proper values
  *
  * @param $regID [INTEGER]		registration ID
  * @param $eventID [INTEGER]	event ID
  * @param $campusID [INTEGER]	campus ID (precondition: must be associated directly with registration ID)
  * @param $eventBasePrice [INTEGER]	the cost of the event per registration, before any discounts
  * @param $priceRulesArray [ARRAY]	an array of the price rules applying to event denoted by $eventID
  * @param &$rulesApplied [ARRAY REFERENCE]	reference to an array to be filled with applied rules	
  * @return [INTEGER] $basePriceForThisGuy		the new base price for registration $regID (before scholarships)
  */
 function getBasePriceForRegistrant($regID, $eventID, $campusID, $eventBasePrice, $priceRulesArray, &$rulesApplied = array())
 {
     // Need to manually calculate discounts for these exceptions:
     $BC_SUMMIT_2007 = 19;
     $MB_SUMMIT_2007 = 22;
     $LAKESHORE_SUMMIT_2007 = 25;
     $EASTERN_WC_2007 = 28;
     $AIA_NATIONAL_TRAINING = 33;
     $MARITIMES_SUMMIT_2008 = 34;
     $basePriceForThisGuy = $eventBasePrice;
     // 	     echo "<pre>".print_r($priceRulesArray,true)."</pre>";
     // PUT SPECIAL EVENT EXCEPTIONS HERE AS CONDITIONAL STATEMENTS:
     /*	    if ($eventID == $MARITIMES_SUMMIT_2008)
     	    {
     		    $FROSH_DISCOUNT_FIELD = 119;
     		    
     		    // first check for Frosh Discount
                 $fieldValue = new RowManager_FieldValueManager();
     // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
     			$fieldValue->setFieldID($FROSH_DISCOUNT_FIELD);
     			$fieldValue->setRegID($regID);
              
              $valueListManager = $fieldValue->getListIterator(); 
              $fieldValueList = $valueListManager->getDataList();	
     // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
     			
              reset($fieldValueList);
              $record = current($fieldValueList);		         	
     
     			// CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
     // 					$userValue = '';
     			$userValue = $record['fieldvalues_value'];   // $fieldValue->getFieldValue();
     			if ((isset($userValue))&&($userValue != '')) 
     			{
     			
     				// DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
                 if ( $userValue == '1')
                 {
                     // form criteria is met, apply the discount/penalty
     //                 $basePriceForThisGuy -= 15;		// subtract $15 from $65 event base cost
     					$basePriceForThisGuy = 50;		// frosh cost
     					
     					$rulesApplied[] = $priceRulesArray['45'];
     					
     					return $basePriceForThisGuy;
                 }			
            	}  
            	
            	// if no frosh discount, THEN apply early bird discount (if conditions met)
     // 		        echo "DATE RULE<BR>";
              // get the user's registration date    
              $registration = new RowManager_RegistrationManager();
              $registration->setRegID($regID);
              
              $regListManager = $registration->getListIterator(); 
              $regArray = $regListManager->getDataList();	
     //        echo "<pre>".print_r($registration,true)."</pre>";	
     
     			// set default date-time
     			$regTime = '';	
     			
     			// retrieve registration date
     			reset($regArray);
     			$record = current($regArray);	// should be only 1 record for regID
     			$regTime = $record['registration_date'];
     		
     // 					$regTime = $registration->getRegistrationDate();
     			if ($regTime != '') 
     			{										
     				
                 // if the registrant signed up before a deadline, apply the rule
                 if ( strtotime($regTime) < strtotime( '2008-04-01' )  )		//$rule['pricerules_value']
                 {
                     // date criteria is met, apply the discount/penalty
     //                 $basePriceForThisGuy -= 15;		// apply early bird discount to $65 event base cost to get $50
                     
     					 $basePriceForThisGuy = 50;
                     $rulesApplied[] = $priceRulesArray['47'];
                     
                     return $basePriceForThisGuy;
                 }	
           	}	      		    
     		    
     	    	return $basePriceForThisGuy;			// otherwise return unaltered base event cost ($125)
         	}		*/
     if ($eventID == $AIA_NATIONAL_TRAINING) {
         $FOOD_PASS_REQ_FIELD = 102;
         $HOUSING_REQ_FIELD = 103;
         // first check for Food Pass Fee
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($FOOD_PASS_REQ_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR $FOOD_PASS_REQ_FIELD
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             /** Get the user's registration date **/
             $registration = new RowManager_RegistrationManager();
             $registration->setRegID($regID);
             $regListManager = $registration->getListIterator();
             $regArray = $regListManager->getDataList();
             //        echo "<pre>".print_r($registration,true)."</pre>";
             // set default date-time
             $regTime = '';
             // retrieve registration date-time
             reset($regArray);
             $record = current($regArray);
             // should be only 1 record for regID
             $regTime = $record['registration_date'];
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // form criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy += 100;		// add 150 to base 260 event price
                 $basePriceForThisGuy += 150;
                 $rulesApplied[] = $priceRulesArray['39'];
                 // Apply early-bird discount on this if applicable
                 if ($regTime != '') {
                     // if the registrant signed up before a deadline, apply the rule
                     if (strtotime($regTime) < strtotime('2008-04-16')) {
                         $basePriceForThisGuy -= 50;
                         // subtract 50
                         $rulesApplied[] = $priceRulesArray['42'];
                     }
                 }
             }
         }
         // second check for Housing Fee
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($HOUSING_REQ_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR $HOUSING_REQ_FIELD
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             /** Get the user's registration date **/
             $registration = new RowManager_RegistrationManager();
             $registration->setRegID($regID);
             $regListManager = $registration->getListIterator();
             $regArray = $regListManager->getDataList();
             //        echo "<pre>".print_r($registration,true)."</pre>";
             // set default date-time
             $regTime = '';
             // retrieve registration date-time
             reset($regArray);
             $record = current($regArray);
             // should be only 1 record for regID
             $regTime = $record['registration_date'];
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // form criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy += 180;		// add 230 to base 260 event price
                 $basePriceForThisGuy += 230;
                 $rulesApplied[] = $priceRulesArray['41'];
                 // Apply early-bird discount on this if applicable
                 if ($regTime != '') {
                     // if the registrant signed up before a deadline, apply the rule
                     if (strtotime($regTime) < strtotime('2008-04-16')) {
                         $basePriceForThisGuy -= 50;
                         // subtract 50
                         $rulesApplied[] = $priceRulesArray['42'];
                     }
                 }
                 return $basePriceForThisGuy;
             }
         }
         return $basePriceForThisGuy;
         // otherwise return unaltered base event cost ($125)
     }
     if ($eventID == $EASTERN_WC_2007) {
         $COMMUTER_DISCOUNT_FIELD = 86;
         // first check for Frosh Discount
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($COMMUTER_DISCOUNT_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // form criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy -= 80;		// subtract $80 from $279 event base cost
                 $basePriceForThisGuy = 199;
                 // commuter cost
                 $rulesApplied[] = $priceRulesArray['38'];
                 return $basePriceForThisGuy;
             }
         }
         // if no commuter discount, THEN apply early bird discount (if conditions met)
         // 		        echo "DATE RULE<BR>";
         // get the user's registration date
         $registration = new RowManager_RegistrationManager();
         $registration->setRegID($regID);
         $regListManager = $registration->getListIterator();
         $regArray = $regListManager->getDataList();
         //        echo "<pre>".print_r($registration,true)."</pre>";
         // set default date-time
         $regTime = '';
         // retrieve registration date
         reset($regArray);
         $record = current($regArray);
         // should be only 1 record for regID
         $regTime = $record['registration_date'];
         // 					$regTime = $registration->getRegistrationDate();
         if ($regTime != '') {
             // if the registrant signed up before a deadline, apply the rule
             if (strtotime($regTime) < strtotime('2007-12-01')) {
                 if (strtotime($regTime) < strtotime('2007-10-09')) {
                     // date criteria is met, apply the discount/penalty
                     //                 $basePriceForThisGuy -= 50;		// apply early bird discounts to $279 event base cost to get $229
                     $basePriceForThisGuy = 229;
                     $rulesApplied[] = $priceRulesArray['37'];
                     $rulesApplied[] = $priceRulesArray['36'];
                     return $basePriceForThisGuy;
                 } else {
                     // date criteria is met, apply the discount/penalty
                     //                 $basePriceForThisGuy -= 50;		// apply regular discount to $279 event base cost to get $259
                     $basePriceForThisGuy = 259;
                     $rulesApplied[] = $priceRulesArray['36'];
                     return $basePriceForThisGuy;
                 }
             }
         }
         return $basePriceForThisGuy;
         // otherwise return unaltered base event cost ($125)
     }
     // PUT SPECIAL EVENT EXCEPTIONS HERE AS CONDITIONAL STATEMENTS:
     if ($eventID == $BC_SUMMIT_2007) {
         $FROSH_DISCOUNT_FIELD = 54;
         // first check for Frosh Discount
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // form criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy -= 46;		// subtract $46 from $125 event base cost
                 $basePriceForThisGuy = 79;
                 // frosh cost
                 $rulesApplied[] = $priceRulesArray['14'];
                 return $basePriceForThisGuy;
             }
         }
         // if no frosh discount, THEN apply early bird discount (if conditions met)
         // 		        echo "DATE RULE<BR>";
         // get the user's registration date
         $registration = new RowManager_RegistrationManager();
         $registration->setRegID($regID);
         $regListManager = $registration->getListIterator();
         $regArray = $regListManager->getDataList();
         //        echo "<pre>".print_r($registration,true)."</pre>";
         // set default date-time
         $regTime = '';
         // retrieve registration date
         reset($regArray);
         $record = current($regArray);
         // should be only 1 record for regID
         $regTime = $record['registration_date'];
         // 					$regTime = $registration->getRegistrationDate();
         if ($regTime != '') {
             // if the registrant signed up before a deadline, apply the rule
             if (strtotime($regTime) < strtotime('2007-09-21')) {
                 // date criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy -= 26;		// apply early bird discount to $125 event base cost to get $99
                 $basePriceForThisGuy = 99;
                 $rulesApplied[] = $priceRulesArray['15'];
                 return $basePriceForThisGuy;
             }
         }
         return $basePriceForThisGuy;
         // otherwise return unaltered base event cost ($125)
     }
     if ($eventID == $MB_SUMMIT_2007) {
         $FROSH_DISCOUNT_FIELD = 60;
         $FROSH_VOLUME_THRESHOLD = 20;
         $MB_EARLY_FROSH_TABLE = 'temp_mb_early_frosh';
         // first check for Frosh Discount
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // check if there are 20 or more frosh already stored
                 $froshValues = new RowManager_FieldValueManager();
                 $froshValues->setFieldID($FROSH_DISCOUNT_FIELD);
                 $froshValues->setFieldValue('1');
                 // 1 = checked checkbox
                 $fieldsManager = new MultiTableManager();
                 $fieldsManager->addRowManager($froshValues);
                 // TODO: sub-query like 'SELECT <ALL FIELD VALUES FOR SPECIFIC FROSH DISCOUNT> WHERE REG_ID IN (SELECT ALL REGISTRATIONS FOR EVENT)'
                 $regs = new RowManager_RegistrationManager();
                 $regs->setEventID($eventID);
                 $regData = new MultiTableManager();
                 $regData->addRowManager($regs);
                 $regData->setFieldList('registration_id');
                 $registered_SQL = $regData->createSQL();
                 // actually creates the sub-query in order to get an accurate count of discount field values stored
                 $negateSubQuery = false;
                 $addSubQuery = true;
                 $fieldsManager->constructSubQuery('registration_id', $registered_SQL, $negateSubQuery, $addSubQuery);
                 // 		         $froshValues->setSortOrder('registration_id');
                 $froshList = $fieldsManager->getListIterator();
                 $froshArray = array();
                 $froshArray = $froshList->getDataList();
                 // 		         echo "COUNT = ".count($froshArray);
                 if (count($froshArray) <= $FROSH_VOLUME_THRESHOLD) {
                     // form criteria is met, apply the discount/penalty
                     //                 $basePriceForThisGuy -= 25;		// subtract $46 from $125 event base cost
                     $basePriceForThisGuy = 40;
                     // frosh cost
                     $rulesApplied[] = $priceRulesArray['25'];
                     $db = new Database_MySQL();
                     $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD);
                     // precaution that avoids duplicates
                     $sql = "DELETE FROM " . $MB_EARLY_FROSH_TABLE . " WHERE registration_id = " . $regID;
                     $db->runSQL($sql);
                     $sql = "INSERT INTO " . $MB_EARLY_FROSH_TABLE . " (registration_id) VALUES (" . $regID . ")";
                     $db->runSQL($sql);
                 } else {
                     $db = new Database_MySQL();
                     $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD);
                     $sql = "SELECT * FROM " . $MB_EARLY_FROSH_TABLE . " WHERE registration_id = " . $regID;
                     $db->runSQL($sql);
                     $temp_regID = '';
                     if ($row = $db->retrieveRow()) {
                         $temp_regID = $row['registration_id'];
                     }
                     // apply rule despite there being >20 frosh because this registration existed before cut-off
                     if ($regID == $temp_regID) {
                         //                 $basePriceForThisGuy -= 25;		// subtract $25 from $85 event base cost
                         $basePriceForThisGuy = 40;
                         // frosh cost
                         $rulesApplied[] = $priceRulesArray['25'];
                     } else {
                         $basePriceForThisGuy = 60;
                         // basic frosh cost
                         $rulesApplied[] = $priceRulesArray['28'];
                     }
                 }
                 return $basePriceForThisGuy;
             }
         }
         return $basePriceForThisGuy;
         // otherwise return unaltered base event cost ($85)
     }
     if ($eventID == $LAKESHORE_SUMMIT_2007) {
         $FROSH_DISCOUNT_FIELD = 64;
         // first check for Frosh Discount
         $fieldValue = new RowManager_FieldValueManager();
         // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
         $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD);
         $fieldValue->setRegID($regID);
         $valueListManager = $fieldValue->getListIterator();
         $fieldValueList = $valueListManager->getDataList();
         // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
         reset($fieldValueList);
         $record = current($fieldValueList);
         // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
         // 					$userValue = '';
         $userValue = $record['fieldvalues_value'];
         // $fieldValue->getFieldValue();
         if (isset($userValue) && $userValue != '') {
             // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
             if ($userValue == '1') {
                 // form criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy -= <varies>;		// subtract <varying amount> from $120/$115/$110/$105 to get $75
                 $basePriceForThisGuy = 75;
                 // frosh cost
                 $rulesApplied[] = $priceRulesArray['19'];
                 return $basePriceForThisGuy;
             }
         }
         // if no frosh discount, THEN apply early bird discount (if conditions met)
         // 		        echo "DATE RULE<BR>";
         // get the user's registration date
         $registration = new RowManager_RegistrationManager();
         $registration->setRegID($regID);
         $regListManager = $registration->getListIterator();
         $regArray = $regListManager->getDataList();
         //        echo "<pre>".print_r($registration,true)."</pre>";
         // set default date-time
         $regTime = '';
         // retrieve registration date
         reset($regArray);
         $record = current($regArray);
         // should be only 1 record for regID
         $regTime = $record['registration_date'];
         // 					$regTime = $registration->getRegistrationDate();
         if ($regTime != '') {
             // if the registrant signed up before a deadline, apply the rule
             if (strtotime($regTime) < strtotime('2007-09-26')) {
                 // date criteria is met, apply the discount/penalty
                 //                 $basePriceForThisGuy -= 15;		// apply early bird discount to $115 event base cost to get $105
                 $basePriceForThisGuy = 105;
                 $rulesApplied[] = $priceRulesArray['20'];
                 return $basePriceForThisGuy;
             }
         }
         return $basePriceForThisGuy;
         // otherwise return unaltered base event cost ($120)
     }
     /**** END OF RULE EXCEPTIONS ****/
     // apply any price rules
     foreach ($priceRulesArray as $key => $rule) {
         $ruleType = $rule['priceruletypes_id'];
         // form attribute rule: apply price rule based on whether some form field value exists (i.e. frosh discount)
         if ($ruleType == RowManager_PriceRuleTypeManager::FORM_ATTRIBUTE_RULE) {
             // 	            echo "FORM RULE<BR>";
             // get the user's input for this form attribute
             $fieldValue = new RowManager_FieldValueManager();
             // 	            $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID);
             $fieldValue->setFieldID($rule['fields_id']);
             $fieldValue->setRegID($regID);
             $valueListManager = $fieldValue->getListIterator();
             $fieldValueList = $valueListManager->getDataList();
             // 		         echo "<pre>".print_r($fieldValueList,true)."</pre>";
             reset($fieldValueList);
             $record = current($fieldValueList);
             // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS
             // 					$userValue = '';
             $userValue = $record['fieldvalues_value'];
             // $fieldValue->getFieldValue();
             if (isset($userValue) && $userValue != '') {
                 // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE
                 if ($rule['pricerules_value'] == $userValue) {
                     // form criteria is met, apply the discount/penalty
                     $basePriceForThisGuy += $rule['pricerules_discount'];
                     $rulesApplied[] = $rule;
                 }
             }
         } else {
             if ($ruleType == RowManager_PriceRuleTypeManager::DATE_RULE) {
                 // 		        echo "DATE RULE<BR>";
                 // get the user's registration date
                 $registration = new RowManager_RegistrationManager();
                 $registration->setRegID($regID);
                 $regListManager = $registration->getListIterator();
                 $regArray = $regListManager->getDataList();
                 //        echo "<pre>".print_r($registration,true)."</pre>";
                 // set default date-time
                 $regTime = '';
                 // retrieve registration date
                 reset($regArray);
                 $record = current($regArray);
                 // should be only 1 record for regID
                 $regTime = $record['registration_date'];
                 // 					$regTime = $registration->getRegistrationDate();
                 if ($regTime != '') {
                     // if the registrant signed up before a deadline, apply the rule
                     if (strtotime($regTime) < strtotime($rule['pricerules_value'])) {
                         // date criteria is met, apply the discount/penalty
                         $basePriceForThisGuy += $rule['pricerules_discount'];
                         $rulesApplied[] = $rule;
                     }
                 }
             } else {
                 if ($ruleType == RowManager_PriceRuleTypeManager::VOLUME_RULE) {
                     $volumeNeeded = $rule['pricerules_value'];
                     // 		        $correctCampus = false;
                     // 		        $pattern = RowManager_PriceRuleTypeManager::CAMPUS_VOLUME_REGEX;
                     // 		        $numMatches = preg_match($pattern, $rule['pricerules_value']);
                     // 		        if ($numMatches > 0)
                     // 		        {
                     //
                     // 						$pricingValues = explode('|',$rule['pricerules_value']);
                     // 	//					echo '<pre>'.print_r($pricingValues,true).'</pre>';
                     // 	//					echo 'campus = '.$pricingValues[0].'  cut-off = '.$pricingValues[1];
                     // 						if ((int)$pricingValues[0] == $campusID)
                     // 						{
                     // 							$correctCampus = true;
                     // 							$volumeNeeded = $pricingValues[1];
                     //
                     // 	/*						if ($numRegistrantsMyCampus != '')
                     // 							{
                     // 				            // if the # of registrants >= the bulk discount value...
                     // 				            if ( $numRegistrantsMyCampus >= $pricingValues[1] )
                     // 				            {
                     // 				                // bulk discount criteria is met, apply the discount/penalty
                     // 				                $basePriceForThisGuy += $rule['pricerules_discount'];
                     //
                     // 				                $rulesApplied[] = $rule;
                     // 				            }
                     // 			         	}
                     // 			         	else 	// try to calculate the # of registrants on our own
                     // 			         	{
                     // 	*/
                     //
                     // 	/**						}
                     // 	**/
                     // 						}
                     // 					}
                     //
                     // 					// check volume rule if no specific campus associated or current campus is associated with rule
                     // 					if (($numMatches == 0)||($correctCampus == true))
                     // 					{
                     if (isset($campusID) && $campusID != '') {
                         // get total registrations for specific campus and particular event
                         $total = array();
                         $summary = new RegSummaryTools();
                         $total = $summary->getCampusRegistrations($eventID, '', false, $campusID, '', RowManager_RegistrationManager::STATUS_REGISTERED);
                         if (isset($total[$campusID])) {
                             $numRegistrantsMyCampus = $total[$campusID];
                         } else {
                             $numRegistrantsMyCampus = 0;
                         }
                         if (count($total) > 0) {
                             // if the # of registrants >= the bulk discount value...
                             if ($numRegistrantsMyCampus >= $volumeNeeded) {
                                 // bulk discount criteria is met, apply the discount/penalty
                                 $basePriceForThisGuy += $rule['pricerules_discount'];
                                 $rulesApplied[] = $rule;
                             }
                         }
                     } else {
                         // should not occur, this function meant to be used with campusID set
                     }
                 } else {
                     if ($ruleType == RowManager_PriceRuleTypeManager::CAMPUS_RULE) {
                         // 		        echo "CAMPUS RULE<BR>";
                         // check the campus ID against the one stored in the price rules table
                         if ($campusID == $rule['pricerules_value']) {
                             $basePriceForThisGuy += $rule['pricerules_discount'];
                             $rulesApplied[] = $rule;
                         }
                     } else {
                         die('unknown ruletype[' . $ruleType . ']');
                     }
                 }
             }
         }
     }
     // foreach rule
     // special hack for Eastern Ontario/Montreal summit 2006
     /*	    if ( $eventID == 4 )
     	    {
     	        $basePriceForThisGuy = getBasePriceEasternSummit2006( $regID, $numRegistrantsMyCampus, $rulesApplied );
     	    }
     	    else if ( $eventID == 11 )
     	    {
     	        $basePriceForThisGuy = getBasePricePrairieSummit2006( $regID, $campusID, $numRegistrantsMyCampus, $rulesApplied );
     	    }
     */
     return $basePriceForThisGuy;
 }
 /**
  * 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;
     $exposureArray = array();
     $exposureTypeManager = new RowManager_ExposureTypeManager();
     $exIt = $exposureTypeManager->getListIterator();
     $exIt->setFirst();
     while ($exIt->moveNext()) {
         $anEx = $exIt->getCurrent(new RowManager_ExposureTypeManager());
         $typeID = $anEx->getID();
         $campusExposure = new CampusExposure();
         $campusExposure->expDesc = $anEx->getLabel();
         $arrayOfExposures = array();
         $weekManager = new RowManager_WeekManager();
         $weekManager->setSemesterID($this->semester_id);
         $moreStatsManager = new RowManager_MoreStatsManager();
         $moreStatsManager->setExposureTypeID($typeID);
         $moreStatsManager->setCampusID($this->campus_id);
         $multiTableManager = new MultiTableManager();
         $multiTableManager->addRowManager($weekManager);
         $multiTableManager->addRowManager($moreStatsManager, new JoinPair($weekManager->getJoinOnWeekID(), $moreStatsManager->getJoinOnWeekID()));
         $listIterator = $multiTableManager->getListIterator();
         $listIterator->setFirst();
         $dataArray = array();
         while ($listIterator->moveNext()) {
             $moreStatsObj = $listIterator->getCurrent(new RowManager_MoreStatsManager());
             $weekObj = $listIterator->getCurrent(new RowManager_WeekManager());
             $arrayOfExposures[] = array_merge($moreStatsObj->getArrayOfValues(), $weekObj->getArrayOfValues());
             // array( 1=>array("week_endDate"=>"23-34", "morestats_notes"=>"some notes", "morestats_exp"=>35));
         }
         $campusExposure->valuesArray = $arrayOfExposures;
         $exposureArray[] = $campusExposure;
     }
     // while
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     $campusJumpLinkSelectedValue = $this->linkValues['campusJumpLink'] . $this->campus_id;
     $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'] . $this->semester_id;
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     $this->template->set('exposureArray', $exposureArray);
     $this->template->set('campusJumpLinkSelectedValue', $campusJumpLinkSelectedValue);
     $this->template->set('semesterJumpLinkSelectedValue', $semesterJumpLinkSelectedValue);
     // campus list
     $jumpLink = $this->linkValues['campusJumpLink'];
     $campusArray = array();
     $this->campusListIterator->setFirst();
     while ($this->campusListIterator->moveNext()) {
         $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager());
         $campusArray[$jumpLink . $campusObject->getID()] = $campusObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_campus_id', $campusArray);
     // semester list
     $jumpLink = $this->linkValues['semesterJumpLink'];
     $semesterArray = array();
     $semesterManager = new RowManager_SemesterManager();
     $this->semesterListIterator = $semesterManager->getListIterator();
     $this->semesterListIterator->setFirst();
     while ($this->semesterListIterator->moveNext()) {
         $semesterObject = $this->semesterListIterator->getCurrent(new RowManager_SemesterManager());
         $semesterArray[$jumpLink . $semesterObject->getID()] = $semesterObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_semester_id', $semesterArray);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_CampusWeeklyStatsReport.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
 protected function getNextStatusID()
 {
     // get the MAX(status_id)... need to determine what insertion status_id will be (used to create new status record)
     $status = new RowManager_StatusManager();
     $statuses = new MultiTableManager();
     $statuses->addRowManager($status);
     $statuses->setFunctionCall('MAX', 'status_id');
     $statuses->ignoreFields();
     // only leave MAX(status_id) in values to be returned
     $statusesList = $statuses->getListIterator();
     $statusesArray = $statusesList->getDataList();
     $maxID = -1;
     reset($statusesArray);
     foreach (array_keys($statusesArray) as $k) {
         $statusRecord = current($statusesArray);
         $maxID = $statusRecord['MAX(status_id)'];
         if ($maxID > -1) {
             // this condition occurs if no records found
             if ($maxID == '') {
                 $maxID = -1;
             }
             break;
             // get out of the loop once MAX is found
         }
         next($statusesArray);
     }
     return $maxID + 1;
     // NOTE: equals 0 if nothing found
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     // The weeks
     $weekManager = new RowManager_WeekManager();
     $weekManager->setSemesterID($this->semester_id);
     $weekManager->setSortByDate();
     $staffArray = array();
     // figure out all the people we want to report on
     $isCD = $this->permManager->isCD();
     if ($isCD) {
         // get all the people from this campus who have reported stats
         $wklyReportManager = new RowManager_WeeklyReportManager();
         $wklyReportManager->setCampusID($this->campus_id);
         $anotherWeekManager = new RowManager_WeekManager();
         $anotherWeekManager->setSemesterID($this->semester_id);
         $multiTableManager = new MultiTableManager();
         $multiTableManager->addRowManager($wklyReportManager);
         $multiTableManager->addRowManager($anotherWeekManager, new JoinPair($wklyReportManager->getJoinOnWeekID(), $anotherWeekManager->getJoinOnWeekID()));
         $this->listIterator = $multiTableManager->getListIterator();
         $this->listIterator->setFirst();
         while ($this->listIterator->moveNext()) {
             $reportRow = $this->listIterator->getCurrent(new RowManager_WeeklyReportManager());
             $staffArray[] = $reportRow->getStaffID();
         }
         $staffArray = array_unique($staffArray);
         // echo '<pre>'.print_r($staffArray, true).'</pre>';
     } else {
         // just get the stats for the staff viewing the page
         $staffArray[] = $this->staff_id;
     }
     $infoArray = array();
     foreach ($staffArray as $indx => $staffID) {
         //IndSemesterInfo
         $indInfo = new IndSemesterInfo();
         $staffManager = new RowManager_StaffManager($staffID);
         $personID = $staffManager->getPersonID();
         $personManager = new RowManager_PersonManager($personID);
         $personManager->setLabelTemplateLastNameFirstName();
         $indInfo->staffName = $personManager->getLabel();
         $indInfo->staffID = $staffID;
         // calendar
         $indInfo->calendar = array();
         $currentMonth = 0;
         // actual data
         // dataArray[weekID] = arrayOfData
         $indInfo->dataArray = array();
         $weekList = new ListIterator($weekManager);
         $weekList->setFirst();
         while ($weekList->moveNext()) {
             $week = $weekList->getCurrent(new RowManager_WeekManager());
             $weekID = $week->getID();
             // setup stuff for the calendar in the report
             $endDate = $week->getEndDate();
             list($year, $month, $day) = explode('-', $endDate);
             $month = ltrim($month, "0");
             // $day = ltrim($day, "0");
             if ($currentMonth != $month) {
                 // echo 'start new array<br/>';
                 $currentMonth = $month;
             }
             $indInfo->calendar[$currentMonth][$day] = $weekID;
             // end calendar stuff
             // check if an entry exists in the table for
             $weeklyReport = new RowManager_WeeklyReportManager($weekID, $staffID, $this->campus_id);
             if ($weeklyReport->isLoaded()) {
                 // echo $week->getEndDate() . ' loaded <br/>';
                 $indInfo->dataArray[$weekID] = $weeklyReport->getArrayOfValues();
                 // echo '<pre>'.print_r( $weeklyReport->getArrayOfValues() ).'</pre>';
             } else {
                 $indInfo->dataArray[$weekID] = null;
                 // echo $week->getEndDate() . ' NOT loaded <br/>';
             }
         }
         // echo '<pre>'.print_r($calendar,true).'</pre>';
         $infoArray[] = $indInfo;
     }
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     $campusJumpLinkSelectedValue = $this->linkValues['campusJumpLink'] . $this->campus_id;
     $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'] . $this->semester_id;
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // $this->template->set( 'calendar', $calendar );
     // $this->template->set( 'dataArray', $dataArray );
     $this->template->set('infoArray', $infoArray);
     $this->template->set('campusJumpLinkSelectedValue', $campusJumpLinkSelectedValue);
     $this->template->set('semesterJumpLinkSelectedValue', $semesterJumpLinkSelectedValue);
     // campus list
     $jumpLink = $this->linkValues['campusJumpLink'];
     $campusArray = array();
     $this->campusListIterator->setFirst();
     while ($this->campusListIterator->moveNext()) {
         $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager());
         $region_id = $campusObject->getRegionID();
         if ($region_id == 1 || $region_id == 2 || $region_id == 3) {
             $campusArray[$jumpLink . $campusObject->getID()] = $campusObject->getLabel();
         }
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_campus_id', $campusArray);
     // semester list
     $jumpLink = $this->linkValues['semesterJumpLink'];
     $semesterArray = array();
     $semesterManager = new RowManager_SemesterManager();
     $this->semesterListIterator = $semesterManager->getListIterator();
     $this->semesterListIterator->setFirst();
     while ($this->semesterListIterator->moveNext()) {
         $semesterObject = $this->semesterListIterator->getCurrent(new RowManager_SemesterManager());
         $semesterArray[$jumpLink . $semesterObject->getID()] = $semesterObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_semester_id', $semesterArray);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_StaffSemesterReport.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }