/**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_AdminHome::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $privManager = new PrivilegeManager($this->viewer->getID());
     $dataAccessObject = new RowManager_EventManager();
     // go through events found for logged-in administrator (if lower level than super-admin)
     //         if ($privManager->isSuperAdmin()==false)	// check privilege level
     //         {
     // 	        $adminEvents = $privManager->getAdminEvents();
     // 	        if ($adminEvents != PrivilegeManager::ALL_EVENTS)
     // 	        {
     // 		        for ($i=0; $i < count($adminEvents); $i++)
     // 		        {
     // 		        		$condArray[$i] = $dataAccessObject->constructSearchCondition( 'event_id', '=', $adminEvents[$i]);
     // 		     		}
     // 	     	  		$dataAccessObject->constructSearchConditionFromArray( $condArray, 'OR', true );
     //      	  		}
     //   	  		}
     $dataAccessObject->setSortOrder($sortBy);
     //        $this->listManager = new EventList( $sortBy );
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_AdminHome::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 protected function getEventBasePrice($eventID)
 {
     $event = new RowManager_EventManager();
     $event->setEventID($eventID);
     $eventList = $event->getListIterator();
     $eventArray = $eventList->getDataList();
     $eventBasePrice = 0;
     reset($eventArray);
     foreach (array_keys($eventArray) as $k) {
         $record = current($eventArray);
         $eventBasePrice = $record['event_basePrice'];
         // should be only 1 base price for 1 event_id
         next($eventArray);
     }
     return $eventBasePrice;
 }
 protected function setRegistrationID()
 {
     // get registration ID for the rest of the reg. process
     $regs = new RowManager_RegistrationManager();
     $people = new RowManager_PersonManager();
     $people->setPersonID($this->person_id);
     $events = new RowManager_EventManager();
     $events->setEventID($this->event_id);
     $personRegs = new MultiTableManager();
     $personRegs->addRowManager($regs);
     $personRegs->addRowManager($people, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID()));
     $personRegs->addRowManager($events, new JoinPair($regs->getJoinOnEventID(), $events->getJoinOnEventID()));
     $regsList = $personRegs->getListIterator();
     $regsArray = $regsList->getDataList();
     //        echo "<pre>".print_r($regsArray,true)."</pre>";
     reset($regsArray);
     foreach (array_keys($regsArray) as $k) {
         $registration = current($regsArray);
         $this->registration_id = $registration['registration_id'];
         // NOTE: should only be one reg. per person per event (ENFORCE??)
         next($regsArray);
     }
     // create new registration record for this person (since none exists for current person-event combo)
     if (!isset($this->registration_id)) {
         // get status id for INITIAL_REG_STATUS
         $regStatus = new RowManager_StatusManager();
         $regStatus->setStatusDesc(FormProcessor_EditMyInfo::INITIAL_REG_STATUS);
         $regStatusList = $regStatus->getListIterator();
         $regStatusArray = $regStatusList->getDataList();
         $statusID = 0;
         reset($regStatusArray);
         foreach (array_keys($regStatusArray) as $k) {
             $status = current($regStatusArray);
             $statusID = $status['status_id'];
             // NOTE: should only be one reg. per person per event (ENFORCE??)
             next($regStatusArray);
         }
         // get the MAX(registration_id)... need to determine what insertion registration ID will be (used in confirmNum)
         $allRegs = new MultiTableManager();
         $regs2 = new RowManager_RegistrationManager();
         $allRegs->addRowManager($regs2);
         $allRegs->setFunctionCall('MAX', 'registration_id');
         $allRegs->ignoreFields();
         // only leave MAX(registration_id) in values to be returned
         $allRegsList = $allRegs->getListIterator();
         $allRegsArray = $allRegsList->getDataList();
         $maxID = -1;
         reset($allRegsArray);
         foreach (array_keys($allRegsArray) as $k) {
             $regRecord = current($allRegsArray);
             $maxID = $regRecord['MAX(registration_id)'];
             if ($maxID > -1) {
                 break;
                 // get out of the loop once MAX is found
             }
             next($allRegsArray);
         }
         // compile values needed for new registration record
         $regValues = array();
         $nextRegID = $maxID + 1;
         $regValues['event_id'] = $this->event_id;
         // check if a new person record needs to be created
         if ($this->person_id == -1) {
             $this->person_id = $this->getNextPersonID();
             // assumes processData() will properly use this value for insertion
             // create empty person record to start off... since otherwise FK constraint on cim_reg_registration is NOT satisfied
             $personManager = new RowManager_PersonManager($this->person_id);
             $personManager->loadFromArray($this->formValues);
             $personManager->setPersonID($this->person_id);
             $personManager->createNewEntry(true);
             //$this->assignCampus($this->person_id);	-- save this step for when info properly entered into form
         }
         $regValues['person_id'] = $this->person_id;
         $timestamp = strtotime("now");
         $date = date('Y-m-d H:i:s', $timestamp);
         // == NOW() : to bad I could pass that as non-string...
         $regValues['registration_date'] = $date;
         // set date-time to current date-time
         $regValues['registration_confirmNum'] = 'E' . $this->event_id . 'R' . $nextRegID . 'C' . $this->campus_id;
         $regValues['registration_status'] = $statusID;
         // store values in table manager object.
         $regs->loadFromArray($regValues);
         // set primary key to use for update (if maxID found)
         if ($maxID > -1) {
             $regValues['registration_id'] = $nextRegID;
             $regs->setRegID($regValues['registration_id']);
         }
         // now update the DB with the values
         if (!$regs->isLoaded()) {
             $regs->createNewEntry(true);
             // allow primary key to be set (in case auto_increment is off)
             $this->registration_id = $nextRegID;
         }
         // TODO: figure out how to show error if no registration made, or updated (IF it is even possible now...)
     }
 }
 /**
  * function 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);
 }
Beispiel #5
0
  * event_id [INTEGER]  unique id
  * event_name [STRING]  name of event
  * event_descBrief [STRING]  brief description
  * event_descDetail [STRING]  Detailed description of the event
  * event_startDate [DATE]  start date
  * event_endDate [DATE]  event's end date
  * event_regStart [DATE]  registration starts
  * event_regEnd [DATE]  event registration ends
  * event_website [STRING]  event website
  * event_emailConfirmText [STRING]  email confirmation text
  * event_basePrice [STRING]  base price for the event
  * event_deposit [INTEGER]  deposit req'd
  * event_contactEmail [STRING]  contact email
  * event_pricingText [STRING]  pricing text
  */
 $Event = new RowManager_EventManager();
 $Event->dropTable();
 $Event->createTable();
 /*
  * FieldType Table
  *
  * Manages field type information
  *
  * fieldtypes_id [INTEGER]  ID for field type
  * fieldtypes_desc [STRING]  Description of field type
  */
 $FieldType = new RowManager_FieldTypeManager();
 $FieldType->dropTable();
 $FieldType->createTable();
 /*
  * PriceRuleType Table
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     $regSummaries = new RegSummaryTools();
     // 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();
     $event = new RowManager_EventManager($this->event_id);
     $this->labels->setLabelTag('[Instr]', '[eventName]', $event->getEventName());
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // pass in the labels for the outer template
     //		$labels = new MultiLingual_Labels( GPC_SITE_LABEL, GPC_SERIES_LABEL, TEMPLATE_PAGE, $langID );
     //		$page->set('labels', $labels );
     // get privileges for the current viewer
     $privManager = new PrivilegeManager($this->viewer->getID());
     if ($privManager->isEventAdmin($this->event_id) == true) {
         $this->template->set('isEventAdmin', true);
         // display messages based on balance owing recalculation status
         switch ($this->recalcStatus) {
             // display balance owing recalculation COMPLETED message
             case FinancialTools::RECALC_COMPLETE:
                 $this->template->set('isRecalculated', true);
                 $completedMsg = $this->labels->getLabel('[RecalcCompleteMsg]');
                 $this->template->set('recalcMessage', $completedMsg);
                 break;
                 // display balance owing recalculation NEEDED message
             // display balance owing recalculation NEEDED message
             case FinancialTools::RECALC_NEEDED:
                 $this->template->set('needsRecalculation', true);
                 $completedMsg = $this->labels->getLabel('[RecalcNeededMsg]');
                 $this->template->set('recalcMessage', $completedMsg);
                 break;
             default:
                 break;
         }
     }
     $this->template->set('backLink', $this->linkValues['BackLink']);
     //$superAdminPrefix = 'superAdmin_';
     //$this->template->set('superAdminPrefix', $superAdminPrefix );
     $superAdminLevelLinks = array();
     $campusLevelLinks = array();
     $eventLevelLinks = array();
     $financeLevelLinks = array();
     if ($privManager->isSuperAdmin() == true) {
         $this->template->set('isSuperAdmin', true);
         //Super Admin Level links (order is important == viewing order)
         $superAdminLevelLinks['AddSuperAdmins'] = $this->linkValues['AddSuperAdmins'];
         $superAdminLevelLinks['EditPrivilegeTypes'] = $this->linkValues['EditPrivilegeTypes'];
         $superAdminLevelLinks['EditFieldTypes'] = $this->linkValues['EditFieldTypes'];
         $superAdminLevelLinks['EditPriceRuleTypes'] = $this->linkValues['EditPriceRuleTypes'];
         $superAdminLevelLinks['EditCreditCardTypes'] = $this->linkValues['EditCreditCardTypes'];
         $superAdminLevelLinks['EditStatusTypes'] = $this->linkValues['EditStatusTypes'];
         $this->template->set('superAdminLevelLinks', $superAdminLevelLinks);
     }
     //Campus Level links
     /** TODO: move the below code into an earlier page and pass on priv. info OR put in helper function ***/
     /** ALSO: make use of this or similar code for restricting access to campus-level registrations **/
     /** CHECK PRIVILEGE LEVEL IN ORDER TO DETERMINE WHICH CAMPUS REGISTRATION LINKS TO SHOW **/
     //         $viewer_id = $this->viewer->getViewerID();
     //         $accessAll = false;
     //         $accessCampuses = array();
     //
     //         $superAdmin = new RowManager_SuperAdminAssignmentManager();
     //         $superAdmin->setViewerID($viewer_id);
     //         $superAdminList = new ListIterator($superAdmin);
     //   		  $superAdminArray = $superAdminList->getDropListArray();
     // //     		echo "super: <pre>".print_r($superAdminArray, true)."</pre>";
     //
     // 			// all campuses can be accessed if user/viewer is super-admin
     //         if (count($superAdminArray) > 0)
     //         {
     // 	        $accessAll = true;
     //         }
     //         else	// check if viewer is finance-level, event-level, or campus-level admin
     //         {
     // 	        // TODO: retrieve these constants from the database using PrivilegeTypeManager
     // 	         $EVENT_LEVEL = 3;
     // 	         $FINANCE_LEVEL = 2;
     // 	         $CAMPUS_LEVEL = 4;
     //
     // 	         $eventAdmin = new RowManager_EventAdminAssignmentManager();
     //         		$eventAdmin->setEventID($this->event_id);
     //         		$eventAdmin->setViewerID($viewer_id);
     //         		$eventAdmin->setPrivilege($EVENT_LEVEL." or ".$FINANCE_LEVEL);
     //         		$eventAdminList = new ListIterator($eventAdmin);
     //         		$eventAdminArray = $eventAdminList->getDropListArray();
     // //        		echo "eventAdmin: <pre>".print_r($eventAdminArray, true)."</pre>";
     // 				// grant access to all campuses if viewer is event-level or finance-level admin
     //         		if (count($eventAdminArray) < 0)
     //         		{
     // 	        		$accessAll = true;
     //   				}
     //   				else 	// TODO: retrieve campus list if viewer has campus-level admin privileges
     //   				{
     // 	  				$eventAdmin2 = new RowManager_EventAdminAssignmentManager();
     // 	        		$eventAdmin2->setEventID($this->event_id);
     // 	        		$eventAdmin2->setViewerID($viewer_id);
     // 	  				$eventAdmin2->setPrivilege($CAMPUS_LEVEL);
     // 	        		$eventAdminList2 = new ListIterator($eventAdmin2);
     // 	        		$eventAdminArray2 = $eventAdminList2->getDropListArray();
     // //	        		echo "eventAdmin2: <pre>".print_r($eventAdminArray2, true)."</pre>";
     //         		}
     //
     //       	}
     /** END PRIVILEGE CHECKING **/
     //       	$is_campus_admin = false;
     if ($privManager->isBasicAdmin($this->event_id) == true) {
         $this->template->set('isCampusAdmin', true);
         /** RETRIEVE CAMPUS REGISTRATION SUMMARY DATA ***/
         //TODO?: put some/all of this into a helper method
         // initialized template arrays
         $campusLevelLinks = array();
         $summaryTotals = array();
         $summaryTotals['numMales'] = 0;
         $summaryTotals['numFemales'] = 0;
         $summaryTotals['campusTotal'] = 0;
         $summaryTotals['cancellations'] = 0;
         // get all campuses
         $campuses = new RowManager_CampusManager();
         $campuses->setSortOrder('campus_desc');
         $campusList = $campuses->getListIterator();
         $campusArray = $campusList->getDataList();
         reset($campusArray);
         // 	     		echo 'campus array = <pre>'.print_r($campusArray,true).'</pre>';
         // retrieve cancellations (for current event)
         $results_cancelled = array();
         $results_cancelled = $regSummaries->getCampusRegistrations($this->event_id, '', true);
         // retrieve total registrations and total females registered (for current event)
         $results = array();
         $results_female = array();
         $results = $regSummaries->getCampusRegistrations($this->event_id, '');
         $results_female = $regSummaries->getCampusRegistrations($this->event_id, 'female');
         // retrieve total complete registrations and total incomplete registrations (for current event)
         $results_complete = array();
         $results_incomplete = array();
         $results_complete = $regSummaries->getCampusRegistrations($this->event_id, '', false, '', '', RowManager_RegistrationManager::STATUS_REGISTERED);
         $results_incomplete = $regSummaries->getCampusRegistrations($this->event_id, '', false, '', '', RowManager_RegistrationManager::STATUS_INCOMPLETE);
         //      	 $results = array_merge( $results_male, $results_female );
         reset($results);
         //      	 reset($results_male);
         //      	 reset($results_female);
         // go through total registrations in parallel with other results
         foreach (array_keys($campusArray) as $k) {
             $total = current($results);
             $regCampusID = key($results);
             $campusID = key($campusArray);
             //key($results);
             // retrieve campus name given the campus ID
             $campus = new RowManager_CampusManager($campusID);
             $campusName = $campus->getDesc();
             // process registration total if it matches the current campus ID
             if ($regCampusID == $campusID) {
                 // set total valid non-cancelled registrations for current campus (and event)
                 if (isset($results_cancelled[$campusID])) {
                     $cancelled = $results_cancelled[$campusID];
                     // 							$total = $total - $cancelled;
                 } else {
                     $cancelled = 0;
                 }
                 // set total females registered for current campus (and event)
                 if (isset($results_female[$campusID])) {
                     $females = $results_female[$campusID];
                 } else {
                     $females = 0;
                 }
                 // set total complete registrations for current campus (and event)
                 if (isset($results_complete[$campusID])) {
                     $completes = $results_complete[$campusID];
                 } else {
                     $completes = 0;
                 }
                 // set total incomplete registrations for current campus (and event)
                 if (isset($results_incomplete[$campusID])) {
                     $incompletes = $results_incomplete[$campusID];
                 } else {
                     $incompletes = 0;
                 }
                 //				$females = current($results_female);
                 //				$males = $results_male[$campusName];
                 // set total registered males
                 $males = $total - $females;
                 //current($results_male);//
                 //        		echo $campusName.': '.$total.' : '.$males.' : '.$females.'<br>';
                 //        		echo 'cancelled : '.$cancelled.'<br>';
                 // set registration summary values for current campus
                 $aCampus = array();
                 $aCampus['campus_desc'] = $campusName;
                 $aCampus['regLink'] = '#';
                 //$this->linkValues[ 'CampusLink' ].$campusID;//$this->event_id."_".$campusID;
                 $aCampus['numMales'] = $males;
                 $aCampus['numFemales'] = $females;
                 $aCampus['campusTotal'] = $total;
                 $aCampus['cancellations'] = $cancelled;
                 $aCampus['completes'] = $completes;
                 $aCampus['incompletes'] = $incompletes;
                 // 		        		$summaryTotals['numMales'] += $males;
                 // 		        		$summaryTotals['numFemales'] += $females;
                 // 		        		$summaryTotals['campusTotal'] += $total;
                 // 		        		$summaryTotals['cancellations'] += $cancelled;
                 next($results);
                 // increment array-pointer for registration totals array
             } else {
                 // set registration summary values for current campus
                 $aCampus = array();
                 $aCampus['campus_desc'] = $campusName;
                 $aCampus['regLink'] = '#';
                 //$this->linkValues[ 'CampusLink' ].$campusID;//$this->event_id."_".$campusID;
                 $aCampus['numMales'] = 0;
                 $aCampus['numFemales'] = 0;
                 $aCampus['campusTotal'] = 0;
                 $aCampus['cancellations'] = 0;
                 $aCampus['completes'] = 0;
                 $aCampus['incompletes'] = 0;
             }
             //       		        $editLink = $this->getCallBack( modulecim_reg::PAGE_ADMINEVENTHOME, $this->sortBy, $parameters );
             //       $editLink .= "&". modulecim_reg::REG_ID . "=";
             //       CampusLink
             if ($privManager->isCampusAdmin($this->event_id, $campusID) == true) {
                 $aCampus['regLink'] = $this->linkValues['CampusLink'] . $campusID;
                 //$this->event_id."_".$campusID;
             }
             // <START> USED TO BE INSIDE CAMPUS ADMIN PRIV. CHECK
             // BUT NOW ALL CAMPUS ADMINS CAN SEE SUMMARY DATA... ONLY REGISTRATION LINKS NOT SHOWN FOR INVALID CAMPUSES
             // store campus summary info in array indexed by campus name
             $campusLevelLinks[$campusName] = $aCampus;
             // 	        		if ($is_campus_admin == false) {
             // 		        		$this->template->set('isCampusAdmin', true);
             // 		        		$is_campus_admin = true;
             // 	        		}
             // <END>
             next($campusArray);
             //				next($results_female);
             //				next($results_male);
         }
         /*** END CAMPUS REGISTRATION SUMMARY DATA RETRIEVAL ***/
         $this->template->set('linkText', 'Registrations');
         $this->template->set('campusLevelLinks', $campusLevelLinks);
         /**** SET TOTAL  *UNIQUE*  REGISTRATIONS *******/
         $totalRegs = array();
         $totalRegs = $regSummaries->getUniqueRegistrations($this->event_id);
         // 				echo "Total unique regs: ".count($totalRegs);
         $femaleRegs = array();
         $gender = 'female';
         $femaleRegs = $regSummaries->getUniqueRegistrations($this->event_id, $gender);
         // 				echo "<br>Total male regs: ".(count($totalRegs)-count($femaleRegs));
         // 				echo "<br>Total female regs: ".count($femaleRegs);
         $cancelledRegs = array();
         $gender = '';
         $areCancelled = true;
         $cancelledRegs = $regSummaries->getUniqueRegistrations($this->event_id, $gender, $areCancelled);
         // 				echo "<br>Total cancelled regs: ".count($cancelledRegs);
         $completeRegs = array();
         $gender = '';
         $areCancelled = false;
         $status = RowManager_RegistrationManager::STATUS_REGISTERED;
         $completeRegs = $regSummaries->getUniqueRegistrations($this->event_id, $gender, $areCancelled, $status);
         $incompleteRegs = array();
         $gender = '';
         $areCancelled = false;
         $status = RowManager_RegistrationManager::STATUS_INCOMPLETE;
         $incompleteRegs = $regSummaries->getUniqueRegistrations($this->event_id, $gender, $areCancelled, $status);
         $summaryTotals['numMales'] = count($totalRegs) - count($femaleRegs);
         $summaryTotals['numFemales'] = count($femaleRegs);
         $summaryTotals['campusTotal'] = count($totalRegs);
         $summaryTotals['cancellations'] = count($cancelledRegs);
         $summaryTotals['completes'] = count($completeRegs);
         $summaryTotals['incompletes'] = count($incompleteRegs);
         $this->template->set('summaryTotals', $summaryTotals);
     }
     if ($privManager->isEventAdmin($this->event_id) == true) {
         //Event Level links
         $eventLevelLinks['AddEventAdmins'] = $this->linkValues['AddEventAdmins'];
         $eventLevelLinks['AddCampusAdmins'] = $this->linkValues['AddCampusAdmins'];
         $eventLevelLinks['RecalculateBalances'] = $this->linkValues['RecalculateBalances'];
         $eventLevelLinks['EditEventDetails'] = $this->linkValues['EditEventDetails'];
         $eventLevelLinks['EditEventFormFields'] = $this->linkValues['EditEventFormFields'];
         $eventLevelLinks['EditEventPriceRules'] = $this->linkValues['EditEventPriceRules'];
         $eventLevelLinks['EventDataDump'] = $this->linkValues['EventDataDump'];
         $eventLevelLinks['EventScholarshipList'] = $this->linkValues['EventScholarshipList'];
         $this->template->set('eventLevelLinks', $eventLevelLinks);
         //$editEventDetailsLink = $this->linkValues[ 'editEventDetailsLink' ];
         //$this->template->set('editEventDetailsLink', $editEventDetailsLink );
     }
     if ($privManager->isFinanceAdmin($this->event_id) == true) {
         $this->template->set('isFinanceAdmin', true);
         //Finance Level links
     }
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_AdminEventHome.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
 /**
  * function loadSideBar
  * <pre>
  * Choosses .
  * </pre>
  * @return [void]
  */
 function loadSideBar()
 {
     $regStatus = RowManager_RegistrationManager::STATUS_INCOMPLETE;
     // get privileges for the current viewer
     $privManager = new PrivilegeManager($this->viewer->getID());
     // students allowed to see sidebar for sign-up process
     if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP || $privManager->isCampusAdmin($this->EVENT_ID, $this->CAMPUS_ID) == true) {
         //         $parameters['PERSON_ID'] = $personID;
         // find registration ID using person id and event_id
         //if ((!isset($this->REG_ID))||$this->REG_ID='')
         //{
         if (isset($this->PERSON_ID) && $this->PERSON_ID != '' && (isset($this->EVENT_ID) && $this->EVENT_ID != '')) {
             // get registration ID for the rest of the reg. process
             $regs = new RowManager_RegistrationManager();
             $people = new RowManager_PersonManager();
             $people->setPersonID($this->PERSON_ID);
             $events = new RowManager_EventManager();
             $events->setEventID($this->EVENT_ID);
             $personRegs = new MultiTableManager();
             $personRegs->addRowManager($regs);
             $personRegs->addRowManager($people, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID()));
             $personRegs->addRowManager($events, new JoinPair($regs->getJoinOnEventID(), $events->getJoinOnEventID()));
             $regsList = $personRegs->getListIterator();
             $regsArray = $regsList->getDataList();
             // 		        echo "<pre>".print_r($regsArray,true)."</pre>";
             reset($regsArray);
             foreach (array_keys($regsArray) as $k) {
                 $registration = current($regsArray);
                 $this->REG_ID = $registration['registration_id'];
                 // NOTE: should only be one reg. per person per event (ENFORCE??)
                 $regStatus = $registration['registration_status'];
                 next($regsArray);
             }
         }
         //}
         $regCompleted = false;
         if ($regStatus == RowManager_RegistrationManager::STATUS_REGISTERED) {
             $regCompleted = true;
         }
         $this->sideBar = new obj_RegProcessSideBar($this->moduleRootPath, $this->viewer, $regCompleted);
         //, $isNewRegistrant );
         $links = array();
         //         $adminLinks = array();
         //         $campusLevelLinks = array();
         $parameters = array();
         $parameters = array('MINISTRY_ID' => $this->MINISTRY_ID, 'IS_IN_REG_PROCESS' => $this->IS_IN_REG_PROCESS, 'EVENT_ID' => $this->EVENT_ID, 'REG_ID' => $this->REG_ID, 'PERSON_ID' => $this->PERSON_ID, 'CAMPUS_ID' => $this->CAMPUS_ID, 'PRIV_ID' => $this->PRIV_ID);
         //[RAD_CALLBACK_PARAMS]
         // 'PROVINCE_ID'=>$this->PROVINCE_ID, 'GENDER_ID'=>$this->GENDER_ID, 'STAFF_ID'=>$this->STAFF_ID, 'USER_ID'=>$this->USER_ID, 'ASSIGNMENT_ID'=>$this->ASSIGNMENT_ID, 'ADMIN_ID'=>$this->ADMIN_ID, 'CAMPUSADMIN_ID'=>$this->CAMPUSADMIN_ID
         // echo print_r($parameters,true);
         // GROUP 1: EVERYONE.
         // ALL viewers can access these links
         if ($regStatus == RowManager_RegistrationManager::STATUS_REGISTERED && $this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP) {
             $requestLink = $this->getCallBack(modulecim_reg::PAGE_CONFIRMCANCELREGISTRATION, '', $parameters);
             $links['[RegCancel]'] = $requestLink;
         }
         $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITPERSONALINFO, '', $parameters);
         $links['[editMyInfo]'] = $requestLink;
         // need to know if registration process requires new registrant personal info
         // since this means side-bar cannot have future registration step links yet
         if (isset($this->PERSON_ID) && $this->PERSON_ID == -1) {
             // show only first link
         } else {
             $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITCAMPUSASSIGNMENT, '', $parameters);
             $links['[editCampusInfo]'] = $requestLink;
             $requestLink = $this->getCallBack(modulecim_reg::PAGE_EDITFIELDVALUES, '', $parameters);
             $links['[editFieldValues]'] = $requestLink;
             $requestLink = $this->getCallBack(modulecim_reg::PAGE_PROCESSFINANCIALTRANSACTIONS, '', $parameters);
             $links['[processFinances]'] = $requestLink;
         }
         /***	       
         	        if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_SIGNUP)
         	        {
         		        $requestLink = $this->getCallBack( modulecim_reg::PAGE_REG_HOME, '' , $parameters);
         		        $links[ '[backToEventList]' ] = $requestLink; 
         	        }
         	        else if ($this->IS_IN_REG_PROCESS == modulecim_reg::IS_OFFLINE_REG)
         	        {
         		        $requestLink = $this->getCallBack( modulecim_reg::PAGE_EDITCAMPUSREGISTRATIONS, '' , $parameters);
         		        $links[ '[backToRegList]' ] = $requestLink;                 
         	        }
         ****/
         //         // GROUP 2: CAMPUS ADMINS AND ABOVE ONLY.
         //         if ( ( $this->accessPrivManager->hasSitePriv() ) || ( $this->accessPrivManager->hasCampusPriv() ) ){
         //           //$requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PEOPLE );
         //           //$campusLevelLinks[ '[PeopleList]' ] = $requestLink;
         //           // TODO if you have 'hrdb campus' group access rights you can see these
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PEOPLEBYCAMPUSES );
         //           $campusLevelLinks[ '[PeopleByCampuses]' ] = $requestLink;
         //         }
         //         // GROUP 3: SUPER ADMINS ONLY.
         //         if ( $this->accessPrivManager->hasSitePriv()){
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_CAMPUSES );
         //           $adminLinks[ '[editCampuses]' ] = $requestLink;
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PROVINCES );
         //           $adminLinks[ '[editProvinces]' ] = $requestLink;
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PRIVILEGES );
         //           $adminLinks[ '[editPrivileges]' ] = $requestLink;
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_STAFF );
         //           $adminLinks[ '[Staff]' ] = $requestLink;
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_ADMINS );
         //           $adminLinks[ '[Admins]' ] = $requestLink;
         //
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENT );
         //           $adminLinks[ '[CampusAssignments]' ] = $requestLink;
         //           $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENTSTATUSTYPES );
         //           $adminLinks[ '[AssignStatusTypes]' ] = $requestLink;
         //
         //         }
         // pass the links to the sidebar object
         $this->sideBar->setLinks($links);
         //         $this->sideBar->setAdminLinks( $adminLinks );
         //         $this->sideBar->setCampusLevelLinks( $campusLevelLinks );
     }
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // 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 calcBalanceOwing
  * <pre>
  * calculates the balance owed by the person linked to a particular registration
  * </pre>
  * @param $registrant_id [INTEGER] The unique id of the registration we are dealing with.
  * @return [INTEGER] the balance owing by the registrant
  */
 function simpleCalcBalanceOwing($registrant_id, $eventID = '', $campusID = '')
 {
     // variables to fill with data
     $eventBasePrice = '';
     $priceRulesArray = array();
     // 	  $rulesApplied = array();
     if ($eventID == '') {
         /** retrieve event ID from registration(s) array   **/
         $registration = new RowManager_RegistrationManager();
         $registration->setRegID($registrant_id);
         $regsManager = $registration->getListIterator();
         $regsArray = $regsManager->getDataList();
         //     	echo "<pre>".print_r($regEventsArray,true)."</pre>";
         //NOTE: should be only one record in array
         reset($regsArray);
         $result = current($regsArray);
         $eventID = $result['event_id'];
         //     echo 'eventID = '.$eventID;
     }
     if ($campusID == '') {
         /** Retrieve campus registration data for single registration **/
         $summaryTool = new RegSummaryTools();
         $regInfo = array();
         $regInfo = $summaryTool->getCampusRegistrations($eventID, '', false, '', $registrant_id);
         //NOTE: should be only one key-value pair
         reset($regInfo);
         $campusID = key($regInfo);
         // since key = campusID and value = total of registrations for that campus
         //     echo 'campusID = '.$campusID;
     }
     /** Retrieve event base price **/
     $event = new RowManager_EventManager($eventID);
     $eventBasePrice = $event->getEventBasePrice();
     /** Retrieve price rules array **/
     $priceRules = new RowManager_PriceRuleManager();
     $priceRules->setEventID($eventID);
     $ruleManager = $priceRules->getListIterator();
     $priceRulesArray = $ruleManager->getDataList();
     $balanceOwing = 0;
     /** Use found data to retrieve base price for the $registrant_id parameter **/
     $balanceOwing = $this->getBasePriceForRegistrant($registrant_id, $eventID, $campusID, $eventBasePrice, $priceRulesArray);
     $basePrice = $balanceOwing;
     //	  echo '0) original cost = '.$balanceOwing.'<br>';
     //	  echo "<pre>".print_r($rulesApplied,true)."</pre>";
     /** Search for scholarships **/
     $scholarships = array();
     $scholarships = $this->getScholarships($registrant_id);
     //	  echo "<pre>".print_r($scholarships,true)."</pre>";
     /** Retrieve cash transactions **/
     $cash_transactions = array();
     $cash_transactions = $this->getCashTransactions($registrant_id);
     /** Retrieve credit card transactions **/
     $cc_transactions = array();
     $cc_transactions = $this->getCCTransactions($registrant_id);
     /** Calculate amount still owing **/
     // subtract scholarship money from total owing
     $refund = array();
     reset($scholarships);
     foreach (array_keys($scholarships) as $k) {
         $refund = current($scholarships);
         $balanceOwing -= $refund['scholarship_amount'];
         // 			echo '1) new amount = '.$balanceOwing.'<br>';
         next($scholarships);
     }
     // subtract cash transactions received
     $cash_paid = array();
     $cashReceived = 0;
     $cashOwed = 0;
     reset($cash_transactions);
     foreach (array_keys($cash_transactions) as $k) {
         $cash_paid = current($cash_transactions);
         if ($cash_paid['cashtransaction_recd'] == 1) {
             $balanceOwing -= $cash_paid['cashtransaction_amtPaid'];
         }
         // 			echo '2) new amount = '.$balanceOwing.'<br>';
         next($cash_transactions);
     }
     // subtract credit card transactions processed
     $cc_paid = array();
     $ccReceived = 0;
     $ccOwed = 0;
     reset($cc_transactions);
     foreach (array_keys($cc_transactions) as $k) {
         $cc_paid = current($cc_transactions);
         if ($cc_paid['cctransaction_processed'] == 1) {
             $balanceOwing -= $cc_paid['cctransaction_amount'];
         }
         // 			echo '3) new amount = '.$balanceOwing.'<br><br>';
         next($cc_transactions);
     }
     return $balanceOwing;
 }
 protected function getFieldValuesArray($regID = '', $personID = '', $eventID = '')
 {
     $FALSE = 0;
     $fields = new RowManager_FieldManager();
     $fvalues = new RowManager_FieldValueManager();
     $ftypes = new RowManager_FieldTypeManager();
     // 		 echo "personID = ".$personID;
     // 		 echo "eventID = ".$eventID;
     if ($regID != '') {
         //$fields->setEventID($eventID);
         $fvalues->setRegID($regID);
     } else {
         if ($eventID != '' && $personID != '') {
             $registrations = new RowManager_RegistrationManager();
             // 		    $registrations->setRegID($regID);
             $person = new RowManager_PersonManager();
             $person->setPersonID($personID);
             $event = new RowManager_EventManager();
             $event->setEventID($eventID);
             $personReg = new MultiTableManager();
             $personReg->addRowManager($registrations);
             $personReg->addRowManager($person, new JoinPair($registrations->getJoinOnPersonID(), $person->getJoinOnPersonID()));
             $personReg->addRowManager($event, new JoinPair($registrations->getJoinOnEventID(), $event->getJoinOnEventID()));
             $valIterator = $personReg->getListIterator();
             $valArray = $valIterator->getDataList();
             // go through results and store field types
             reset($valArray);
             foreach (array_keys($valArray) as $k) {
                 $regValue = current($valArray);
                 $regID = $regValue['registration_id'];
                 //NOTE: assumes only 1 registration per person per event
                 next($valArray);
             }
             // 			$fields->setEventID($eventID);
             $fvalues->setRegID($regID);
         }
     }
     //	    $fvalues->setSortByFieldID();
     $fieldInfo = new MultiTableManager();
     $fieldInfo->addRowManager($fields);
     $fieldInfo->addRowManager($fvalues, new JoinPair($fvalues->getJoinOnFieldID(), $fields->getJoinOnFieldID()));
     $fieldInfo->addRowManager($ftypes, new JoinPair($fields->getJoinOnFieldTypeID(), $ftypes->getJoinOnFieldTypeID()));
     if ($this->show_hidden == false) {
         $fieldInfo->constructSearchCondition('fields_hidden', '=', $FALSE, true);
     }
     $fieldInfo->setSortOrder('fields_priority');
     $valuesIterator = $fieldInfo->getListIterator();
     $valuesArray = $valuesIterator->getDataList();
     //        echo "field values:<br><pre>".print_r($valuesArray,true)."</pre>";
     // store field ids associated with values already in database
     $initializedFieldIds = array_keys($valuesArray);
     // since each field value is located in a DB row the result array has several arrays - one per field value
     // need to extract each field value and store it as a non-array record in a result array
     $fieldValues = array();
     $idx = 0;
     /** Go through all event fields and map each to existing field value, otherwise create new field value record **/
     $fieldsArray = array_values($this->formFieldToFieldIDmapper);
     // store field IDs (ASSUMES formFieldToFieldIDmapper is initialized)
     //         echo 'fieldsArray = <pre>'.print_r($fieldsArray,true).'</pre>';
     reset($fieldsArray);
     reset($valuesArray);
     foreach (array_keys($fieldsArray) as $k) {
         $fieldID = current($fieldsArray);
         $form_value = '';
         // default blank field value if none found
         $form_value_id = -1;
         // to be replaced with existing or newly-created field values ID
         if (in_array($fieldID, $initializedFieldIds) == true) {
             $record = $valuesArray[$fieldID];
             $form_value = $record['fieldvalues_value'];
             $form_value_id = $record['fieldvalues_id'];
         } else {
             $updateValues = array();
             $updateValues['fields_id'] = $fieldID;
             $updateValues['fieldvalues_value'] = $form_value;
             $updateValues['registration_id'] = $regID;
             $fieldvalues_manager = new RowManager_FieldValueManager();
             // store values in table manager object.
             $fieldvalues_manager->loadFromArray($updateValues);
             // now update the DB with the values
             if (!$fieldvalues_manager->isLoaded()) {
                 $fieldvalues_manager->createNewEntry(true);
                 $form_value_id = $fieldvalues_manager->getID();
             }
         }
         $fieldValues['form_field' . $idx] = $form_value;
         // store mapping associating form field label with fieldvalues_id
         $this->formFieldToValueIDmapper['form_field' . $idx] = $form_value_id;
         next($fieldsArray);
         $idx++;
     }
     // 			echo 'labels-values = <pre>'.print_r($this->formFieldToValueIDmapper,true).'</pre>';
     // 			echo 'labels-fields = <pre>'.print_r($this->formFieldToFieldIDmapper,true).'</pre>';
     return $fieldValues;
 }
 function getEventDeposit()
 {
     if (isset($this->event_id)) {
         $event = new RowManager_EventManager();
         $event->setEventID($this->event_id);
         $eventList = $event->getListIterator();
         $eventArray = $eventList->getDataList();
         $deposit = '';
         reset($eventArray);
         foreach (array_keys($eventArray) as $k) {
             $record = current($eventArray);
             $deposit = $record['event_deposit'];
             next($eventArray);
         }
         return $deposit;
     } else {
         return "TO BE DETERMINED";
     }
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     $regSummaries = new RegSummaryTools();
     // 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();
     $event = new RowManager_EventManager($this->event_id);
     $this->labels->setLabelTag('[Instr]', '[eventName]', $event->getEventName());
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // pass in the labels for the outer template
     //		$labels = new MultiLingual_Labels( GPC_SITE_LABEL, GPC_SERIES_LABEL, TEMPLATE_PAGE, $langID );
     //		$page->set('labels', $labels );
     // get privileges for the current viewer
     $privManager = new PrivilegeManager($this->viewer->getID());
     if ($privManager->isEventAdmin($this->event_id) == true) {
         $this->template->set('isEventAdmin', true);
         // display messages based on balance owing recalculation status
         switch ($this->recalcStatus) {
             // display balance owing recalculation COMPLETED message
             case FinancialTools::RECALC_COMPLETE:
                 $this->template->set('isRecalculated', true);
                 $completedMsg = $this->labels->getLabel('[RecalcCompleteMsg]');
                 $this->template->set('recalcMessage', $completedMsg);
                 break;
                 // display balance owing recalculation NEEDED message
             // display balance owing recalculation NEEDED message
             case FinancialTools::RECALC_NEEDED:
                 $this->template->set('needsRecalculation', true);
                 $completedMsg = $this->labels->getLabel('[RecalcNeededMsg]');
                 $this->template->set('recalcMessage', $completedMsg);
                 break;
             default:
                 break;
         }
     }
     $this->template->set('backLink', $this->linkValues['BackLink']);
     //$superAdminPrefix = 'superAdmin_';
     //$this->template->set('superAdminPrefix', $superAdminPrefix );
     $superAdminLevelLinks = array();
     $campusLevelLinks = array();
     $eventLevelLinks = array();
     $financeLevelLinks = array();
     if ($privManager->isSuperAdmin() == true) {
         $this->template->set('isSuperAdmin', true);
         //Super Admin Level links (order is important == viewing order)
         $superAdminLevelLinks['AddSuperAdmins'] = $this->linkValues['AddSuperAdmins'];
         $superAdminLevelLinks['EditPrivilegeTypes'] = $this->linkValues['EditPrivilegeTypes'];
         $superAdminLevelLinks['EditFieldTypes'] = $this->linkValues['EditFieldTypes'];
         $superAdminLevelLinks['EditPriceRuleTypes'] = $this->linkValues['EditPriceRuleTypes'];
         $superAdminLevelLinks['EditCreditCardTypes'] = $this->linkValues['EditCreditCardTypes'];
         $superAdminLevelLinks['EditStatusTypes'] = $this->linkValues['EditStatusTypes'];
         $this->template->set('superAdminLevelLinks', $superAdminLevelLinks);
     }
     //Campus Level links
     /** TODO: move the below code into an earlier page and pass on priv. info OR put in helper function ***/
     /** ALSO: make use of this or similar code for restricting access to campus-level registrations **/
     /** CHECK PRIVILEGE LEVEL IN ORDER TO DETERMINE WHICH CAMPUS REGISTRATION LINKS TO SHOW **/
     //         $viewer_id = $this->viewer->getViewerID();
     //         $accessAll = false;
     //         $accessCampuses = array();
     //
     //         $superAdmin = new RowManager_SuperAdminAssignmentManager();
     //         $superAdmin->setViewerID($viewer_id);
     //         $superAdminList = new ListIterator($superAdmin);
     //   		  $superAdminArray = $superAdminList->getDropListArray();
     // //     		echo "super: <pre>".print_r($superAdminArray, true)."</pre>";
     //
     // 			// all campuses can be accessed if user/viewer is super-admin
     //         if (count($superAdminArray) > 0)
     //         {
     // 	        $accessAll = true;
     //         }
     //         else	// check if viewer is finance-level, event-level, or campus-level admin
     //         {
     // 	        // TODO: retrieve these constants from the database using PrivilegeTypeManager
     // 	         $EVENT_LEVEL = 3;
     // 	         $FINANCE_LEVEL = 2;
     // 	         $CAMPUS_LEVEL = 4;
     //
     // 	         $eventAdmin = new RowManager_EventAdminAssignmentManager();
     //         		$eventAdmin->setEventID($this->event_id);
     //         		$eventAdmin->setViewerID($viewer_id);
     //         		$eventAdmin->setPrivilege($EVENT_LEVEL." or ".$FINANCE_LEVEL);
     //         		$eventAdminList = new ListIterator($eventAdmin);
     //         		$eventAdminArray = $eventAdminList->getDropListArray();
     // //        		echo "eventAdmin: <pre>".print_r($eventAdminArray, true)."</pre>";
     // 				// grant access to all campuses if viewer is event-level or finance-level admin
     //         		if (count($eventAdminArray) < 0)
     //         		{
     // 	        		$accessAll = true;
     //   				}
     //   				else 	// TODO: retrieve campus list if viewer has campus-level admin privileges
     //   				{
     // 	  				$eventAdmin2 = new RowManager_EventAdminAssignmentManager();
     // 	        		$eventAdmin2->setEventID($this->event_id);
     // 	        		$eventAdmin2->setViewerID($viewer_id);
     // 	  				$eventAdmin2->setPrivilege($CAMPUS_LEVEL);
     // 	        		$eventAdminList2 = new ListIterator($eventAdmin2);
     // 	        		$eventAdminArray2 = $eventAdminList2->getDropListArray();
     // //	        		echo "eventAdmin2: <pre>".print_r($eventAdminArray2, true)."</pre>";
     //         		}
     //
     //       	}
     /** END PRIVILEGE CHECKING **/
     //       	$is_campus_admin = false;
     if ($privManager->isBasicAdmin($this->event_id) == true) {
         $this->template->set('isCampusAdmin', true);
         /** HSMIT, Dec 6, 2007: MOVED REG SUMMARY DATA RETRIEVAL TO CONSTRUCTOR **/
         $campusLevelLinks = $this->summary_data;
         /*** END CAMPUS REGISTRATION SUMMARY DATA RETRIEVAL ***/
         $this->template->set('linkText', 'Registrations');
         $this->template->set('campusLevelLinks', $campusLevelLinks);
         /** HSMIT: Dec 13, 2007: MOVED REG SUMMARY TOTALS TO CONSTRUCTOR **/
         $this->template->set('summaryTotals', $this->summaryTotals);
     }
     if ($privManager->isEventAdmin($this->event_id) == true) {
         //Event Level links
         $eventLevelLinks['DownloadSummary'] = $this->linkValues['DownloadSummary'];
         $eventLevelLinks['EmailRegistrants'] = $this->linkValues['EmailRegistrants'];
         $eventLevelLinks['AddEventAdmins'] = $this->linkValues['AddEventAdmins'];
         $eventLevelLinks['AddCampusAdmins'] = $this->linkValues['AddCampusAdmins'];
         $eventLevelLinks['RecalculateBalances'] = $this->linkValues['RecalculateBalances'];
         $eventLevelLinks['EditEventDetails'] = $this->linkValues['EditEventDetails'];
         $eventLevelLinks['EditEventFormFields'] = $this->linkValues['EditEventFormFields'];
         $eventLevelLinks['EditEventPriceRules'] = $this->linkValues['EditEventPriceRules'];
         $eventLevelLinks['EventDataDump'] = $this->linkValues['EventDataDump'];
         $eventLevelLinks['EventScholarshipList'] = $this->linkValues['EventScholarshipList'];
         $this->template->set('eventLevelLinks', $eventLevelLinks);
         //$editEventDetailsLink = $this->linkValues[ 'editEventDetailsLink' ];
         //$this->template->set('editEventDetailsLink', $editEventDetailsLink );
     }
     if ($privManager->isFinanceAdmin($this->event_id) == true) {
         $this->template->set('isFinanceAdmin', true);
         //Finance Level links
     }
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_AdminEventHome.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @param $pageContentHTML [STRING] the html generated by the pageDisplay
  * object.
  * @return [STRING] HTML Display data.
  */
 function getHTML($pageContentHTML)
 {
     // Create a new Template Object
     $this->template = new Template($this->pathModuleRoot . 'templates/');
     // store the page labels
     $this->template->setXML('pageLabels', $this->labels->getLabelXML());
     // display event name (blank if not in event-specific page)
     $event = new RowManager_EventManager($this->event_id);
     $this->template->set('eventName', '<b>' . $event->getEventName() . '</b>');
     // store the pageDisplay object's html
     $this->template->set('pageContent', $pageContentHTML);
     // store the path to root.  Useful for accessing site images and
     // resources.
     $this->template->set('pathToRoot', $this->pathModuleRoot);
     // return the html from the commong display template
     return $this->template->fetch('obj_CommonDisplay.php');
 }