/** * 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, $formAction, $event_id, $person_id) { parent::__construct(); // initialzie the object values $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->person_id = $person_id; $this->event_id = $event_id; $this->formAction = $formAction; $this->displayFields = page_ConfirmCancelRegistration::DISPLAY_FIELDS; $this->shouldCancel = false; $this->wasSubmitted = false; // create the item Manager to display $regs = new RowManager_RegistrationManager(); $regs->setPersonID($this->person_id); $regs->setEventID($this->event_id); $regList = $regs->getListIterator(); $regArray = $regList->getDataList(); reset($regArray); $record = current($regArray); // should be single record per person per event $this->reg_id = $record['registration_id']; // init. data manager object $this->itemManager = new RowManager_RegistrationManager($this->reg_id); // 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_ConfirmCancelRegistration::MULTILINGUAL_PAGE_KEY; $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey); // then load the page specific labels for this page $this->labels->loadPageLabels($pageKey); // add Site YES/NO labels $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_LIST_YESNO); }
require '../modules/app_cim_reg/objects_da/FieldValueManager.php'; require '../modules/app_cim_reg/objects_da/ScholarshipAssignmentManager.php'; require '../modules/app_cim_reg/objects_da/CashTransactionManager.php'; require '../modules/app_cim_reg/objects_da/CreditCardTransactionManager.php'; $toolName = '../Tools/tools_Finances.php'; $toolPath = ''; //Page::findPathExtension( $toolName ); require_once $toolPath . $toolName; // get privileges for the current viewer $privManager = new PrivilegeManager($this->viewer->getID()); if ($privManager->isCampusAdmin($this->EVENT_ID, $this->CAMPUS_ID) == true) { /********** NOTE: make sure 60 second PHP timeout is not activated: use filters, such as event_id ************/ $EVENT_ID = 18; // retrieve registration records $regs = new RowManager_RegistrationManager(); $regs->setEventID($EVENT_ID); $regsList = $regs->getListIterator(); $regsArray = $regsList->getDataList(); $priceGetter = new FinancialTools(); reset($regsArray); foreach (array_keys($regsArray) as $k) { $record = current($regsArray); $reg_id = $record['registration_id']; $owed = $priceGetter->simpleCalcBalanceOwing($reg_id); // store calculated balance owing in registration record $singleReg = new RowManager_RegistrationManager($reg_id); $balance = array(); $balance['registration_balance'] = $owed; $singleReg->loadFromArray($balance); $singleReg->updateDBTable(); next($regsArray);
/** * function getBasePriceForRegistrant * <pre> * Returns registration cost for a particular registration, not including scholarship discounts * </pre> * Pre-condition: all variables must be initialized with proper values * * @param $regID [INTEGER] registration ID * @param $eventID [INTEGER] event ID * @param $campusID [INTEGER] campus ID (precondition: must be associated directly with registration ID) * @param $eventBasePrice [INTEGER] the cost of the event per registration, before any discounts * @param $priceRulesArray [ARRAY] an array of the price rules applying to event denoted by $eventID * @param &$rulesApplied [ARRAY REFERENCE] reference to an array to be filled with applied rules * @return [INTEGER] $basePriceForThisGuy the new base price for registration $regID (before scholarships) */ function getBasePriceForRegistrant($regID, $eventID, $campusID, $eventBasePrice, $priceRulesArray, &$rulesApplied = array()) { // Need to manually calculate discounts for these exceptions: $BC_SUMMIT_2007 = 19; $MB_SUMMIT_2007 = 22; $LAKESHORE_SUMMIT_2007 = 25; $EASTERN_WC_2007 = 28; $AIA_NATIONAL_TRAINING = 33; $MARITIMES_SUMMIT_2008 = 34; $basePriceForThisGuy = $eventBasePrice; // echo "<pre>".print_r($priceRulesArray,true)."</pre>"; // PUT SPECIAL EVENT EXCEPTIONS HERE AS CONDITIONAL STATEMENTS: /* if ($eventID == $MARITIMES_SUMMIT_2008) { $FROSH_DISCOUNT_FIELD = 119; // first check for Frosh Discount $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if ((isset($userValue))&&($userValue != '')) { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ( $userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 15; // subtract $15 from $65 event base cost $basePriceForThisGuy = 50; // frosh cost $rulesApplied[] = $priceRulesArray['45']; return $basePriceForThisGuy; } } // if no frosh discount, THEN apply early bird discount (if conditions met) // echo "DATE RULE<BR>"; // get the user's registration date $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // $regTime = $registration->getRegistrationDate(); if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if ( strtotime($regTime) < strtotime( '2008-04-01' ) ) //$rule['pricerules_value'] { // date criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 15; // apply early bird discount to $65 event base cost to get $50 $basePriceForThisGuy = 50; $rulesApplied[] = $priceRulesArray['47']; return $basePriceForThisGuy; } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($125) } */ if ($eventID == $AIA_NATIONAL_TRAINING) { $FOOD_PASS_REQ_FIELD = 102; $HOUSING_REQ_FIELD = 103; // first check for Food Pass Fee $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($FOOD_PASS_REQ_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR $FOOD_PASS_REQ_FIELD // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { /** Get the user's registration date **/ $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date-time reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy += 100; // add 150 to base 260 event price $basePriceForThisGuy += 150; $rulesApplied[] = $priceRulesArray['39']; // Apply early-bird discount on this if applicable if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime('2008-04-16')) { $basePriceForThisGuy -= 50; // subtract 50 $rulesApplied[] = $priceRulesArray['42']; } } } } // second check for Housing Fee $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($HOUSING_REQ_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR $HOUSING_REQ_FIELD // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { /** Get the user's registration date **/ $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date-time reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy += 180; // add 230 to base 260 event price $basePriceForThisGuy += 230; $rulesApplied[] = $priceRulesArray['41']; // Apply early-bird discount on this if applicable if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime('2008-04-16')) { $basePriceForThisGuy -= 50; // subtract 50 $rulesApplied[] = $priceRulesArray['42']; } } return $basePriceForThisGuy; } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($125) } if ($eventID == $EASTERN_WC_2007) { $COMMUTER_DISCOUNT_FIELD = 86; // first check for Frosh Discount $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($COMMUTER_DISCOUNT_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 80; // subtract $80 from $279 event base cost $basePriceForThisGuy = 199; // commuter cost $rulesApplied[] = $priceRulesArray['38']; return $basePriceForThisGuy; } } // if no commuter discount, THEN apply early bird discount (if conditions met) // echo "DATE RULE<BR>"; // get the user's registration date $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // $regTime = $registration->getRegistrationDate(); if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime('2007-12-01')) { if (strtotime($regTime) < strtotime('2007-10-09')) { // date criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 50; // apply early bird discounts to $279 event base cost to get $229 $basePriceForThisGuy = 229; $rulesApplied[] = $priceRulesArray['37']; $rulesApplied[] = $priceRulesArray['36']; return $basePriceForThisGuy; } else { // date criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 50; // apply regular discount to $279 event base cost to get $259 $basePriceForThisGuy = 259; $rulesApplied[] = $priceRulesArray['36']; return $basePriceForThisGuy; } } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($125) } // PUT SPECIAL EVENT EXCEPTIONS HERE AS CONDITIONAL STATEMENTS: if ($eventID == $BC_SUMMIT_2007) { $FROSH_DISCOUNT_FIELD = 54; // first check for Frosh Discount $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 46; // subtract $46 from $125 event base cost $basePriceForThisGuy = 79; // frosh cost $rulesApplied[] = $priceRulesArray['14']; return $basePriceForThisGuy; } } // if no frosh discount, THEN apply early bird discount (if conditions met) // echo "DATE RULE<BR>"; // get the user's registration date $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // $regTime = $registration->getRegistrationDate(); if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime('2007-09-21')) { // date criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 26; // apply early bird discount to $125 event base cost to get $99 $basePriceForThisGuy = 99; $rulesApplied[] = $priceRulesArray['15']; return $basePriceForThisGuy; } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($125) } if ($eventID == $MB_SUMMIT_2007) { $FROSH_DISCOUNT_FIELD = 60; $FROSH_VOLUME_THRESHOLD = 20; $MB_EARLY_FROSH_TABLE = 'temp_mb_early_frosh'; // first check for Frosh Discount $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // check if there are 20 or more frosh already stored $froshValues = new RowManager_FieldValueManager(); $froshValues->setFieldID($FROSH_DISCOUNT_FIELD); $froshValues->setFieldValue('1'); // 1 = checked checkbox $fieldsManager = new MultiTableManager(); $fieldsManager->addRowManager($froshValues); // TODO: sub-query like 'SELECT <ALL FIELD VALUES FOR SPECIFIC FROSH DISCOUNT> WHERE REG_ID IN (SELECT ALL REGISTRATIONS FOR EVENT)' $regs = new RowManager_RegistrationManager(); $regs->setEventID($eventID); $regData = new MultiTableManager(); $regData->addRowManager($regs); $regData->setFieldList('registration_id'); $registered_SQL = $regData->createSQL(); // actually creates the sub-query in order to get an accurate count of discount field values stored $negateSubQuery = false; $addSubQuery = true; $fieldsManager->constructSubQuery('registration_id', $registered_SQL, $negateSubQuery, $addSubQuery); // $froshValues->setSortOrder('registration_id'); $froshList = $fieldsManager->getListIterator(); $froshArray = array(); $froshArray = $froshList->getDataList(); // echo "COUNT = ".count($froshArray); if (count($froshArray) <= $FROSH_VOLUME_THRESHOLD) { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 25; // subtract $46 from $125 event base cost $basePriceForThisGuy = 40; // frosh cost $rulesApplied[] = $priceRulesArray['25']; $db = new Database_MySQL(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); // precaution that avoids duplicates $sql = "DELETE FROM " . $MB_EARLY_FROSH_TABLE . " WHERE registration_id = " . $regID; $db->runSQL($sql); $sql = "INSERT INTO " . $MB_EARLY_FROSH_TABLE . " (registration_id) VALUES (" . $regID . ")"; $db->runSQL($sql); } else { $db = new Database_MySQL(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $sql = "SELECT * FROM " . $MB_EARLY_FROSH_TABLE . " WHERE registration_id = " . $regID; $db->runSQL($sql); $temp_regID = ''; if ($row = $db->retrieveRow()) { $temp_regID = $row['registration_id']; } // apply rule despite there being >20 frosh because this registration existed before cut-off if ($regID == $temp_regID) { // $basePriceForThisGuy -= 25; // subtract $25 from $85 event base cost $basePriceForThisGuy = 40; // frosh cost $rulesApplied[] = $priceRulesArray['25']; } else { $basePriceForThisGuy = 60; // basic frosh cost $rulesApplied[] = $priceRulesArray['28']; } } return $basePriceForThisGuy; } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($85) } if ($eventID == $LAKESHORE_SUMMIT_2007) { $FROSH_DISCOUNT_FIELD = 64; // first check for Frosh Discount $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($FROSH_DISCOUNT_FIELD); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($userValue == '1') { // form criteria is met, apply the discount/penalty // $basePriceForThisGuy -= <varies>; // subtract <varying amount> from $120/$115/$110/$105 to get $75 $basePriceForThisGuy = 75; // frosh cost $rulesApplied[] = $priceRulesArray['19']; return $basePriceForThisGuy; } } // if no frosh discount, THEN apply early bird discount (if conditions met) // echo "DATE RULE<BR>"; // get the user's registration date $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // $regTime = $registration->getRegistrationDate(); if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime('2007-09-26')) { // date criteria is met, apply the discount/penalty // $basePriceForThisGuy -= 15; // apply early bird discount to $115 event base cost to get $105 $basePriceForThisGuy = 105; $rulesApplied[] = $priceRulesArray['20']; return $basePriceForThisGuy; } } return $basePriceForThisGuy; // otherwise return unaltered base event cost ($120) } /**** END OF RULE EXCEPTIONS ****/ // apply any price rules foreach ($priceRulesArray as $key => $rule) { $ruleType = $rule['priceruletypes_id']; // form attribute rule: apply price rule based on whether some form field value exists (i.e. frosh discount) if ($ruleType == RowManager_PriceRuleTypeManager::FORM_ATTRIBUTE_RULE) { // echo "FORM RULE<BR>"; // get the user's input for this form attribute $fieldValue = new RowManager_FieldValueManager(); // $fieldValue->loadByFieldIDandRegID($rule['fields_id'],$regID); $fieldValue->setFieldID($rule['fields_id']); $fieldValue->setRegID($regID); $valueListManager = $fieldValue->getListIterator(); $fieldValueList = $valueListManager->getDataList(); // echo "<pre>".print_r($fieldValueList,true)."</pre>"; reset($fieldValueList); $record = current($fieldValueList); // CHECK TO SEE IF SOME FIELD VALUE HAS BEEN SET FOR GIVEN PARAMETERS // $userValue = ''; $userValue = $record['fieldvalues_value']; // $fieldValue->getFieldValue(); if (isset($userValue) && $userValue != '') { // DETERMINE WHETHER PRICE RULE VALUE IS EQUIVALENT TO CURRENT FIELD VALUE if ($rule['pricerules_value'] == $userValue) { // form criteria is met, apply the discount/penalty $basePriceForThisGuy += $rule['pricerules_discount']; $rulesApplied[] = $rule; } } } else { if ($ruleType == RowManager_PriceRuleTypeManager::DATE_RULE) { // echo "DATE RULE<BR>"; // get the user's registration date $registration = new RowManager_RegistrationManager(); $registration->setRegID($regID); $regListManager = $registration->getListIterator(); $regArray = $regListManager->getDataList(); // echo "<pre>".print_r($registration,true)."</pre>"; // set default date-time $regTime = ''; // retrieve registration date reset($regArray); $record = current($regArray); // should be only 1 record for regID $regTime = $record['registration_date']; // $regTime = $registration->getRegistrationDate(); if ($regTime != '') { // if the registrant signed up before a deadline, apply the rule if (strtotime($regTime) < strtotime($rule['pricerules_value'])) { // date criteria is met, apply the discount/penalty $basePriceForThisGuy += $rule['pricerules_discount']; $rulesApplied[] = $rule; } } } else { if ($ruleType == RowManager_PriceRuleTypeManager::VOLUME_RULE) { $volumeNeeded = $rule['pricerules_value']; // $correctCampus = false; // $pattern = RowManager_PriceRuleTypeManager::CAMPUS_VOLUME_REGEX; // $numMatches = preg_match($pattern, $rule['pricerules_value']); // if ($numMatches > 0) // { // // $pricingValues = explode('|',$rule['pricerules_value']); // // echo '<pre>'.print_r($pricingValues,true).'</pre>'; // // echo 'campus = '.$pricingValues[0].' cut-off = '.$pricingValues[1]; // if ((int)$pricingValues[0] == $campusID) // { // $correctCampus = true; // $volumeNeeded = $pricingValues[1]; // // /* if ($numRegistrantsMyCampus != '') // { // // if the # of registrants >= the bulk discount value... // if ( $numRegistrantsMyCampus >= $pricingValues[1] ) // { // // bulk discount criteria is met, apply the discount/penalty // $basePriceForThisGuy += $rule['pricerules_discount']; // // $rulesApplied[] = $rule; // } // } // else // try to calculate the # of registrants on our own // { // */ // // /** } // **/ // } // } // // // check volume rule if no specific campus associated or current campus is associated with rule // if (($numMatches == 0)||($correctCampus == true)) // { if (isset($campusID) && $campusID != '') { // get total registrations for specific campus and particular event $total = array(); $summary = new RegSummaryTools(); $total = $summary->getCampusRegistrations($eventID, '', false, $campusID, '', RowManager_RegistrationManager::STATUS_REGISTERED); if (isset($total[$campusID])) { $numRegistrantsMyCampus = $total[$campusID]; } else { $numRegistrantsMyCampus = 0; } if (count($total) > 0) { // if the # of registrants >= the bulk discount value... if ($numRegistrantsMyCampus >= $volumeNeeded) { // bulk discount criteria is met, apply the discount/penalty $basePriceForThisGuy += $rule['pricerules_discount']; $rulesApplied[] = $rule; } } } else { // should not occur, this function meant to be used with campusID set } } else { if ($ruleType == RowManager_PriceRuleTypeManager::CAMPUS_RULE) { // echo "CAMPUS RULE<BR>"; // check the campus ID against the one stored in the price rules table if ($campusID == $rule['pricerules_value']) { $basePriceForThisGuy += $rule['pricerules_discount']; $rulesApplied[] = $rule; } } else { die('unknown ruletype[' . $ruleType . ']'); } } } } } // foreach rule // special hack for Eastern Ontario/Montreal summit 2006 /* if ( $eventID == 4 ) { $basePriceForThisGuy = getBasePriceEasternSummit2006( $regID, $numRegistrantsMyCampus, $rulesApplied ); } else if ( $eventID == 11 ) { $basePriceForThisGuy = getBasePricePrairieSummit2006( $regID, $campusID, $numRegistrantsMyCampus, $rulesApplied ); } */ return $basePriceForThisGuy; }
/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to this module's root directory * @param $viewer [OBJECT] The viewer object. * @param $formAction [STRING] The action on a form submit * @param $event_id [INTEGER] Value used to initialize the dataManager * @return [void] */ function __construct($pathModuleRoot, $viewer, $formAction, $event_id, $campus_id = '', $to_email_opt = '', $base_opt_value = '') { // NOTE: be sure to call the parent constructor before trying to // use the ->formXXX arrays... // $this->person_id = $person_id; $this->event_id = $event_id; $this->campus_id = $campus_id; if ($to_email_opt == '') { $this->to_email_choice = FormProcessor_EmailComposer::DEFAULT_RECIPIENTS; } else { $this->to_email_choice = $to_email_opt; } $this->base_opt_value = $base_opt_value; $this->viewer = $viewer; // if ((!isset($person_id))||($person_id == '')) // { // $this->person_id = $this->getPersonIDfromViewerID(); // $formAction .= '&'.modulecim_reg::PERSON_ID.'='.$this->person_id; // } // if (($isInRegProcess == true)&&($registration_id == '')) // { // $this->setRegistrationID(); // get registration ID for the rest of the process // $formAction .= '&'.modulecim_reg::REG_ID.'='.$this->registration_id; // // also note that person_id is set above if it is also not set yet // if ($person_id == -1) // { // // pass on new person_id to GET parameters // $formAction = str_replace( modulecim_reg::PERSON_ID.'=-1', modulecim_reg::PERSON_ID.'='.$this->person_id, $formAction); // } // // } $fieldList = FormProcessor_EmailComposer::FORM_FIELDS; $fieldDisplayTypes = FormProcessor_EmailComposer::FORM_FIELD_TYPES; parent::__construct($formAction, $fieldList, $fieldDisplayTypes); $this->pathModuleRoot = $pathModuleRoot; // if ($this->pageType == FormProcessor_EmailComposer::CAMPUS_EMAIL) if ($this->campus_id != '') { $this->TO_ADDRESS_OPTIONS = array('0' => 'All Campus Registrants', '1' => 'Campus Registrants - Completed', '2' => 'Campus Registrants - Incomplete', '3' => 'Campus Registrants - Cancelled', '4' => 'Campus Registrants - Males', '5' => 'Campus Registrants - Females', '6' => 'Custom List of Campus Registrants...'); //, '6'=>'All Campus Club Students' } else { $this->TO_ADDRESS_OPTIONS = array('0' => 'All Event Registrants', '1' => 'Event Registrants - Completed', '2' => 'Event Registrants - Incomplete', '3' => 'Event Registrants - Cancelled', '4' => 'Event Registrants - Males', '5' => 'Event Registrants - Females', '6' => 'Custom List of Event Registrants...'); } // To make sure this is not exploited to edit any other person's id. // If the user has no privileges, this sets the viewer id to be his/her own, // even if the variable given to it is not the viewer's person id. // NOTE: anyone with higher previliges can edit any person's info, by simply // changing the posted variable value. // NOTE: this code was causing problems in app_cim_reg module // Now load the access Priviledge manager of this viewer // $this->accessPrivManager = new RowManager_AdminManager( ); // // Get the person ID // $accessManager = new RowManager_AccessManager( ); // $accessManager->loadByViewerID( $this->viewer->getViewerID( ) ); // $personID = $accessManager->getPersonID(); // // Get the permissions the person has. // $this->accessPrivManager->loadByPersonID( $personID ); // if ( !$this->accessPrivManager->isLoaded() ) { // $this->person_id=$personID; // / } //End of check. // figure out the important fields for the dataManager // $fieldsOfInterest = implode(',', $this->formFields); $this->dataManager = new MultiTableManager(); $persons = new RowManager_PersonManager(); //$this->person_id $registrations = new RowManager_RegistrationManager(); $registrations->setEventID($this->event_id); $this->dataManager->addRowManager($persons); $this->dataManager->addRowManager($registrations, new JoinPair($persons->getJoinOnPersonID(), $registrations->getJoinOnPersonID())); if ($this->campus_id != '') { $assignments = new RowManager_AssignmentsManager(); $assignments->setCampusID($this->campus_id); $this->dataManager->addRowManager($assignments, new JoinPair($assignments->getJoinOnPersonID(), $persons->getJoinOnPersonID())); } $this->dataManager->setSortOrder('person_lname,person_fname'); // $this->dataManager->setFieldsOfInterest( $fieldsOfInterest ); $this->formValues = $this->dataManager->getArrayOfValues(); // echo "form values:<br><pre>".print_r($this->formValues,true)."</pre>"; // $eventInfo = new RowManager_EventManager($this->event_id); // $event_email = $eventInfo->getEventEmail(); // echo $event_email; $this->formValues['from_email'] = $this->getPersonEmailfromViewerID(); $this->formValues['to_email'] = $this->base_opt_value . $this->to_email_choice; // set jumplist SELECTED value // $this->formValues['email_subject'] = $campus_name.' - '.$event_name.' Notice'; // now initialize the labels for this page // start by loading the default field labels for this Module $languageID = $viewer->getLanguageID(); $seriesKey = modulecim_reg::MULTILINGUAL_SERIES_KEY; $pageKey = modulecim_reg::MULTILINGUAL_PAGE_FIELDS; $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey); // then load the page specific labels for this page $pageKey = FormProcessor_EmailComposer::MULTILINGUAL_PAGE_KEY; $this->labels->loadPageLabels($pageKey); // load the site default form link labels $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS); }
private function generateRegistrantsDroplist() { // $content = $this->_controller->loadEditCampusRegistrations_OffflineRegBox(); //$content = $this->registrants_dropList->getHTML(); $people = new RowManager_PersonManager(); $access = new RowManager_AccessManager(); // ADDED Nov 21, 2007 $viewers = new RowManager_ViewerManager(); // ADDED Nov 21, 2007 $assignment = new RowManager_AssignmentsManager(); $assignment->setCampusID($this->campus_id); $registrants = new MultiTableManager(); $registrants->addRowManager($people); $registrants->addRowManager($assignment, new JoinPair($people->getJoinOnPersonID(), $assignment->getJoinOnPersonID())); $registrants->addRowManager($access, new JoinPair($people->getJoinOnPersonID(), $access->getJoinOnPersonID())); // ADDED Nov 21, 2007 $registrants->addRowManager($viewers, new JoinPair($access->getJoinOnViewerID(), $viewers->getJoinOnViewerID())); // ADDED Nov 21, 2007 // get sub-query data for filtering out registrants that have already been registered for event $regs = new RowManager_RegistrationManager(); $regs->setEventID($this->event_id); // $regs->setPersonID($this->person_id); $status = new RowManager_StatusManager(); $status->setStatusDesc(RowManager_StatusManager::REGISTERED); $regData = new MultiTableManager(); $regData->addRowManager($regs); $regData->addRowManager($status, new JoinPair($regs->getJoinOnStatus(), $status->getJoinOnStatusID())); $regData->setFieldList('person_id'); $registered_SQL = $regData->createSQL(); // echo "<br>CREATED SQL 1 = ".$registered_SQL; // actually creates the sub-query ensuring that registrants in drop-down list are NOT registered $negateSubQuery = true; $addSubQuery = true; $registrants->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery); $registrants->setSortOrder('person_lname'); $peopleManager = $registrants->getListIterator(); $registrantsArray = $peopleManager->getDataList(); // echo "<br>CREATED SQL 2 = ".$registrants->createSQL(); $registrant = array(); // NOTE: the drop-down list stealthily passes PERSON_ID to controller (see name="SV43") $dropList = '<form name="Form" id="Form" method="post" action="' . $this->registrant_formAction . '">' . 'Select a registrant for offline registration, or choose "New Registrant" :<br><br>' . '<select name="' . modulecim_reg::PERSON_ID . '">' . '<option selected="selected" value="-1">New Registrant</option>'; // retrieve person first and last name from database array reset($registrantsArray); foreach (array_keys($registrantsArray) as $k) { $personData = current($registrantsArray); // $registrant['person_fname'] = $personData['person_fname']; // $registrant['person_lname'] = $personData['person_lname']; // add registrant names to drop-down list // for ($i = 0; $i < $totalPeople; $i++) // { $dropList .= '<option value=' . $personData['person_id'] . '>' . $personData['person_lname'] . ', ' . $personData['person_fname'] . ' (' . $personData['viewer_userID'] . ')</option>'; // } next($registrantsArray); } // $totalPeople = count($ $dropList .= '</select>' . ' <input name="REGISTER" type="submit" value="REGISTER" /></form>'; return $dropList; }