/**
  * 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 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;
 }
示例#3
0
 protected function triggerBalanceRecalculation($eventID)
 {
     $shouldRecalculate = false;
     $volumeRuleTriggered = false;
     $activeRule = null;
     $is_active = RowManager_ActiveRuleManager::IS_FALSE;
     $is_calculated = RowManager_ActiveRuleManager::IS_TRUE;
     $eventPriceRules = new RowManager_PriceRuleManager();
     $eventPriceRules->setEventID($eventID);
     $eventPriceRules->setPriceRuleType(RowManager_PriceRuleTypeManager::VOLUME_RULE);
     $ruleList = $eventPriceRules->getListIterator();
     $ruleArray = $ruleList->getDataList();
     // 	    echo "rules <pre>".print_r($ruleArray,true)."</pre><BR>";
     $ruleIDs = array();
     reset($ruleArray);
     // cycle through volume rules
     foreach (array_keys($ruleArray) as $k) {
         $record = current($ruleArray);
         $volumeNeeded = $record['pricerules_value'];
         // 	    	echo "volume needed = ".$volumeNeeded."<BR>";
         $activeRule = new RowManager_ActiveRuleManager($record['pricerules_id']);
         $is_active = $activeRule->getIsActive();
         $is_calculated = $activeRule->getIsRecalculated();
         // 	    	echo "active, calculated = ".$is_active.", ".$is_calculated."<BR>";
         // if recalculation was not executed previously
         if (isset($is_calculated) && $is_calculated != '' && $is_calculated == RowManager_ActiveRuleManager::IS_FALSE) {
             $shouldRecalculate = true;
             break;
         } else {
             $is_calculated = RowManager_ActiveRuleManager::IS_TRUE;
         }
         if (isset($is_active) && $is_active == '') {
             $is_active = RowManager_ActiveRuleManager::IS_FALSE;
         }
         // get total registrations for the current event
         $totalRegs = 0;
         $total = array();
         $summary = new RegSummaryTools();
         $total = $summary->getCampusRegistrations($eventID, '', false, '', '', RowManager_RegistrationManager::STATUS_REGISTERED);
         // 		    echo "totals <pre>".print_r($total,true)."</pre><BR>";
         reset($total);
         foreach (array_keys($total) as $k) {
             $element = current($total);
             // check if this volume rule is triggered for current campus
             if ($element >= $volumeNeeded) {
                 $volumeRuleTriggered = true;
                 break;
             }
             next($total);
         }
         // 			echo "volume triggered = ".$volumeRuleTriggered;
         // if a volume rule was triggered for the first time
         if ($volumeRuleTriggered == true && $is_active == RowManager_ActiveRuleManager::IS_FALSE) {
             $setRecord = array();
             $setRecord['is_active'] = RowManager_ActiveRuleManager::IS_TRUE;
             $setRecord['is_recalculated'] = RowManager_ActiveRuleManager::IS_FALSE;
             $activeRule->loadFromArray($setRecord);
             $activeRule->updateDBTable();
             $volumeRuleTriggered = false;
             // reset value to default
             $shouldRecalculate = true;
             break;
         } else {
             if ($volumeRuleTriggered == false && $is_active == RowManager_ActiveRuleManager::IS_TRUE) {
                 $setRecord = array();
                 $setRecord['is_active'] = RowManager_ActiveRuleManager::IS_FALSE;
                 $setRecord['is_recalculated'] = RowManager_ActiveRuleManager::IS_FALSE;
                 $activeRule->loadFromArray($setRecord);
                 $activeRule->updateDBTable();
                 $shouldRecalculate = true;
                 break;
             } else {
                 if ($volumeRuleTriggered) {
                     $volumeRuleTriggered = false;
                     // reset value to default
                 } else {
                     // either way, don't need to recalculate
                     // 				$shouldRecalculate = false;			// do NOT set flag to FALSE because it may override setting to TRUE by prev. rule
                 }
             }
         }
         next($ruleArray);
     }
     return $shouldRecalculate;
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $eventID, $recalcStatus = FinancialTools::RECALC_NOTNEEDED, $campus_link = '')
 {
     parent::__construct();
     // initialzie the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->event_id = $eventID;
     $this->recalcStatus = $recalcStatus;
     // get privileges for the current viewer
     $privManager = new PrivilegeManager($this->viewer->getID());
     $regSummaries = new RegSummaryTools();
     //       	$is_campus_admin = false;
     if ($privManager->isBasicAdmin($this->event_id) == true) {
         /** Set the summary data headings (used only for generating PDF) **/
         $this->summary_headings = array();
         $this->summary_headings[0] = 'Campus';
         $this->summary_headings[1] = 'Admin';
         $this->summary_headings[2] = 'Males';
         $this->summary_headings[3] = 'Females';
         $this->summary_headings[4] = 'Total';
         $this->summary_headings[5] = 'Cancellations';
         $this->summary_headings[6] = 'Completed';
         $this->summary_headings[7] = 'Incomplete';
         /** RETRIEVE CAMPUS REGISTRATION SUMMARY DATA ***/
         //TODO?: put some/all of this into a helper method
         // initialized template arrays
         $campusLevelLinks = array();
         $this->summaryTotals = array();
         $this->summaryTotals['label'] = '';
         $this->summaryTotals['blank'] = '';
         // 'Registrations' link has no need for a total...
         $this->summaryTotals['numMales'] = 0;
         $this->summaryTotals['numFemales'] = 0;
         $this->summaryTotals['campusTotal'] = 0;
         $this->summaryTotals['cancellations'] = 0;
         $this->summaryTotals['completes'] = 0;
         $this->summaryTotals['incompletes'] = 0;
         /* Get all campuses (affiliated with the admin's country) */
         // 	     		$campuses = new RowManager_CampusManager();
         // 	     		$campuses->setSortOrder('campus_desc');
         // 	     		$campusList = $campuses->getListIterator();
         // 	     		$campusArray = $campusList->getDataList();
         $country_campuses = new MultiTableManager();
         $events = new RowManager_EventManager();
         $events->setEventID($this->event_id);
         $campuses = new RowManager_CampusManager();
         $regions = new RowManager_RegionManager();
         $countries = new RowManager_CountryManager();
         $country_campuses->addRowManager($campuses);
         $country_campuses->addRowManager($regions, new JoinPair($regions->getJoinOnRegionID(), $campuses->getJoinOnRegionID()));
         $country_campuses->addRowManager($countries, new JoinPair($countries->getJoinOnCountryID(), $regions->getJoinOnCountryID()));
         $country_campuses->addRowManager($events, new JoinPair($events->getJoinOnCountryID(), $countries->getJoinOnCountryID()));
         $country_campuses->setSortOrder('campus_desc');
         $countryList = $country_campuses->getListIterator();
         $campusArray = $countryList->getDataList();
         reset($campusArray);
         // 	     		echo 'campus array = <pre>'.print_r($campusArray,true).'</pre>';
         /** JANUARY 25, 2008    (HSMIT) added $campusList to all getCampusRegistrations() calls below
                                         to match registration campuses with event-affliated country's campus list 
                                         
             ALSO: had to add somewhat redundant pre-processing to get campus list **/
         $campusList = '';
         foreach (array_keys($campusArray) as $key) {
             $record = current($campusArray);
             $campusList .= $record['campus_id'] . ',';
             // populate CSV for registrations filter
             next($campusArray);
         }
         $campusList = substr($campusList, 0, -1);
         reset($campusArray);
         // retrieve cancellations (for current event)
         $results_cancelled = array();
         $results_cancelled = $regSummaries->getCampusRegistrations($this->event_id, '', true, $campusList);
         // retrieve total registrations and total females registered (for current event)
         $results = array();
         $results_female = array();
         $results = $regSummaries->getCampusRegistrations($this->event_id, '', false, $campusList);
         $results_female = $regSummaries->getCampusRegistrations($this->event_id, 'female', false, $campusList);
         // 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, $campusList, '', RowManager_RegistrationManager::STATUS_REGISTERED);
         $results_incomplete = $regSummaries->getCampusRegistrations($this->event_id, '', false, $campusList, '', 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'] = $campus_link . $campusID;
                 // $this->linkValues[ 'CampusLink' ].$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);
         }
         $this->summary_data = $campusLevelLinks;
         /*** END CAMPUS REGISTRATION SUMMARY DATA RETRIEVAL ***/
         /**** 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);
         $this->summaryTotals['label'] = 'Total (Unique) Registrations:';
         $this->summaryTotals['blank'] = '';
         // 'Registrations' link has no need for a total...
         $this->summaryTotals['numMales'] = count($totalRegs) - count($femaleRegs);
         $this->summaryTotals['numFemales'] = count($femaleRegs);
         $this->summaryTotals['campusTotal'] = count($totalRegs);
         $this->summaryTotals['cancellations'] = count($cancelledRegs);
         $this->summaryTotals['completes'] = count($completeRegs);
         $this->summaryTotals['incompletes'] = count($incompleteRegs);
     }
     // 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 = page_AdminEventHome::MULTILINGUAL_PAGE_KEY;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
 }