/** * 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); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object //$this->pathModuleRoot.'templates/'; // Replace $path with the following line if you want to create a // template tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // $adminLink = $this->linkValues[ 'adminHome' ]; // $this->template->set('adminLink', $adminLink ); // get pricing info // get base price for event participation $event = new RowManager_EventManager($this->event_id); $eventBasePrice = $event->getEventBasePrice(); // get price rules for specific event $priceRules = new RowManager_PriceRuleManager(); $priceRules->setEventID($this->event_id); $ruleManager = $priceRules->getListIterator(); $priceRulesArray = $ruleManager->getDataList(); // echo "<pre>".print_r($priceRulesArray,true)."</pre>"; // array storing the rules applied to a particular registrant $rulesApplied = array(); $priceGetter = new FinancialTools(); $basePriceForThisGuy = $priceGetter->getBasePriceForRegistrant($this->reg_id, $this->event_id, $this->campus_id, $eventBasePrice, $priceRulesArray, $rulesApplied); // get Personal Info $registration = new RowManager_RegistrationManager(); $registration->setRegID($this->reg_id); $person = new RowManager_PersonManager(); $assignment = new RowManager_AssignmentsManager(); // assigns campus to person $campus = new RowManager_CampusManager(); // $campus->setCampusID($this->campus_id); $personalInfo = new MultiTableManager(); $personalInfo->addRowManager($person); $personalInfo->addRowManager($assignment, new JoinPair($person->getJoinOnPersonID(), $assignment->getJoinOnPersonID())); $personalInfo->addRowManager($campus, new JoinPair($campus->getJoinOnCampusID(), $assignment->getJoinOnCampusID())); $personalInfo->addRowManager($registration, new JoinPair($registration->getJoinOnPersonID(), $person->getJoinOnPersonID())); $this->listManager = $personalInfo->getListIterator(); $personInfoArray = $this->listManager->getDataList(); // echo "<pre>".print_r($this->listManager,true)."</pre>"; // echo "<pre>".print_r($personInfoArray,true)."</pre>"; // cycle through registrations and store balance owing for each $this->owingArray = array(); $priceGetter = new FinancialTools(); reset($personInfoArray); foreach (array_keys($personInfoArray) as $k) { $personData = current($personInfoArray); $this->person_id = $personData['person_id']; $this->person_info['person_fname'] = ''; $this->person_info['person_fname'] = $personData['person_fname']; $this->person_info['person_lname'] = ''; $this->person_info['person_lname'] = $personData['person_lname']; $this->person_info['campus_desc'] = ''; $this->person_info['campus_desc'] = $personData['campus_desc']; $this->person_info['person_email'] = ''; $this->person_info['person_email'] = $personData['person_email']; $this->person_info['gender_id'] = ''; $this->person_info['gender_id'] = $personData['gender_id']; $this->person_info['person_local_addr'] = ''; $this->person_info['person_local_addr'] = $personData['person_local_addr']; $this->person_info['person_local_city'] = ''; $this->person_info['person_local_city'] = $personData['person_local_city']; $this->person_info['person_local_province_id'] = ''; $this->person_info['person_local_province_id'] = $personData['person_local_province_id']; $this->person_info['person_local_pc'] = ''; $this->person_info['person_local_pc'] = $personData['person_local_pc']; $this->person_info['person_local_phone'] = ''; $this->person_info['person_local_phone'] = $personData['person_local_phone']; $this->person_info['person_addr'] = ''; $this->person_info['person_addr'] = $personData['person_addr']; $this->person_info['person_city'] = ''; $this->person_info['person_city'] = $personData['person_city']; $this->person_info['province_id'] = ''; $this->person_info['province_id'] = $personData['province_id']; $this->person_info['person_pc'] = ''; $this->person_info['person_pc'] = $personData['person_pc']; $this->person_info['person_phone'] = ''; $this->person_info['person_phone'] = $personData['person_phone']; $this->person_info['registration_status'] = $personData['registration_status']; next($personInfoArray); } $this->linkValues["EditPersonInfo"] .= $this->person_id; $this->prepareTemplate($path); // set current registration status ID $this->template->set('currentRegStatus', $this->person_info['registration_status']); // get list of registration statuses $regStatuses = new RowManager_StatusManager(); $regStatusesList = $regStatuses->getListIterator(); $regStatusesArray = $regStatusesList->getDataList(); $statusList = array(); reset($regStatusesArray); foreach (array_keys($regStatusesArray) as $k) { $record = current($regStatusesArray); $statusList[key($regStatusesArray)] = $record['status_desc']; next($regStatusesArray); } // echo 'status list = <pre>'.print_r($statusList, true).'</pre>'; // set registration status information $this->template->set('statusFormAction', $this->formAction); $this->template->set('statusList', $statusList); $this->template->set('statusButtonText', 'Update'); // set some variables calculated previously; placed here because I need to get PERSON_ID for link // which had to be set before prepareTemplate(), which has to be executed BEFORE setting variables... $this->template->set('eventBasePrice', $eventBasePrice); $this->template->set('priceRules', $rulesApplied); $this->template->set('basePriceForThisGuy', $basePriceForThisGuy); //$priceGetter->calcBalanceOwing($this->reg_id); // NOT NEEDED BECAUSE TOTALS CALCULATED $this->template->set('person', $this->person_info); // get provinces and genders $provinces = new RowManager_ProvinceManager(); $provinceList = $provinces->getListIterator(); $provincesArray = $provinceList->getDataList(); // echo "<pre>".print_r($provincesArray,true)."</pre>"; $province_info = array(); reset($provincesArray); foreach (array_keys($provincesArray) as $k) { $province = current($provincesArray); $province_info[$province['province_id']] = $province['province_desc']; next($provincesArray); } $this->template->set('list_province_id', $province_info); $genders = new RowManager_GenderManager(); $genderList = $genders->getListIterator(); $genderArray = $genderList->getDataList(); // echo "<pre>".print_r($genderArray,true)."</pre>"; $gender_info = array(); reset($genderArray); foreach (array_keys($genderArray) as $k) { $gender = current($genderArray); $gender_info[$gender['gender_id']] = $gender['gender_desc']; next($genderArray); } $this->template->set('list_gender_id', $gender_info); // send in scholarships table, cash transactions table, and credit card transactions table $this->template->set('scholarshipsAdminBox', $this->generateScholarshipsTable()); $this->template->set('cashTransAdminBox', $this->generateCashTransactionsTable()); $this->template->set('ccTransAdminBox', $this->generateCCTransactionsTable()); // get scholarship total $scholarships = new RowManager_ScholarshipAssignmentManager(); $scholarships->setRegID($this->reg_id); $scholarshipTotal = new MultiTableManager(); $scholarshipTotal->addRowManager($scholarships); $scholarshipTotal->setFunctionCall('SUM', 'scholarship_amount'); $scholarshipTotal->setGroupBy('registration_id'); $scholarshipsList = $scholarshipTotal->getListIterator(); $scholarshipsArray = $scholarshipsList->getDataList(); reset($scholarshipsArray); foreach (array_keys($scholarshipsArray) as $k) { $scholarshp = current($scholarshipsArray); $scholarship_total = $scholarshp['SUM(scholarship_amount)']; next($scholarshipsArray); } if (!isset($scholarship_total)) { $scholarship_total = 0; } $this->template->set('scholarshipTotal', $scholarship_total); // get cash total $cashTrans = new RowManager_CashTransactionManager(); $cashTrans->setRegID($this->reg_id); $cashTrans->setReceived(true); $cashTransTotal = new MultiTableManager(); $cashTransTotal->addRowManager($cashTrans); $cashTransTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid'); $cashTransTotal->setGroupBy('reg_id'); $cashTransList = $cashTransTotal->getListIterator(); $cashTransArray = $cashTransList->getDataList(); reset($cashTransArray); foreach (array_keys($cashTransArray) as $k) { $cash_trans = current($cashTransArray); $cash_total = $cash_trans['SUM(cashtransaction_amtPaid)']; next($cashTransArray); } if (!isset($cash_total)) { $cash_total = 0; } $this->template->set('cashTotal', $cash_total); // get cash owed $cashOwed = new RowManager_CashTransactionManager(); $cashOwed->setRegID($this->reg_id); $cashOwed->setReceived(false); $cashOwedTotal = new MultiTableManager(); $cashOwedTotal->addRowManager($cashOwed); $cashOwedTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid'); $cashOwedTotal->setGroupBy('reg_id'); $cashOwedList = $cashOwedTotal->getListIterator(); $cashOwedArray = $cashOwedList->getDataList(); reset($cashOwedArray); foreach (array_keys($cashOwedArray) as $k) { $cash_owed = current($cashOwedArray); $cash_owing = $cash_owed['SUM(cashtransaction_amtPaid)']; next($cashOwedArray); } if (!isset($cash_owing)) { $cash_owing = 0; } $this->template->set('cashOwed', $cash_owing); // get credit card total $ccTrans = new RowManager_CreditCardTransactionManager(); $ccTrans->setProcessed(true); $ccTrans->setRegID($this->reg_id); $ccTransTotal = new MultiTableManager(); $ccTransTotal->addRowManager($ccTrans); $ccTransTotal->setFunctionCall('SUM', 'cctransaction_amount'); $ccTransTotal->setGroupBy('reg_id'); $ccTransList = $ccTransTotal->getListIterator(); $ccTransArray = $ccTransList->getDataList(); reset($ccTransArray); foreach (array_keys($ccTransArray) as $k) { $cc_trans = current($ccTransArray); $cc_total = $cc_trans['SUM(cctransaction_amount)']; next($ccTransArray); } if (!isset($cc_total)) { $cc_total = 0; } $this->template->set('ccTotal', $cc_total); // TODO??: get credit card transactions NOT processed // set form for editing registration-specific form fields' values $this->template->set('eventFieldsFormSingle', $this->generateFieldValuesForm()); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', RowManager_RegistrationManager::XML_NODE_NAME ); $this->template->set('rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'registration_id'); // Load over-payment message, if necessary if ($this->ccTrans_subPage->hasOverPaid()) { $this->template->set('attemptedOverpayment', true); } // TODO: somehow merge the primary join with the balance owing join.... for efficiency /* * Set up any additional data transfer to the Template here... */ // $this->template->set( 'dataList', $this->dataList); $templateName = 'page_EditRegistrationDetails.tpl.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditCampusRegistrations.php'; return $this->template->fetch($templateName); }
*/ $FieldValue = new RowManager_FieldValueManager(); $FieldValue->dropTable(); $FieldValue->createTable(); /* * Registration Table * * Manages basic registration data for some person-event combination. * * registration_id [INTEGER] Unique identifier for this particular registration record * event_id [INTEGER] The event the person is registering for. * person_id [INTEGER] The value identifying the person registering. * registration_date [DATE] The date the registration was made. * registration_confirmNum [STRING] The confirmation number for the registration. */ $Registration = new RowManager_RegistrationManager(); $Registration->dropTable(); $Registration->createTable(); /* * ScholarshipAssignment Table * * Assigns a scholarship to a registrant and manages affiliated data. * * scholarship_id [INTEGER] Unique identifier of the scholarship being assigned. * registration_id [INTEGER] Value identifying the registrant receiving the scholarship. * scholarship_amount [INTEGER] The amount of money the scholarship is worth. * scholarship_sourceAcct [STRING] The account number from where the scholarship originates. * scholarship_sourceDesc [STRING] The description of the source account. */ $ScholarshipAssignment = new RowManager_ScholarshipAssignmentManager(); $ScholarshipAssignment->dropTable();
function loadEditRegistrationDetails($isCreated = false) { // if event-id is missing, use reg-id to find it if ((!isset($this->EVENT_ID) || $this->EVENT_ID == '') && $this->REG_ID != '') { $eventFinder = new RowManager_RegistrationManager($this->REG_ID); $this->EVENT_ID = $eventFinder->getEventID(); } // if campus-id is missing, use person-id to find it if ((!isset($this->CAMPUS_ID) || $this->CAMPUS_ID == '') && $this->PERSON_ID != '') { $campusFinder = new RowManager_EditCampusAssignmentManager(); $campusFinder->setPersonID($this->PERSON_ID); $campusList = $campusFinder->getListIterator(); $campusArray = $campusList->getDataList(); // echo 'campus array = <pre>'.print_r($campusArray,true).'</pre>'; // pick the first campus found $record = current($campusArray); $this->CAMPUS_ID = $record['campus_id']; } // get privileges for the current viewer $privManager = new PrivilegeManager($this->viewer->getID()); if ($privManager->isCampusAdmin($this->EVENT_ID, $this->CAMPUS_ID) == true) { //template-specific sections for jumping to $SCHOLARSHIPS = '#Scholarships'; $CASHTRANS = '#CashTransactions'; $CCTRANS = '#ccTransactions'; $EVENTINFO = '#EventInfo'; // set the pageCallBack to be without any additional parameters // (an AdminBox needs this so Language Switching on a page doesn't // pass a previous operations) // echo "SCHOLARSHIP_ID, CASHTRANS_ID, CCTRANS_ID = ".$this->SCHOLARSHIP_ID." ".$this->CASHTRANS_ID." ".$this->CCTRANS_ID."<BR>"; $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $scholarship_parameters = array('EVENT_ID' => $this->EVENT_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'REG_ID' => $this->REG_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $cashtrans_parameters = array('EVENT_ID' => $this->EVENT_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'REG_ID' => $this->REG_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $cctrans_parameters = array('EVENT_ID' => $this->EVENT_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $fieldvals_parameters = array('EVENT_ID' => $this->EVENT_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'CAMPUS_ID' => $this->CAMPUS_ID, 'PERSON_ID' => $this->PERSON_ID, 'FIELD_ID' => $this->FIELD_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID); //[RAD_CALLBACK_PARAMS] $pageCallBack = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $parameters); $this->setPageCallBack($pageCallBack); $formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $parameters); $scholarship_formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $scholarship_parameters); $cashTrans_formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $cashtrans_parameters); $ccTrans_formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $cctrans_parameters); $fieldvals_formAction = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $fieldvals_parameters); // if this pageDisplay object isn't already created then if (!$isCreated) { // create a new pageDisplay object $this->pageDisplay = new page_EditRegistrationDetails($this->moduleRootPath, $this->viewer, $this->sortBy, $this->REG_ID, $this->EVENT_ID, $this->CAMPUS_ID, $this->SCHOLARSHIP_ID, $this->CASHTRANS_ID, $this->CCTRANS_ID, $formAction, $scholarship_formAction, $cashTrans_formAction, $ccTrans_formAction, $fieldvals_formAction, $this->PERSON_ID, $this->FIELDVALUE_ID, $this->FIELD_ID); } else { // otherwise just update the formAction value $this->pageDisplay->setFormAction($formAction, $scholarship_formAction, $cashTrans_formAction, $ccTrans_formAction, $fieldvals_formAction); } $links = array(); $this->IS_IN_REG_PROCESS = modulecim_reg::IS_FALSE; $parameters = array('IS_IN_REG_PROCESS' => $this->IS_IN_REG_PROCESS, 'EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $continueLink = $this->getCallBack(modulecim_reg::PAGE_EDITCAMPUSREGISTRATIONS, "", $parameters); $links["cont"] = $continueLink; // set edit personal info link $editLink = $this->getCallBack(modulecim_reg::PAGE_EDITPERSONALINFO, $this->sortBy, $parameters); $editLink .= "&" . modulecim_reg::PERSON_ID . "="; $links["EditPersonInfo"] = $editLink; /**** SCHOLARSHIP SUB-PAGE LINKS INIT ***/ $scholarshipLinks = array(); $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] // $parameters = array( 'REG_ID'=>$this->REG_ID );//[RAD_CALLBACK_PARAMS_EDIT] $editLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $parameters); $editLink .= "&" . modulecim_reg::SCHOLARSHIP_ID . "="; $scholarshipLinks["edit"] = $editLink; // NOTE: delete link is same as edit link for an AdminBox $scholarshipLinks["del"] = $editLink; $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $sortByLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, '', $parameters); $sortByLink .= "&" . modulecim_reg::SORTBY . "="; $scholarshipLinks["sortBy"] = $sortByLink; /**** CASH TRANSACTIONS SUB-PAGE LINKS INIT ***/ $cashTransLinks = array(); $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $editLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $parameters); $editLink .= "&" . modulecim_reg::CASHTRANS_ID . "="; $cashTransLinks["edit"] = $editLink; // NOTE: delete link is same as edit link for an AdminBox $cashTransLinks["del"] = $editLink; $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $sortByLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, '', $parameters); $sortByLink .= "&" . modulecim_reg::SORTBY . "="; $cashTransLinks["sortBy"] = $sortByLink; /**** CC TRANSACTIONS SUB-PAGE LINKS INIT ***/ $ccTransLinks = array(); $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'CCTRANS_ID' => $this->CCTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $editLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, $this->sortBy, $parameters); $editLink .= "&" . modulecim_reg::CCTRANS_ID . "="; // $ccTransLinks[ "edit" ] = $editLink; // NOTE: delete link is same as edit link for an AdminBox // $ccTransLinks[ "del" ] = $editLink; $parameters = array('EVENT_ID' => $this->EVENT_ID, 'FIELDTYPE_ID' => $this->FIELDTYPE_ID, 'PRICERULETYPE_ID' => $this->PRICERULETYPE_ID, 'CCTYPE_ID' => $this->CCTYPE_ID, 'PRIV_ID' => $this->PRIV_ID, 'VIEWER_ID' => $this->VIEWER_ID, 'SUPERADMIN_ID' => $this->SUPERADMIN_ID, 'EVENTADMIN_ID' => $this->EVENTADMIN_ID, 'FIELD_ID' => $this->FIELD_ID, 'DATATYPE_ID' => $this->DATATYPE_ID, 'PRICERULE_ID' => $this->PRICERULE_ID, 'CAMPUSACCESS_ID' => $this->CAMPUSACCESS_ID, 'CASHTRANS_ID' => $this->CASHTRANS_ID, 'REG_ID' => $this->REG_ID, 'FIELDVALUE_ID' => $this->FIELDVALUE_ID, 'SCHOLARSHIP_ID' => $this->SCHOLARSHIP_ID, 'STATUS_ID' => $this->STATUS_ID, 'CAMPUS_ID' => $this->CAMPUS_ID); //[RAD_CALLBACK_PARAMS] $sortByLink = $this->getCallBack(modulecim_reg::PAGE_EDITREGISTRATIONDETAILS, '', $parameters); $sortByLink .= "&" . modulecim_reg::SORTBY . "="; $ccTransLinks["sortBy"] = $sortByLink; $this->pageDisplay->setLinks($links, $scholarshipLinks, $cashTransLinks, $ccTransLinks); //$this->previous_page = modulecim_reg::PAGE_EDITREGISTRATIONDETAILS; } else { $this->pageDisplay = new page_NotAuthorized($this->moduleRootPath, $this->viewer); } }
protected function getRegistrationID($personID) { $regID = -1; if ($personID != -1) { // get registration ID for the rest of the reg. process $regs = new RowManager_RegistrationManager(); $regs->setPersonID($this->person_id); $regsList = $regs->getListIterator(); $regsArray = $regsList->getDataList(); $statusID = 0; reset($regsArray); foreach (array_keys($regsArray) as $k) { $reg = current($regsArray); $regID = $reg['registration_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) // $this->registration_id = $regID; next($regsArray); } } return $regID; // returns latest registration_id }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // echo "<pre>".print_r($this->linkValues, true)."</pre>"; $title = $this->labels->getLabel('[Details]'); $columnLabel = $this->labels->getLabel('[View]'); $link = $this->linkValues['view']; $fieldName = 'event_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); $REGISTERED = 2; //'true'; $INCOMPLETE = 1; $NOT_REGISTERED = 0; //'false'; /** determine which events the user has already registered for... **/ $events = new RowManager_EventManager(); $events->setOnHomePage('1'); $events->addSearchCondition($this->countrySearchCondition); // $events->setSortOrder( $this->sortBy ); // needed to sync lists $regs = new RowManager_RegistrationManager(); $regs->setPersonID($this->person_id); $status = new RowManager_StatusManager(); $status->setStatusDesc(RowManager_StatusManager::REGISTERED); $reg_events = new MultiTableManager(); $reg_events->addRowManager($events); $reg_events->addRowManager($regs, new JoinPair($events->getJoinOnEventID(), $regs->getJoinOnEventID())); $reg_events->addRowManager($status, new JoinPair($regs->getJoinOnStatus(), $status->getJoinOnStatusID())); if (!isset($this->sortBy) || $this->sortBy == '') { $this->sortBy = 'event_id'; } $reg_events->setSortOrder($this->sortBy); // needed to sync lists // echo "reg events sql = ".$reg_events->createSQL(); $regs_events_list = $reg_events->getListIterator(); $regs_events_array = $regs_events_list->getDataList(); /** determine which events the user has PARTIALLY completed registration for ***/ $events2 = new RowManager_EventManager(); $events2->setOnHomePage('1'); $events2->addSearchCondition($this->countrySearchCondition); // $events->setSortOrder( $this->sortBy ); // needed to sync lists $regs2 = new RowManager_RegistrationManager(); $regs2->setPersonID($this->person_id); $status2 = new RowManager_StatusManager(); $status2->setStatusDesc(RowManager_StatusManager::INCOMPLETE); $reg_events2 = new MultiTableManager(); $reg_events2->addRowManager($events2); $reg_events2->addRowManager($regs2, new JoinPair($events2->getJoinOnEventID(), $regs2->getJoinOnEventID())); $reg_events2->addRowManager($status2, new JoinPair($regs2->getJoinOnStatus(), $status2->getJoinOnStatusID())); $reg_events2->setSortOrder($this->sortBy); // needed to sync lists // echo "reg events sql = ".$reg_events->createSQL(): $incomplete_regs_events_list = $reg_events2->getListIterator(); $incompete_regs_events_array = $incomplete_regs_events_list->getDataList(); // echo '<pre>'.print_r($incompete_regs_events_array, true).'</pre>'; // get full event-listing for mapping isRegistered to $allEvents = $this->listManager->getDataList(); // // echo 'reg events = <pre>'.print_r($regs_events_array,true).'</pre><br>'; // echo 'all events = <pre>'.print_r($allEvents, true).'</pre><br>'; $eventName_isReg_array = array(); reset($regs_events_array); reset($incompete_regs_events_array); reset($allEvents); foreach (array_keys($allEvents) as $k) { $record = current($allEvents); $currentEvent = $record['event_id']; $record2 = current($regs_events_array); $currentRegEvent = $record2['event_id']; $record3 = current($incompete_regs_events_array); $currentIncRegEvent = $record3['event_id']; $eventName = $record['event_name']; // store event in registered array if mapping found if ($currentEvent == $currentRegEvent) { $eventName_isReg_array[$eventName] = $REGISTERED; next($regs_events_array); } else { if ($currentEvent == $currentIncRegEvent) { $eventName_isReg_array[$eventName] = $INCOMPLETE; next($incompete_regs_events_array); } else { $eventName_isReg_array[$eventName] = $NOT_REGISTERED; } } next($allEvents); } // echo "events: <PRE>".print_r($eventName_isReg_array,true)."</PRE>"; $title = $this->labels->getLabel('[RegisterAccess]'); $columnLabels = array(); $columnLabels[$NOT_REGISTERED] = $this->labels->getLabel('[Register]'); $columnLabels[$INCOMPLETE] = $this->labels->getLabel('[FinishReg]'); $columnLabels[$REGISTERED] = $this->labels->getLabel('[EditReg]'); // formerly [CancelReg] $links = array(); $links[$NOT_REGISTERED] = $this->linkValues['register']; $links[$INCOMPLETE] = $this->linkValues['complete']; $links[$REGISTERED] = $this->linkValues['edit_reg']; // formerly 'cancel' // field column names to map to link name (i.e. filter by event to determine if link name should change based on reg status) $fieldNames = array(); $fieldNames[$NOT_REGISTERED] = 'event_id'; $fieldNames[$INCOMPLETE] = 'event_id'; $fieldNames[$REGISTERED] = 'event_id'; // OLD: $this->addLinkColumn( $title, $columnLabel, $link, $fieldName, $useAlt, $alt_label, $link_alt, $fieldAlt); $this->addDynamicLinkColumn($title, $columnLabels, $links, $fieldNames); // link an array of filters to a particular link column $linkColumnFilter[$title] = $eventName_isReg_array; // echo '<pre>'.print_r($linkColumnFilter, true).'</pre>'; // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); // set the filter list used to determine which events have 'register' links and which have 'cancel' links $this->template->set('linkColumnFilter', $linkColumnFilter); // store the Row Manager's XML Node Name $this->template->set('rowManagerXMLNodeName', RowManager_EventManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'event_id'); /* * Set up any additional data transfer to the Template here... */ $this->template->set('disableHeading', true); $templateName = 'siteDataList.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_HomePageEventList.php'; return $this->template->fetch($templateName); }
/** * function 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; }
protected function getBalanceOwing() { $regManager = new RowManager_RegistrationManager($this->reg_id); return $regManager->getBalanceOwing(); }
/** * function processData * <pre> * Processes the data for this form. * </pre> * @return [void] */ function processData() { // initialize the variable storing process report data $reportDataDump = ''; $BR = '<BR>'; $HR = '<HR>'; if ($this->shouldDelete) { // TODO: delete all the dependent data records (otherwise FK constraints will *NOT* allow deletion) // see app_cim_reg/objects_pages/page_ConfirmDeleteRegistration.php $savedPersonID = $this->person_id; // the ID of the person whose records are to be deleted // $reportDataDump .= 'Unique person record tuple:'.$BR.' First Name = '.$person_fname.', Last Name = '.$person_lname.', E-mail = '.$person_email.$BR.$BR; // echo "PERSON NAME: ".$person_fname." ".$person_lname; // echo "PERSON: <pre>".print_r($person,true)."</pre>"; // search for a particular person to see if duplicate records exist // $indiv_person_manager = new RowManager_PersonManager(); $indiv_person_manager = new MultiTableManager(); $indiv_person_manager->addRowManager($this->person_manager); // $indiv_person_manager->setFirstName(addslashes($person_fname)); // use addslashes to escape special chars in string // $indiv_person_manager->setLastName(addslashes($person_lname)); // $indiv_person_manager->setEmail(addslashes($person_email)); // $indiv_person_manager->setSortOrder( 'person_id' ); // $indiv_person_manager->setAscDesc( 'DESC' ); // sort by descending person IDs $indiv_person_manager->addSearchCondition("person_id = '" . $this->person_id . "'"); // use GROUP BY to easily enforce distinct triplets of (person_fname, person_lname, person_email) $groupBy = "person_fname,person_lname,person_email"; $indiv_person_manager->setGroupBy($groupBy); $indivData = $indiv_person_manager->getListIterator(); $indivDataArray = $indivData->getDataList(); // echo " INDIV COUNT: ".count($indivDataArray)."<br><br>"; // echo "INDIV RECORDS: <pre>".print_r($indivDataArray,true)."</pre>"; $person_ids_list = ''; //return all the person's data into array (key = person_id) of arrays (and store total data stored?) if (isset($indivDataArray)) { if (count($indivDataArray) == 0) { echo "ERROR: person was found earlier and now NO records are found!"; } else { if (count($indivDataArray) == 1) { // echo "GREAT! This person only has one record."; reset($indivDataArray); $record = current($indivDataArray); $savedPersonID = $record['person_id']; $person_ids_list = $savedPersonID; $reportDataDump .= 'Unique person id found for tuple: ' . $savedPersonID . $BR . $BR; } else { if (count($indivDataArray) > 1) { // get the person IDs for this individual reset($indivDataArray); foreach (array_keys($indivDataArray) as $l) { $record = current($indivDataArray); $person_ids_list .= $record['person_id']; $person_ids_list .= ','; next($indivDataArray); } $person_ids_list = substr($person_ids_list, 0, -1); // remove final comma $reportDataDump .= 'Multiple person ids found for tuple: ' . $person_ids_list . $BR . $BR; } } } // Search for duplicate person-related entries - for 1 or more person_ids found for current person if ($person_ids_list != '') { // echo "<br> person ids list: ".$person_ids_list."<br>"; // $person_ids_array = explode($person_ids_list,','); // check access table using all the found person IDs - retrieve viewer ids with person id as key $foundViewerIDs = $this->getAccessRecords($person_ids_list); // can safely assume array ISSET // echo 'found viewer ids= <pre>'.print_r($foundViewerIDs,true).'</pre>'; /** IF 0 access table records were found: **/ if (count($foundViewerIDs) == 0) { // TODO?: notify admin that this/these person record(s) require a viewer account // Store the active (latest) person_id in special variable reset($indivDataArray); $savedPersonID = key($indivDataArray); // recall that person_ids are sorted in descending order } else { if (count($foundViewerIDs) >= 1) { /** store the active (access table) person_id in special variable **/ reset($foundViewerIDs); $personIDs = explode(',', $person_ids_list); $savedPersonID = current($personIDs); //current($foundViewerIDs); $reportDataDump .= 'Person ID of the record(s) to delete: ' . $savedPersonID . ' (associated with the most recent person record)' . $BR . $BR; // echo 'latest viewer ids = <pre>'.print_r($foundViewerIDs,true).'</pre>'; // echo 'saved person ID = '.$savedPersonID; $reportDataDump .= 'Changes made to <b>cim_hrdb_access table</b>: ' . $BR; /*** update the access table records to only use latest person ID **/ foreach (array_values($foundViewerIDs) as $person_id) { $viewer_id = key($foundViewerIDs); // echo 'viewer_id = '.$viewer_id; // only delete from the access table record if it needs a different person_id if ($person_id == $savedPersonID) { // get access ID(s) for the record to change $accessManager = new RowManager_AccessManager(); $accessManager->setViewerID($viewer_id); $accessManager->setPersonID(current($foundViewerIDs)); // or just use $person_id $accessData = $accessManager->getListIterator(); $accessDataArray = $accessData->getDataList(); // echo 'access data array = <pre>'.print_r($accessDataArray,true).'</pre>'; reset($accessDataArray); // deal with the unlikely case that we have redundant viewerID-personID records foreach (array_keys($accessDataArray) as $key) { $record = current($accessDataArray); $accessID = $record['access_id']; $reportDataDump .= 'Deleting access table entries linked to person_id = ' . $person_id; $accessDeleter = new RowManager_AccessManager($accessID); $accessDeleter->deleteEntry(); next($accessDataArray); } } $id = next($foundViewerIDs); // person_id if ($id === FALSE) { break; // no valid data found so break out of the loop } } } } /** <end> access table entry deletion **/ $baseRecord = $indivDataArray[$savedPersonID]; // echo "<br>base record: <pre>".print_r($baseRecord,true)."</pre><br>"; // $flagArray = $this->checkPersonRecordFields($baseRecord); // echo "<br>flag array: <pre>".print_r($flagArray,true)."</pre><br>"; /** NOTE: SKIP PERSON RECORD UPDATE SINCE WE ARE JUST DELETING A RECORD, *NOT* UPDATING **/ /** Go through various tables and clean out or update records related to the current person **/ // Update and clean-up the Person-Year table (cim_hrdb_person_year) // Step 1) Find the information stored for the active person_id $personYearArray = array(); $person_year_manager = new RowManager_PersonYearManager(); $person_year_manager->setPersonID($savedPersonID); $person_year_manager->setSortOrder('personyear_id'); $person_year_manager->setAscDesc('DESC'); // sort by descending personyear IDs // echo "<BR>".$savedPersonID.","; $personYearData = $person_year_manager->getListIterator(); $person_year_array = $personYearData->getDataList(); reset($person_year_array); foreach (array_keys($person_year_array) as $key) { $record = current($person_year_array); $person_year_id = $record['personyear_id']; $year_id = $record['year_id']; $personYearArray[$person_year_id] = $year_id; // store person_id associated with the person_year_id next($person_year_array); } // if (count($person_year_array) > 0) // { // echo "<br>Years for active person_id ".$savedPersonID.": <pre>".print_r($personYearArray,true)."</pre><br>"; // } // echo "Person IDs list: ".$person_ids_list."<br>"; $reportDataDump .= 'Changes made to <b>cim_hrdb_person_year table</b>: ' . $BR; // remove all person-year records (associated with active person id) if (count($personYearArray) >= 1) { reset($personYearArray); $person_year_id = key($personYearArray); // $reportDataDump .= 'Saving the first person year record associated with person ID '.$savedPersonID.$BR.$BR; // next($personYearArray); // keep the first record (most recent personyear_id foreach (array_keys($personYearArray) as $m) { $record = current($personYearArray); $personYearID = key($personYearArray); $reportDataDump .= "REMOVE person-year entry for person_id = " . $savedPersonID . " using key = " . key($personYearArray) . $BR . $BR; if (isset($personYearID) && $personYearID != '' && $personYearID > 0) { $reportDataDump .= 'Deleting person year record having year ID ' . $record . $BR . $BR; $personYearUpdater = new RowManager_PersonYearManager($personYearID); $personYearUpdater->deleteEntry(); } next($personYearArray); } } // Update the Emergency Contact table (cim_hrdb_emerg) // Step 1) Find the information stored for the active person_id $emergInfoArray = array(); $emerg_info_manager = new RowManager_EmergencyInfoManager(); $emerg_info_manager->setPersonID($savedPersonID); $emerg_info_manager->setSortOrder('emerg_id'); $emerg_info_manager->setAscDesc('DESC'); // sort by descending emerg IDs // echo "<BR>".$savedPersonID.","; $emergInfoData = $emerg_info_manager->getListIterator(); $emerg_info_array = $emergInfoData->getDataList(); reset($emerg_info_array); foreach (array_keys($emerg_info_array) as $l) { $record = current($emerg_info_array); $emerg_id = $record['emerg_id']; $emerg_info = array(); $fields = page_DeletePerson::EMERG_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the emergency info values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $emerg_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with emerg_id as key $emergInfoArray[$emerg_id] = $emerg_info; next($emerg_info_array); } // TEST CONDITION // if (count($emerg_info_array) > 0) // { // echo "<br>Emergency info for active person_id ".$savedPersonID.": <pre>".print_r($emergInfoArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_emerg table</b>: ' . $BR; // remove all emergency info records associated with active person id if (count($emergInfoArray) >= 1) { reset($emergInfoArray); // $reportDataDump .= 'Saving the emergency contact record associated with person ID '.$savedPersonID.$BR.$BR; // next($emergInfoArray); // keep the first record (most recent emerg_id) foreach (array_keys($emergInfoArray) as $m) { $record = current($emergInfoArray); $emergID = key($emergInfoArray); // echo "REMOVE person-emerg entry for person_id = ".$savedPersonID." using key = ".key($emergInfoArray); if (isset($emergID) && $emergID != '') { $emergUpdater = new RowManager_EmergencyInfoManager($emergID); $emergUpdater->deleteEntry(); $reportDataDump .= 'Deleting emergency contact record having emergency ID ' . $emergID . $BR . $BR; } next($emergInfoArray); } } /**** TODO: have code to deal with deleting person ids in 'cim_hrdb_admin' (LOW-PRIORITY DUE TO SMALL SIZE OF TABLE) **/ /*** Update the Campus Assignment table (cim_hrdb_assignment) **/ // Step 1) Find the information stored for the active person_id $campusAssignArray = array(); $campus_assign_manager = new RowManager_AssignmentsManager(); $campus_assign_manager->setPersonID($savedPersonID); $campus_assign_manager->setSortOrder('assignment_id'); $campus_assign_manager->setAscDesc('DESC'); // sort by descending assignment IDs $campusAssignData = $campus_assign_manager->getListIterator(); $campus_assign_array = $campusAssignData->getDataList(); reset($campus_assign_array); foreach (array_keys($campus_assign_array) as $id) { $record = current($campus_assign_array); $assign_id = $record['assignment_id']; $assignment_info = array(); $fields = page_DeletePerson::ASSIGNMENT_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the campus assignment values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $assignment_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with assign_id as key $campusAssignArray[$assign_id] = $assignment_info; next($campus_assign_array); } // TEST CONDITION // if (count($campus_assign_array) > 0) // { // echo "<br>Campus assignment info for active person_id ".$savedPersonID.": <pre>".print_r($campusAssignArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_assignment table</b>: ' . $BR; // TODO??: remove all but the most recent campus assignment record (associated with active person id) // REMEMBER: a student may be an alumni of one school or attend two schools at once... if (count($campusAssignArray) >= 1) { $campus_ids_list = array(); $idx = 0; reset($campusAssignArray); $row = current($campusAssignArray); $campus_ids_list[$idx++] = $row['campus_id']; // next($campusAssignArray); // keep the first record (most recent assign_id) foreach (array_keys($campusAssignArray) as $m) { $record = current($campusAssignArray); $assignID = key($campusAssignArray); $reportDataDump .= "REMOVE person-campus entry for person_id = " . $savedPersonID . " using key = " . key($campusAssignArray) . $BR . $BR; if (isset($assignID) && $assignID != '') { // remove entries having a campus_id for the active person record $assignUpdater = new RowManager_AssignmentsManager($assignID); $assignUpdater->deleteEntry(); $reportDataDump .= 'Deleting campus assignment record having campus ID ' . $record['campus_id'] . $BR . $BR; } next($campusAssignArray); } } $reportDataDump .= 'Changes made to <b>cim_reg_registration table</b>: ' . $BR; // Delete the registration records associated with the person ID $registration_manager2 = new RowManager_RegistrationManager(); $registration_manager2->addSearchCondition('person_id in (' . $savedPersonID . ')'); //$person_ids_list.')'); $registration_manager2->setSortOrder('person_id'); $registration_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $registrationData2 = $registration_manager2->getListIterator(); $registration_array2 = $registrationData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; // $eventIDs = array(); // $idx = 0; reset($registration_array2); foreach (array_keys($registration_array2) as $key) { $record = current($registration_array2); $personID = $record['person_id']; if ($personID == $savedPersonID) { // echo "FOUND person ".$personID; $registration_id = $record['registration_id']; // $event_id = $record['event_id']; // Delete associated records in registration-related tables $this->deleteAssociatedRegRecords($registration_id); $regRecordUpdater = new RowManager_RegistrationManager($registration_id); // // update the person ID for an campus assignment record (in database) // $updateValues = array(); // $updateValues['person_id'] = $savedPersonID; // $regRecordUpdater->loadFromArray( $updateValues ); // $regRecordUpdater->updateDBTable(); $regRecordUpdater->deleteEntry(); $reportDataDump .= 'Delete associated registration record for person ID ' . $savedPersonID . ',' . $BR; } next($registration_array2); } /*** Update the Staff table (cim_hrdb_staff) **/ // Step 1) Find the information stored for the active person_id $staff_manager = new RowManager_StaffManager(); $staff_manager->setPersonID($savedPersonID); $staff_manager->setSortOrder('staff_id'); $staff_manager->setAscDesc('DESC'); // sort by descending assignment IDs // echo "<BR>".$savedPersonID.","; $staffData = $staff_manager->getListIterator(); $staff_array = $staffData->getDataList(); // TEST CONDITION // if (count($staff_array) > 0) // { // echo "<br>Staff info for active person_id ".$savedPersonID.": <pre>".print_r($staff_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_staff table</b>: ' . $BR; // Step 2) Remove all but one of the staff records // if (count($staff_array) > 1) // remove ONLY records with redundant person-campus pairs // { reset($staff_array); // next($staff_array); // keep the first record (most recent staff_id for active person) // $reportDataDump .= 'Saving the first staff record associated with person ID '.$savedPersonID.$BR.$BR; // echo 'staff array = <pre>'.print_r($staff_array,true).'</pre>'; foreach (array_keys($staff_array) as $m) { $record = current($staff_array); $staffID = key($staff_array); // remove redundant entry $staffUpdater = new RowManager_StaffManager($staffID); $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting staff record having staff ID ' . $staffID . $BR . $BR; $id = next($staff_array); // staff ID if ($id === FALSE) { break; // no valid data found so break out of the loop } } // } /***** Remove redundant sub-group associations, otherwise rename person-id to active person-id ******************/ // Update the Person-DG table (sch_person_sub_group): still requires clean up // Step 1) Find the information stored for the active person_id $dg_campus_array = array(); $person_dg_manager = new RowManager_PersonDGManager(); $person_dg_manager->setPersonID($savedPersonID); $person_dg_manager->setSortOrder('person_sub_group_id'); $person_dg_manager->setAscDesc('DESC'); // sort by descending person_sub_group_IDs $personDGData = $person_dg_manager->getListIterator(); $personDGArray = $personDGData->getDataList(); reset($personDGArray); foreach (array_keys($personDGArray) as $l) { $record = current($personDGArray); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $dg_campus_array[$dg_id] = $campus_id; next($personDGArray); } // // if (count($dg_campus_array) > 0) // { // echo "<br>DG for active person_id ".$savedPersonID.": <pre>".print_r($personDGArray,true)."</pre><br>"; // // echo "<br>DG-Campus for active person_id ".$savedPersonID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>sch_person_sub_group table</b>: ' . $BR; // Step 2) Update the records having the non-active person ids for this person $person_dg_manager2 = new RowManager_PersonDGManager(); $person_dg_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_dg_manager2->setSortOrder('person_id'); $person_dg_manager2->setAscDesc('DESC'); // sort by descending person IDs $personDGData2 = $person_dg_manager2->getListIterator(); $personDGArray2 = $personDGData2->getDataList(); // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personDGArray2) < 1) // { // $updated = false; // } // $j = 0; // echo 'DG array results = <pre>'.print_r($personDGArray2,true).'</pre>'; // echo 'dg - campus array: <pre>'.print_r($dg_campus_array,true).'</pre>'; reset($personDGArray2); foreach (array_keys($personDGArray2) as $l) { $record = current($personDGArray2); $personID = $record['person_id']; if ($personID == $savedPersonID) { $personSubGroupID = $record['person_sub_group_id']; $personDGUpdater = new RowManager_PersonDGManager($personSubGroupID); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $personDGUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for person ID ' . $savedPersonID . $BR; } next($personDGArray2); } /*** Update the personal schedule table (sch_schedule) **/ // Step 1) Find the information stored for the active person_id $schedule_array = array(); $schedule_manager = new RowManager_ScheduleManager(); $schedule_manager->setPersonID($savedPersonID); $schedule_manager->setSortOrder('schedule_id'); $schedule_manager->setAscDesc('DESC'); // sort by descending schedule_IDs $personScheduleData = $schedule_manager->getListIterator(); $personScheduleArray = $personScheduleData->getDataList(); reset($personScheduleArray); $idx = 0; foreach (array_keys($personScheduleArray) as $l) { $record = current($personScheduleArray); $schedule_block = $record['schedule_block']; $schedule_array[$idx] = $schedule_block; next($personScheduleArray); $idx++; } // echo 'active person schedule = <pre>'.print_r($personScheduleArray,true).'</pre>'; // echo 'person blocks array = <pre>'.print_r($schedule_array,true).'</pre>'; $reportDataDump .= 'Changes made to <b>sch_schedule table</b>: ' . $BR; // Step 2) Create new records for active person ID from data linked to the non-active person ids for this person $schedules = new RowManager_ScheduleManager(); $schedule_manager2 = new MultiTableManager(); $schedule_manager2->addRowManager($schedules); $schedule_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $schedule_manager2->addSortField('person_id', 'DESC'); // $schedule_manager2->setAscDesc( 'DESC' ); // sort by descending person ID $personScheduleData2 = $schedule_manager2->getListIterator(); $personScheduleArray2 = $personScheduleData2->getDataList(); $updatePersonID = -1; reset($personScheduleArray2); foreach (array_keys($personScheduleArray2) as $l) { $record = current($personScheduleArray2); $personID = $record['person_id']; if ($personID == $savedPersonID) { $found_sch_block = $record['schedule_block']; $schedule_id = $record['schedule_id']; $personScheduleUpdater = new RowManager_ScheduleManager($schedule_id); $personScheduleUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for person ID ' . $savedPersonID . $BR . $BR; } next($personScheduleArray2); } /*** Remove all person records for person_id***/ $personIDs = explode(',', $person_ids_list); foreach (array_values($personIDs) as $personID) { if ($personID == $savedPersonID) { $personUpdater = new RowManager_PersonManager($personID); $personUpdater->deleteEntry(); $reportDataDump .= 'Deleting <b>cim_hrdb_person</b> record having person ID ' . $personID . $BR; } next($personIDs); } } // end if (isset($indivDataArray)) $reportDataDump = substr($reportDataDump, 0, -4); // remove the last <BR> $reportDataDump .= $HR; // next($personDataArray); // } } // end if (isset($indivDataArray)) // echo $reportDataDump; } // end 'should delete?' parent::processData(); // remove data from cim_hrdb_person table }
protected function getFieldArray($regID = '', $personID = '', $eventID = '') { $FALSE = 0; $fields = new RowManager_FieldManager(); // $fvalues = new RowManager_FieldValueManager(); $ftypes = new RowManager_FieldTypeManager(); // echo "personID = ".$personID; // echo "eventID = ".$eventID; if ($eventID != '') { $fields->setEventID($eventID); //$fvalues->setRegID($regID); } else { if ($regID != '') { $registrations = new RowManager_RegistrationManager(); $registrations->setRegID($regID); // $person = new RowManager_PersonManager(); // $person->setPersonID($personID); $event = new RowManager_EventManager(); // $event->setEventID($eventID); $personReg = new MultiTableManager(); $personReg->addRowManager($registrations); // $personReg->addRowManager($person, new JoinPair($registrations->getJoinOnPersonID(), $person->getJoinOnPersonID())); $personReg->addRowManager($event, new JoinPair($registrations->getJoinOnEventID(), $event->getJoinOnEventID())); $valIterator = $personReg->getListIterator(); $valArray = $valIterator->getDataList(); // go through results and store field types reset($valArray); foreach (array_keys($valArray) as $k) { $regValue = current($valArray); $eventID = $regValue['event_id']; //NOTE: assumes only 1 event per registration //OLD: registration per person per event next($valArray); } $fields->setEventID($eventID); // $fvalues->setRegID($regID); } } // $fvalues->setSortByFieldID(); $fieldInfo = new MultiTableManager(); $fieldInfo->addRowManager($fields); // $fieldInfo->addRowManager($fvalues, new JoinPair($fvalues->getJoinOnFieldID(), $fields->getJoinOnFieldID())); $fieldInfo->addRowManager($ftypes, new JoinPair($fields->getJoinOnFieldTypeID(), $ftypes->getJoinOnFieldTypeID())); if ($this->show_hidden == false) { $fieldInfo->constructSearchCondition('fields_hidden', '=', $FALSE, true); } $fieldInfo->setSortOrder('fields_priority'); // echo $fieldInfo->createSQL(); $valuesIterator = $fieldInfo->getListIterator(); $valuesArray = $valuesIterator->getDataList(); // echo "label values:<br><pre>".print_r($valuesArray,true)."</pre>"; // map the fields_id of each field values row to the label of that particular form field $idx = 0; reset($valuesArray); foreach (array_keys($valuesArray) as $k) { $record = current($valuesArray); // store mapping associating form field label with fields_id $this->formFieldToFieldIDmapper['form_field' . $idx] = $record['fields_id']; next($valuesArray); $idx++; } // echo "field id values:<br><pre>".print_r($this->formFieldToFieldIDmapper,true)."</pre>"; return $valuesArray; }
/** * function updateDBTable * <pre> * Updates the DB table info. * </pre> * @return [void] */ function updateDBTable($isDebug = false) { $status = parent::updateDBTable($isDebug); if ($status == true) { $values = $this->getArrayOfValues(); // echo "<pre>".print_r($values,true)."</pre>"; if (isset($values['reg_id'])) { // update balance owing column in cim_reg_registration table $singleReg = new RowManager_RegistrationManager($values['reg_id']); // $singleReg_list = $singleReg->getListIterator(); // $singleReg_array = $singleReg_list->getDataList(); // // reset($singleReg_array); // $record = current($singleReg_array); // $oldBalance = $record['registration_balance']; $balanceGetter = new FinancialTools(); $balance = array(); // $balance['registration_balance'] = $oldBalance - $record['cctransaction_amount']; $balance['registration_balance'] = $balanceGetter->simpleCalcBalanceOwing($values['reg_id']); $singleReg->loadFromArray($balance); $singleReg->updateDBTable(); } } }
/** Returns CSV containing: scholarshipTotal, cashTotal, cashOwed, ccTotal **/ protected function getFinancialTotals() { // get scholarship total $scholarship_total = $this->getScholarshipsTotal(); if (!isset($scholarship_total)) { $scholarship_total = 0; } // $this->template->set('scholarshipTotal', $scholarship_total ); // get cash total $cash_total = $this->getCashPaidTotal(); if (!isset($cash_total)) { $cash_total = 0; } // $this->template->set('cashTotal', $cash_total ); // get cash owed $cash_owing = $this->getCashOwedTotal(); if (!isset($cash_owing)) { $cash_owing = 0; } // $this->template->set('cashOwed', $cash_owing ); // get credit card total $cc_total = $this->getCCtransTotal(); if (!isset($cc_total)) { $cc_total = 0; } // $this->template->set('ccTotal', $cc_total ); $totalPaid = $scholarship_total + $cash_total + $cc_total; if ($totalPaid + $cash_owing >= $this->deposit) { $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); } // set the balance-owing column in the cim_reg_registration table $owed = $this->basePriceForThisGuy - $scholarship_total - $cash_total - $cc_total; $registration = new RowManager_RegistrationManager($this->reg_id); $registration->setBalanceOwing($owed); $balance = array(); $balance['registration_balance'] = $owed; $registration->loadFromArray($balance); $registration->updateDBTable(); return $scholarship_total . ',' . $cash_total . ',' . $cash_owing . ',' . $cc_total; }
/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to the module's root dir. * @param $viewer [OBJECT] The viewer object. * @param $sortBy [STRING] Field data to sort listManager by. * @param $managerInit [INTEGER] Initialization value for the listManager. * @return [void] */ function __construct($pathModuleRoot, $viewer, $sortBy, $reg_id, $cctrans_id = '', $personID = '') { // parent::__construct( page_DisplayCCtransactionReceipt::DISPLAY_FIELDS ); $formAction = ''; $fieldList = page_DisplayCCtransactionReceipt::FORM_FIELDS; $fieldTypes = page_DisplayCCtransactionReceipt::FORM_FIELD_TYPES; $displayFields = page_DisplayCCtransactionReceipt::DISPLAY_FIELDS; parent::__construct($viewer, $formAction, $sortBy, $fieldList, $fieldTypes, $displayFields); $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->sortBy = $sortBy; $this->reg_id = $reg_id; // echo "REG_ID =".$reg_id; if (isset($_POST['cctransaction_id'])) { $this->cctrans_id = $_POST['cctransaction_id']; } else { $this->cctrans_id = $cctrans_id; } // echo "CCTRANSID = <pre>".$this->cctrans_id."</pre>"; // just let these be empty if they are passed as empty $this->person_id = $personID; $registration = new RowManager_RegistrationManager(); // $registration->setSortOrder( $sortBy ); $registration->setRegID($this->reg_id); $person = new RowManager_PersonManager(); $campus = new RowManager_CampusManager(); $assign = new RowManager_AssignmentsManager(); $campusStatus = new RowManager_CampusAssignmentStatusManager(); $status = new RowManager_StatusManager(); // join 2 tables together: cim_reg_registration & cim_hrdb_person $this->statusManager = new MultiTableManager(); $this->statusManager->addRowManager($registration); $this->statusManager->addRowManager($person, new JoinPair($person->getJoinOnPersonID(), $registration->getJoinOnPersonID())); $this->statusManager->addRowManager($assign, new JoinPair($person->getJoinOnPersonID(), $assign->getJoinOnPersonID())); $this->statusManager->addRowManager($campus, new JoinPair($campus->getJoinOnCampusID(), $assign->getJoinOnCampusID())); $this->statusManager->addRowManager($campusStatus, new JoinPair($assign->getJoinOnStatusID(), $campusStatus->getJoinOnStatusID())); $this->statusManager->addRowManager($status, new JoinPair($registration->getJoinOnStatus(), $status->getJoinOnStatusID())); // $multiTableManager2->setLabelTemplate('viewer_userID', '[viewer_userID]'); // $this->listManager = $regPerson->getListIterator(); // $regsArray = $this->listManager->getDataList(); // echo "<pre>".print_r($this->listManager,true)."</pre>"; // echo "<pre>".print_r($regsArray,true)."</pre>"; $this->ccTransManager = new MultiTableManager(); $ccTrans = new RowManager_CreditCardTransactionManager(); $ccTrans->setCCtransID($this->cctrans_id); // $ccTrans->setSortOrder( $sortBy ); $ccType = new RowManager_CreditCardTypeManager(); $this->ccTransManager->addRowManager($ccTrans); $this->ccTransManager->addRowManager($ccType, new JoinPair($ccType->getJoinOnTypeID(), $ccTrans->getJoinOnTypeID())); $this->receiptManager = new RowManager_ReceiptManager(); $this->receiptManager->setCCtransID($this->cctrans_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 = modulecim_reg::MULTILINGUAL_PAGE_FIELDS; $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey); // then load the page specific labels for this page $pageKey = page_DisplayCCtransactionReceipt::MULTILINGUAL_PAGE_KEY; $this->labels->loadPageLabels($pageKey); $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. * * ON JAN 2, 2008 Russ made two changes to this page to restore the original functionality... they are documented below. * ON JAN 8, 2008 Hobbe added conditional statements to allow registration record searches IF viewer has Reg. Sys. Super Admin privs. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: $privManager = new PrivilegeManager($this->viewer->getID()); if ($privManager->isSuperAdmin() == true) { $path = SITE_PATH_TEMPLATES; } else { // Changed by RM from using the assignment below on Jan 2, 2008. $path = $this->pathModuleRoot . 'templates/'; } // Otherwise use the standard Templates for the site: // $path = SITE_PATH_TEMPLATES; /* * store the link values */ // example: // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); // $this->linkLabels[ 'cont' ] = $this->labels->getLabel( '[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; /* * store any additional link Columns */ // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); /* * Update any label tags ... */ // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); // store the statevar id to edit $this->template->set('editEntryID', $this->registration_id); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Form related Template variables: */ /* * Insert the date start/end values for the following date fields: */ // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * List related Template variables : */ // Store the XML Node name for the Data Access Field List $xmlNodeName = RowManager_RegistrationManager::XML_NODE_NAME; $this->template->set('rowManagerXMLNodeName', $xmlNodeName); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'registration_id'); // store data list to the template // NOTE: we initialize it here to make sure we capture any new data // from a recent processData() call. if ($this->person_id != '') { $dataAccessManager = new RowManager_RegistrationManager(); $dataAccessManager->setPersonID($this->person_id); $dataAccessManager->setSortOrder($this->sortBy); // $this->dataList = new PriceRuleList( $this->sortBy ); $this->dataList = $dataAccessManager->getListIterator(); $this->template->setXML('dataList', $this->dataList->getXML()); } // else // { // $this->dataList = array(); // // $this->template->setXML( 'dataList', $this->dataList->getXML() ); // } /* * Add any additional data required by the template here */ $person = new RowManager_PersonManager(); $person->setLabelTemplateLastNameFirstName(); // $field->setPersonID( $this->person_id); $person->setSortOrder('person_lname, person_fname'); $personList = new ListIterator($person); $personArray = $personList->getDropListArray(); $this->template->set('list_person_id', $personArray); $notice = "<br><b>NOTE:</b> Duplicate names may appear if a person has multiple records."; $this->template->set('note_person_id', $notice); $event = new RowManager_EventManager(); // $field->setPersonID( $this->person_id); $eventList = new ListIterator($event); $eventArray = $eventList->getDropListArray(); $this->template->set('list_event_id', $eventArray); $status = new RowManager_StatusManager(); $statusList = new ListIterator($status); $statusArray = $statusList->getDropListArray(); $this->template->set('list_registration_status', $statusArray); // // $nameFields = 'person_lname,person_fname'; // $template = '[person_lname], [person_fname]'; // $this->dataManager->setLabelTemplate( $nameFields, $template ); if ($privManager->isSuperAdmin() == true) { $templateName = 'siteSearchFormDataList.php'; //'page_HrdbHome.php'; } else { // Changed by RM on Jan 2, 2008 - We can't have just anybody being able to access this data. $templateName = 'page_HrdbHome.php'; } // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditPriceRules.php'; return $this->template->fetch($templateName); }
protected function storeRegStatus($regID = '', $reg_status) { $success = true; if ($regID != '') { $regs = new RowManager_RegistrationManager(); $regs->setRegID($this->reg_id); $status = new RowManager_StatusManager(); $status->setStatusDesc($reg_status); $statusList = $status->getListIterator(); $statusArray = $statusList->getDataList(); $status_id = -1; reset($statusArray); // should be only 1 record for a particular status description foreach (array_keys($statusArray) as $k) { $record = current($statusArray); $status_id = $record['status_id']; next($statusArray); } if ($status_id == -1) { $success = false; return $sucess; } $updateValues = array(); $updateValues['registration_id'] = $this->reg_id; $updateValues['registration_status'] = $status_id; // mark registration as being REGISTERED // Store values in RegistrationManager object $regs->loadFromArray($updateValues); // echo "<pre>".print_r($this->formValues ,true)."</pre>"; // update information $regs->updateDBTable(); return $success; } else { $success = false; } }
/** * 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); }
$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); } echo "SUCCESS!"; } else { echo "PRIVILEGE LEVEL NOT HIGH ENOUGH..."; }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // initialize the variable storing process report data $reportDataDump = ''; $BR = '<BR>'; $HR = '<HR>'; // Make a new Template object $path = $this->pathModuleRoot . 'templates/'; // $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['cont'] = $this->labels->getLabel('[GoBack]'); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->prepareTemplate($path); /** Get list of unique triples of first name, last name, and e-mail address **/ // $allPeople = array(); // NOT USED BECAUSE WE HAVE NESTED LOOP INSTEAD OF MULTIPLE LOOPS $personRecords = new MultiTableManager(); $personRecords->addRowManager($this->person_manager); $personRecords->setSortOrder('person_lname'); // echo 'filters = '.$this->filter_fname.', '.$this->filter_lname.', '.$this->filter_email; /**** DATA FILTERS: USED TO ENSURE 60 SEC TIME-OUT IS NOT VIOLATED ****/ $personRecords->addSearchCondition("person_fname like '" . $this->filter_fname . "%'"); $personRecords->addSearchCondition("person_lname like '" . $this->filter_lname . "%'"); $personRecords->addSearchCondition("person_email like '" . $this->filter_email . "%'"); // use GROUP BY to easily enforce distinct triplets of (person_fname, person_lname, person_email) $groupBy = "person_fname,person_lname,person_email"; $personRecords->setGroupBy($groupBy); $personData = $personRecords->getListIterator(); $personDataArray = $personData->getDataList(); /** Go through the list of names 1 by 1, running another query to find if duplicates exist **/ reset($personDataArray); foreach (array_keys($personDataArray) as $k) { $savedPersonID = -1; // the only person ID left in the database for this individual $person = current($personDataArray); $person_fname = $person['person_fname']; $person_lname = $person['person_lname']; $person_email = $person['person_email']; $reportDataDump .= 'Unique person record tuple:' . $BR . ' First Name = ' . $person_fname . ', Last Name = ' . $person_lname . ', E-mail = ' . $person_email . $BR . $BR; // echo "PERSON NAME: ".$person_fname." ".$person_lname; // echo "PERSON: <pre>".print_r($person,true)."</pre>"; // search for a particular person to see if duplicate records exist $indiv_person_manager = new RowManager_PersonManager(); $indiv_person_manager->setFirstName(addslashes($person_fname)); // use addslashes to escape special chars in string $indiv_person_manager->setLastName(addslashes($person_lname)); $indiv_person_manager->setEmail(addslashes($person_email)); $indiv_person_manager->setSortOrder('person_id'); $indiv_person_manager->setAscDesc('DESC'); // sort by descending person IDs $indivData = $indiv_person_manager->getListIterator(); $indivDataArray = $indivData->getDataList(); // echo " INDIV COUNT: ".count($indivDataArray)."<br><br>"; // echo "INDIV RECORDS: <pre>".print_r($indivDataArray,true)."</pre>"; $person_ids_list = ''; //return all the person's data into array (key = person_id) of arrays (and store total data stored?) if (isset($indivDataArray)) { if (count($indivDataArray) == 0) { echo "ERROR: person was found earlier and now NO records are found!"; } else { if (count($indivDataArray) == 1) { // echo "GREAT! This person only has one record."; reset($indivDataArray); $record = current($indivDataArray); $savedPersonID = $record['person_id']; $person_ids_list = $savedPersonID; $reportDataDump .= 'Unique person id found for tuple: ' . $savedPersonID . $BR . $BR; } else { if (count($indivDataArray) > 1) { // get the person IDs for this individual reset($indivDataArray); foreach (array_keys($indivDataArray) as $l) { $record = current($indivDataArray); $person_ids_list .= $record['person_id']; $person_ids_list .= ','; next($indivDataArray); } $person_ids_list = substr($person_ids_list, 0, -1); // remove final comma $reportDataDump .= 'Multiple person ids found for tuple: ' . $person_ids_list . $BR . $BR; } } } // Search for duplicate person-related entries - for 1 or more person_ids found for current person if ($person_ids_list != '') { // echo "<br> person ids list: ".$person_ids_list."<br>"; // $person_ids_array = explode($person_ids_list,','); // check access table using all the found person IDs - retrieve viewer ids with person id as key $foundViewerIDs = $this->getAccessRecords($person_ids_list); // can safely assume array ISSET // echo 'found viewer ids= <pre>'.print_r($foundViewerIDs,true).'</pre>'; /** IF 0 access table records were found: **/ if (count($foundViewerIDs) == 0) { // TODO?: notify admin that this/these person record(s) require a viewer account // Store the active (latest) person_id in special variable reset($indivDataArray); $savedPersonID = key($indivDataArray); // recall that person_ids are sorted in descending order } else { if (count($foundViewerIDs) >= 1) { // echo "<br>found viewer IDs: <pre>".print_r($foundViewerIDs, true)."</pre>"; /** Get the associated viewer_id with the most recent login date **/ // $viewers = new RowManager_ViewerManager(); // $viewer_ids = ''; // reset($foundViewerIDs); // foreach (array_keys($foundViewerIDs) as $key) // { // // $record = current($foundViewerIDs); // $viewer_ids .= $key.','; //$record // // next($foundViewerIDs); // } // $viewer_ids = substr($viewer_ids, 0, -1); // remove final comma // // echo 'viewer_ids list = '.$viewer_ids.'<br>'; // $viewers->addSearchCondition("viewer_id in (".$viewer_ids.")"); // // $viewersData = $viewers->getListIterator(); // $viewersArray = $viewersData->getDataList(); // // // echo 'viewers array data = <pre>'.print_r($viewersArray,true).'</pre>'; // // $mostRecentDate = '0000-00-00'; // $mostRecentViewer = -1; // reset($viewersArray); // foreach(array_keys($viewersArray) as $l) // { // $record = current($viewersArray); // $foundDate = $record['viewer_lastLogin']; // $viewerID = $record['viewer_id']; // // // update most recent date if a more recent login date was found // if ($foundDate > $mostRecentDate) // { // $mostRecentDate = $foundDate; // $mostRecentViewer = $viewerID; // set viewer_id to use // } // } // TODO: add loop here to check if all $foundViewerIDs (from access table) are in viewers table // <loop> // if (in_array($foundViewerIDs[index], array_keys($viewersArray))) // delete $foundViewerIDs[index] from access table // <end-loop> // echo 'most recent viewer id = '.$mostRecentViewer; // echo 'viewer ids from list = <pre>'.print_r(array_keys($foundViewerIDs),true).'</pre>'; /** store the active (access table) person_id in special variable **/ reset($foundViewerIDs); // // (NEW) == person_id associated with the viewer_id having the most recent login date // // ONLY IN THE CASE WHERE PERSON HAS MORE THAN 1 VIEWER_ID // if (($mostRecentViewer != -1)&&(count($viewersArray) > 1)) // { // $temp_viewerIDs = array_keys($foundViewerIDs); // gets the viewer ids // $temp_personIDs = array_values($foundViewerIDs); // gets the person ids // $index = array_search($mostRecentViewer, $temp_viewerIDs); // get index having most recent viewer_id // // $savedPersonID = $temp_personIDs[$index]; // $reportDataDump .= 'Person ID of the record to keep: '.$savedPersonID.' (associated with most recent login)'.$BR.$BR; // } // else // FORMERLY: (OLD) == latest viewer-associated person ID, since array is ordered by person_id (DESC) // { $personIDs = explode(',', $person_ids_list); $savedPersonID = current($personIDs); //current($foundViewerIDs); $reportDataDump .= 'Person ID of the record to keep: ' . $savedPersonID . ' (associated with the most recent person record)' . $BR . $BR; // } // echo 'latest viewer ids = <pre>'.print_r($foundViewerIDs,true).'</pre>'; // echo 'saved person ID = '.$savedPersonID; $reportDataDump .= 'Changes made to <b>cim_hrdb_access table</b>: ' . $BR; /*** update the access table records to only use latest person ID **/ foreach (array_values($foundViewerIDs) as $person_id) { $viewer_id = key($foundViewerIDs); // echo 'viewer_id = '.$viewer_id; // only update the access table record if it needs a different person_id if ($person_id != $savedPersonID) { // get access ID(s) for the record to change $accessManager = new RowManager_AccessManager(); $accessManager->setViewerID($viewer_id); $accessManager->setPersonID(current($foundViewerIDs)); // or just use $person_id $accessData = $accessManager->getListIterator(); $accessDataArray = $accessData->getDataList(); // echo 'access data array = <pre>'.print_r($accessDataArray,true).'</pre>'; reset($accessDataArray); // deal with the unlikely case that we have redundant viewerID-personID records foreach (array_keys($accessDataArray) as $key) { $record = current($accessDataArray); $accessID = $record['access_id']; // set the values to set in the record (using 'access_id' as search key) $updateValues = array(); $updateValues['access_id'] = $accessID; $updateValues['viewer_id'] = $viewer_id; $updateValues['person_id'] = $savedPersonID; // only data that is changed $reportDataDump .= 'Updating person_id ' . $person_id . ' to be ' . $savedPersonID . $BR . $BR; $accessManager->loadFromArray($updateValues); $accessManager->updateDBTable(); next($accessDataArray); } } $id = next($foundViewerIDs); // person_id if ($id === FALSE) { break; // no valid data found so break out of the loop } } } } /** <end> access table update **/ $baseRecord = $indivDataArray[$savedPersonID]; // echo "<br>base record: <pre>".print_r($baseRecord,true)."</pre><br>"; $flagArray = $this->checkPersonRecordFields($baseRecord); // echo "<br>flag array: <pre>".print_r($flagArray,true)."</pre><br>"; // Add data from other records to the stored latest person record, if required // (i.e. if latest data misses phone #, etc) reset($indivDataArray); foreach (array_keys($indivDataArray) as $id) { $record = current($indivDataArray); $personID = $record['person_id']; if ($personID != $savedPersonID) { $personUpdater = new RowManager_PersonManager(); $personUpdater->setPersonID($savedPersonID); $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $nextFlagArray = $this->checkPersonRecordFields($indivDataArray[$personID]); // echo "<br>next flag array: <pre>".print_r($nextFlagArray,true)."</pre><br>"; reset($flagArray); foreach (array_keys($flagArray) as $m) { // if field is empty in active record then // replace with most recent value - if one exists // (since we are going through a list of person ids // in descending order) $flag = current($flagArray); if ($flag == '0') { $fieldName = key($flagArray); // check if the replacement person record has a non-empty field if ($nextFlagArray[$fieldName] == '1') { $updateValues[$fieldName] = $record[$fieldName]; $flagArray[$fieldName] = '1'; // prevents less-recent person data to overwrite what was just written } } next($flagArray); } // echo "<br>update values: <pre>".print_r($updateValues,true)."</pre><br>"; // update the active person record (in database) if (count($updateValues) > 1) { $reportDataDump .= 'Adding the following data to our preferred <b>cim_hrdb_person</b> record (using given person_id): '; $reportDataDump .= '<pre>' . print_r($updateValues, true) . '</pre>' . $BR . $BR; $personUpdater->loadFromArray($updateValues); $personUpdater->updateDBTable(); } } next($indivDataArray); } } // end "if >1 person id found for the person data" /** Go through various tables and clean out or update records related to the current person **/ // Update and clean-up the Person-Year table (cim_hrdb_person_year) // Step 1) Find the information stored for the active person_id $personYearArray = array(); $person_year_manager = new RowManager_PersonYearManager(); $person_year_manager->setPersonID($savedPersonID); $person_year_manager->setSortOrder('personyear_id'); $person_year_manager->setAscDesc('DESC'); // sort by descending personyear IDs // echo "<BR>".$savedPersonID.","; $personYearData = $person_year_manager->getListIterator(); $person_year_array = $personYearData->getDataList(); reset($person_year_array); foreach (array_keys($person_year_array) as $key) { $record = current($person_year_array); $person_year_id = $record['personyear_id']; $year_id = $record['year_id']; $personYearArray[$person_year_id] = $year_id; // store person_id associated with the person_year_id next($person_year_array); } // if (count($person_year_array) > 0) // { // echo "<br>Years for active person_id ".$savedPersonID.": <pre>".print_r($personYearArray,true)."</pre><br>"; // } // echo "Person IDs list: ".$person_ids_list."<br>"; $reportDataDump .= 'Changes made to <b>cim_hrdb_person_year table</b>: ' . $BR; // remove all but the most recent person-year record (associated with active person id) if (count($personYearArray) > 1) { reset($personYearArray); $person_year_id = key($personYearArray); $reportDataDump .= 'Saving the first person year record associated with person ID ' . $savedPersonID . $BR . $BR; next($personYearArray); // keep the first record (most recent personyear_id foreach (array_keys($personYearArray) as $m) { $record = current($personYearArray); $personYearID = key($personYearArray); // echo "REMOVE person-year entry for person_id = ".$savedPersonID." using key = ".key($personYearArray); if (isset($personYearID) && $personYearID != '' && $personYearID > 0) { $reportDataDump .= 'Deleting redundant person year record having year ID ' . $record . $BR . $BR; $personYearUpdater = new RowManager_PersonYearManager($personYearID); $personYearUpdater->deleteEntry(); } next($personYearArray); } } // Step 2) Update the records having the non-active person ids for this person $person_year_manager2 = new RowManager_PersonYearManager(); $person_year_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_year_manager2->setSortOrder('person_id'); $person_year_manager2->setAscDesc('DESC'); // sort by descending person IDs $personYearData2 = $person_year_manager2->getListIterator(); $person_year_array2 = $personYearData2->getDataList(); // echo "<br>Years for ALL person_ids: <pre>".print_r($person_year_array2,true)."</pre><br>"; // If no record was found for the active person record - then set flag for updating $updated = true; if (count($personYearArray) < 1) { $updated = false; } reset($person_year_array2); $j = 0; foreach (array_keys($person_year_array2) as $l) { $record = current($person_year_array2); $personID = $record['person_id']; // We ignore records with the active person id - since we dealt with those redundancies already if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $person_year_id = $record['personyear_id']; $personYearUpdater = new RowManager_PersonYearManager($person_year_id); // $personYearUpdater->setPersonYearID($person_year_id); $person_id = $record['person_id']; $year_id = $record['year_id']; // check to see if identical information was already stored under active person_id // if (in_array($year_id, $personYearArray)) // { if ($updated == false) { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $updateValues['year_id'] = $year_id; // echo "<br>update values to ".$savedPersonID." from ".$person_id.": <pre>".print_r($person_year_array2,true)."</pre><br>"; // update the person ID for a person-DG record (in database) $personYearUpdater->loadFromArray($updateValues); $personYearUpdater->updateDBTable(); $updated = true; // prevents the new data from being overwritten with older data (and allows better efficiency) $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $person_id . $BR . $BR; } else { // echo "<br>TO BE DELETED FROM cim_hrdb_person_year: person_id = ".$personID.", year = ".$year_id."<br>"; $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; $personYearUpdater->deleteEntry(); } // else // add person-year data from other person-id-linked records // { // $updateValues = array(); // $updateValues['person_id'] = $savedPersonID; // just to make sure... // $updateValues['year_id'] = $year_id; // // echo "<br>update values to ".$savedPersonID." from ".$person_id.": <pre>".print_r($person_year_array2,true)."</pre><br>"; // // // update the person ID for a person-DG record (in database) // $personYearUpdater->loadFromArray( $updateValues ); // $personYearUpdater->updateDBTable(); // } } next($person_year_array2); } // Update the Emergency Contact table (cim_hrdb_emerg) // Step 1) Find the information stored for the active person_id $emergInfoArray = array(); $emerg_info_manager = new RowManager_EmergencyInfoManager(); $emerg_info_manager->setPersonID($savedPersonID); $emerg_info_manager->setSortOrder('emerg_id'); $emerg_info_manager->setAscDesc('DESC'); // sort by descending emerg IDs // echo "<BR>".$savedPersonID.","; $emergInfoData = $emerg_info_manager->getListIterator(); $emerg_info_array = $emergInfoData->getDataList(); reset($emerg_info_array); foreach (array_keys($emerg_info_array) as $l) { $record = current($emerg_info_array); $emerg_id = $record['emerg_id']; $emerg_info = array(); $fields = page_PersonRecordCleanUp::EMERG_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the emergency info values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $emerg_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // $emerg_info['person_id'] = $record['person_id']; // $emerg_info['emerg_passportNum'] = $record['emerg_passportNum']; // $emerg_info['emerg_passportOrigin'] = $record['emerg_passportOrigin']; // $emerg_info['emerg_passportExpiry'] = $record['emerg_passportExpiry']; // $emerg_info['emerg_contactName'] = $record['emerg_contactName']; // $emerg_info['emerg_contactRship'] = $record['emerg_contactRship']; // $emerg_info['emerg_contactHome'] = $record['emerg_contactHome']; // $emerg_info['emerg_contactWork'] = $record['emerg_contactWork']; // $emerg_info['emerg_contactMobile'] = $record['emerg_contactMobile']; // $emerg_info['emerg_contactEmail'] = $record['emerg_contactEmail']; // $emerg_info['emerg_birthdate'] = $record['emerg_birthdate']; // $emerg_info['emerg_medicalNotes'] = $record['emerg_medicalNotes']; // store array of record values in array with emerg_id as key $emergInfoArray[$emerg_id] = $emerg_info; next($emerg_info_array); } // TEST CONDITION // if (count($emerg_info_array) > 0) // { // echo "<br>Emergency info for active person_id ".$savedPersonID.": <pre>".print_r($emergInfoArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_emerg table</b>: ' . $BR; // remove all but the most recent emergency info record (associated with active person id) if (count($emergInfoArray) > 1) { reset($emergInfoArray); $reportDataDump .= 'Saving the emergency contact record associated with person ID ' . $savedPersonID . $BR . $BR; next($emergInfoArray); // keep the first record (most recent emerg_id) foreach (array_keys($emergInfoArray) as $m) { $record = current($emergInfoArray); $emergID = key($emergInfoArray); // echo "REMOVE person-emerg entry for person_id = ".$savedPersonID." using key = ".key($emergInfoArray); if (isset($emergID) && $emergID != '') { $emergUpdater = new RowManager_EmergencyInfoManager($emergID); $emergUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant emergency contact record having emergency ID ' . $emergID . $BR . $BR; } next($emergInfoArray); } } // Step 2) Update the emergency contact records having the non-active person ids for this person $emerg_info_manager2 = new RowManager_EmergencyInfoManager(); $emerg_info_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $emerg_info_manager2->setSortOrder('person_id'); $emerg_info_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $emergInfoData2 = $emerg_info_manager2->getListIterator(); $emerg_info_array2 = $emergInfoData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; $updateValues = array(); // $updateValues = $this->initRecord(page_PersonRecordCleanUp::EMERG_RECORD_FIELDS); // $updateID = -1; // // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personYearArray) < 1) // { // $updated = false; // } reset($emerg_info_array2); foreach (array_keys($emerg_info_array2) as $l) { $record = current($emerg_info_array2); $personID = $record['person_id']; $contactName = $record['emerg_contactName']; if ($personID != $savedPersonID) { $emerg_id = $record['emerg_id']; $personEmergUpdater = new RowManager_EmergencyInfoManager($emerg_id); // $personEmergUpdater->setPersonEmergID($emerg_id); $person_id = $record['person_id']; if (count($emergInfoArray) < 1) { // update the last-updated record with further information (if there was a last update) // if ($updateID != -1) // { // $personEmergUpdater = new RowManager_EmergencyInfoManager($updateID); // } // TODO: reactivate the above and then delete all entries but the first totally updated record $record['person_id'] = $savedPersonID; // require this to actually change person ID // // determine if some fields have been replaced previously // $flagArray = $this->checkRecordFields($updateValues, page_PersonRecordCleanUp::EMERG_RECORD_FIELDS); // // reset($flagArray); // foreach(array_keys($flagArray) as $m) // { // // if field is empty in update record then // // replace with most recent value - if one exists // // (since we are going through a list of person ids // // in descending order) // $flag = current($flagArray); // if ($flag == '0') // { // $fieldName = key($flagArray); // $updateValues[$fieldName] = $record[$fieldName]; // update the array (or replace empty with empty) // } // next($flagArray); // } // (BELOW) REMOVE WHEN USING ABOVE: $updateValues['person_id'] = $savedPersonID; // update the person ID for an emergency contact record (in database) $personEmergUpdater->loadFromArray($updateValues); $personEmergUpdater->updateDBTable(); // $updateID = $emerg_id; // TODO: ensure that we end up with only ONE record that is updated with latest data $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $person_id . $BR . $BR; } else { $contact_name = $record['emerg_contactHome']; // echo "<br>TO BE DELETED FROM cim_hrdb_emerg: person_id = ".$person_id.", contactName = ".$contact_name."<br>"; $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . ' having contact name = ' . $contactName . $BR . $BR; $personEmergUpdater->deleteEntry(); } } next($emerg_info_array2); } /**** TODO: have code to deal with redundant person ids in 'cim_hrdb_admin' (LOW-PRIORITY DUE TO SMALL SIZE OF TABLE) **/ /*** Update the Campus Assignment table (cim_hrdb_assignment) **/ // Step 1) Find the information stored for the active person_id $campusAssignArray = array(); $campus_assign_manager = new RowManager_AssignmentsManager(); $campus_assign_manager->setPersonID($savedPersonID); $campus_assign_manager->setSortOrder('assignment_id'); $campus_assign_manager->setAscDesc('DESC'); // sort by descending assignment IDs $campusAssignData = $campus_assign_manager->getListIterator(); $campus_assign_array = $campusAssignData->getDataList(); reset($campus_assign_array); foreach (array_keys($campus_assign_array) as $id) { $record = current($campus_assign_array); $assign_id = $record['assignment_id']; $assignment_info = array(); $fields = page_PersonRecordCleanUp::ASSIGNMENT_RECORD_FIELDS; $fieldsArray = explode(",", $fields); // store the campus assignment values in an array reset($fieldsArray); foreach (array_keys($fieldsArray) as $k) { $fieldName = current($fieldsArray); $assignment_info[$fieldName] = $record[$fieldName]; next($fieldsArray); } // store array of record values in array with assign_id as key $campusAssignArray[$assign_id] = $assignment_info; next($campus_assign_array); } // TEST CONDITION // if (count($campus_assign_array) > 0) // { // echo "<br>Campus assignment info for active person_id ".$savedPersonID.": <pre>".print_r($campusAssignArray,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_assignment table</b>: ' . $BR; // TODO??: remove all but the most recent campus assignment record (associated with active person id) // REMEMBER: a student may be an alumni of one school or attend two schools at once... if (count($campusAssignArray) > 1) { $campus_ids_list = array(); $idx = 0; reset($campusAssignArray); $row = current($campusAssignArray); $campus_ids_list[$idx++] = $row['campus_id']; next($campusAssignArray); // keep the first record (most recent assign_id) foreach (array_keys($campusAssignArray) as $m) { $record = current($campusAssignArray); $assignID = key($campusAssignArray); // echo "REMOVE person-campus entry for person_id = ".$savedPersonID." using key = ".key($campusAssignArray); if (isset($assignID) && $assignID != '') { // remove entries having a campus_id already stored for the active person record if (in_array($record['campus_id'], $campus_ids_list)) { $assignUpdater = new RowManager_AssignmentsManager($assignID); $assignUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant campus assignment record having campus ID ' . $record['campus_id'] . $BR . $BR; } else { $campus_ids_list[$idx++] = $record['campus_id']; } } next($campusAssignArray); } } // Step 2) Update the campus assignment records having the non-active person ids for this person $campus_assign_manager2 = new RowManager_AssignmentsManager(); $campus_assign_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $campus_assign_manager2->setSortOrder('person_id'); $campus_assign_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $campusAssignData2 = $campus_assign_manager2->getListIterator(); $campus_assign_array2 = $campusAssignData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; $campusIDs = array(); $idx = 0; reset($campus_assign_array2); foreach (array_keys($campus_assign_array2) as $l) { $record = current($campus_assign_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $assignment_id = $record['assignment_id']; $campus_id = $record['campus_id']; $personAssignmentUpdater = new RowManager_AssignmentsManager($assignment_id); // $personEmergUpdater->setPersonEmergID($emerg_id); $person_id = $record['person_id']; if (count($campusAssignArray) < 1) { $record['person_id'] = $savedPersonID; // require this to actually change person ID // only create a new record with active person id if the campus ID not associated with the person yet if (!in_array($campus_id, $campusIDs)) { // update the person ID for an campus assignment record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $personAssignmentUpdater->loadFromArray($updateValues); $personAssignmentUpdater->updateDBTable(); $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ' (with campus ID ' . $campus_id . '),<br>'; $reportDataDump .= 'updating person ID for person ID ' . $person_id . $BR . $BR; $campusIDs[$idx++] = $campus_id; } else { // echo "<br>Delete op #1."; $personAssignmentUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; } } else { // echo "<br>TO BE DELETED FROM cim_hrdb_emerg: person_id = ".$person_id.", campus_id = ".$campus_id."<br>"; $personAssignmentUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $person_id . $BR . $BR; } } next($campus_assign_array2); } /*** Update the Registrations table (cim_reg_registration) **/ /** NOTE: Currenlty only use step 2, which simply replace associated person IDs with active person ID **/ // Step 1) Find the information stored for the active person_id // $regRecordsArray = array(); // $idx = 0; // // $registration_manager = new RowManager_RegistrationManager(); // $registration_manager->setPersonID($savedPersonID); // $registration_manager->setSortOrder( 'registration_id' ); // $registration_manager->setAscDesc( 'DESC' ); // sort by descending registration IDs // // // echo "<BR>".$savedPersonID.","; // $registrationData = $registration_manager->getListIterator(); // $regs_array = $registrationData->getDataList(); // reset($regs_array); // foreach(array_keys($regs_array) as $id) // { // $record = current($regs_array); // // $reg_id = $record['registration_id']; // // $registration_info = array(); // // // $fields = page_PersonRecordCleanUp::REGISTRATION_RECORD_FIELDS; // // $fieldsArray = explode(",",$fields); // // // // // store the campus assignment values in an array // // reset($fieldsArray); // // foreach(array_keys($fieldsArray) as $k) // // { // // $fieldName = current($fieldsArray); // // // // $registration_info[$fieldName] = $record[$fieldName]; // // // // next($fieldsArray); // // } // // // store array of record values in array with assign_id as key // // $regRecordsArray[$reg_id] = $registration_info; // $regRecordsArray[$idx++] = $reg_id; // // next($regs_array); // } // // // TEST CONDITION // if (count($regs_array) > 0) // { // echo "<br>Registration ids for active person_id ".$savedPersonID.": <pre>".print_r($regRecordsArray,true)."</pre><br>"; // } // TODO??: convert the code below to delete registration records that appear under same person_id (obviously with same event_id) // if (count($regRecordsArray) > 1) // remove ONLY records with redundant person-campus pairs // { // $campus_ids_list = array(); // $idx = 0; // reset($campusAssignArray); // $row = current($campusAssignArray); // $campus_ids_list[$idx++] = $row['campus_id']; // next($campusAssignArray); // keep the first record (most recent emerg_id) // // foreach(array_keys($campusAssignArray) as $m) // { // $record = current($campusAssignArray); // // $assignID = key($campusAssignArray); // // // echo "REMOVE person-campus entry for person_id = ".$savedPersonID." using key = ".key($campusAssignArray); // if ((isset($assignID))&&($assignID != '')) // { // // remove entries having a campus_id already stored for the active person record // if (in_array($record['campus_id'], $campus_ids_list)) // { // $assignUpdater = new RowManager_AssignmentsManager($assignID); // $assignUpdater->deleteEntry(); // } // else // store campus_id so as to remove any other records with this campus_id // { // $campus_ids_list[$idx++] = $record['campus_id']; // } // } // // next($campusAssignArray); // } // // } $reportDataDump .= 'Changes made to <b>cim_reg_registration table</b>: ' . $BR; // Step 2) Update the registration records having the non-active person ids for this person (TODO: work from here) $registration_manager2 = new RowManager_RegistrationManager(); $registration_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $registration_manager2->setSortOrder('person_id'); $registration_manager2->setAscDesc('DESC'); // sort by descending person IDs // echo "candidate person ids = ".$person_ids_list."<br>"; $registrationData2 = $registration_manager2->getListIterator(); $registration_array2 = $registrationData2->getDataList(); // echo "<br>Contact data for ALL person_ids: <pre>".print_r($emerg_info_array2,true)."</pre><br>"; // $eventIDs = array(); // $idx = 0; reset($registration_array2); foreach (array_keys($registration_array2) as $key) { $record = current($registration_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { // echo "FOUND person ".$personID; $registration_id = $record['registration_id']; // $event_id = $record['event_id']; $regRecordUpdater = new RowManager_RegistrationManager($registration_id); // $personEmergUpdater->setPersonEmergID($emerg_id); // if (count($regRecordsArray) < 1) // if active person ID doesn't have record yet, then update older record with active person ID // { // $record['person_id'] = $savedPersonID; // require this to actually change person ID // // only create a new record with active person id if the event_id not associated with the person yet // if (!in_array($event_id, $eventIDs)) // { // update the person ID for an campus assignment record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $regRecordUpdater->loadFromArray($updateValues); $regRecordUpdater->updateDBTable(); $reportDataDump .= 'Found registration record for alternative ID of person ID ' . $savedPersonID . ',' . $BR; $reportDataDump .= 'updating person ID for person ID ' . $personID . $BR . $BR; // $eventIDs[$idx++] = $event_id; // } // else // { // echo "<br>Delete op #1."; // $regRecordUpdater->deleteEntry(); // } // } // else // { // echo "<br>TO BE DELETED FROM cim_reg_registration: person_id = ".$personID.", event_id = ".$event_id."<br>"; // $regRecordUpdater->deleteEntry(); // } } next($registration_array2); } /*** Update the Staff table (cim_hrdb_staff) **/ // Step 1) Find the information stored for the active person_id $staff_manager = new RowManager_StaffManager(); $staff_manager->setPersonID($savedPersonID); $staff_manager->setSortOrder('staff_id'); $staff_manager->setAscDesc('DESC'); // sort by descending assignment IDs // echo "<BR>".$savedPersonID.","; $staffData = $staff_manager->getListIterator(); $staff_array = $staffData->getDataList(); // reset($staff_array); // foreach(array_keys($staff_array) as $id) // { // $record = current($staff_array); // // $staff_id = $record['staff_id']; // $staffRecordsArray[$idx++] = $staff_id; // // next($staff_array); // } // TEST CONDITION // if (count($staff_array) > 0) // { // echo "<br>Staff info for active person_id ".$savedPersonID.": <pre>".print_r($staff_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>cim_hrdb_staff table</b>: ' . $BR; // Step 2) Remove all but one of the staff records if (count($staff_array) > 1) { reset($staff_array); next($staff_array); // keep the first record (most recent staff_id for active person) $reportDataDump .= 'Saving the first staff record associated with person ID ' . $savedPersonID . $BR . $BR; // echo 'staff array = <pre>'.print_r($staff_array,true).'</pre>'; foreach (array_keys($staff_array) as $m) { $record = current($staff_array); $staffID = key($staff_array); // remove redundant entry $staffUpdater = new RowManager_StaffManager($staffID); $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant staff record having staff ID ' . $staffID . $BR . $BR; $id = next($staff_array); // staff ID if ($id === FALSE) { break; // no valid data found so break out of the loop } } } // Step 3) Delete the staff records having the non-active person ids for this person $staff_manager2 = new RowManager_StaffManager(); $staff_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $staff_manager2->setSortOrder('person_id'); $staff_manager2->setAscDesc('DESC'); // sort by descending person IDs $staffData2 = $staff_manager2->getListIterator(); $staff_array2 = $staffData2->getDataList(); $toUpdate = false; if (count($staff_array) < 1) { $toUpdate = true; } reset($staff_array2); foreach (array_keys($staff_array2) as $l) { $record = current($staff_array2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $staff_id = $record['staff_id']; $staffUpdater = new RowManager_StaffManager($staff_id); if ($toUpdate == true) { // $record['person_id'] = $savedPersonID; // require this to actually change person ID // update the person ID for a staff record (in database) $updateValues = array(); $updateValues['person_id'] = $savedPersonID; $staffUpdater->loadFromArray($updateValues); $staffUpdater->updateDBTable(); $toUpdate = false; $reportDataDump .= 'No record found for person ID ' . $savedPersonID . ', updating person ID for person ID ' . $personID . $BR . $BR; } else { // echo "<br>TO BE DELETED FROM cim_hrdb_staff: person_id = ".$person_id.", staff_id = ".$staff_id."<br>"; $staffUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $personID . $BR . $BR; } } next($staff_array2); } /***** Remove redundant sub-group associations, otherwise rename person-id to active person-id ******************/ // Update the Person-DG table (sch_person_sub_group): still requires clean up // Step 1) Find the information stored for the active person_id $dg_campus_array = array(); $person_dg_manager = new RowManager_PersonDGManager(); $person_dg_manager->setPersonID($savedPersonID); $person_dg_manager->setSortOrder('person_sub_group_id'); $person_dg_manager->setAscDesc('DESC'); // sort by descending person_sub_group_IDs $personDGData = $person_dg_manager->getListIterator(); $personDGArray = $personDGData->getDataList(); reset($personDGArray); foreach (array_keys($personDGArray) as $l) { $record = current($personDGArray); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; $dg_campus_array[$dg_id] = $campus_id; next($personDGArray); } // // if (count($dg_campus_array) > 0) // { // echo "<br>DG for active person_id ".$savedPersonID.": <pre>".print_r($personDGArray,true)."</pre><br>"; // // echo "<br>DG-Campus for active person_id ".$savedPersonID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // } $reportDataDump .= 'Changes made to <b>sch_person_sub_group table</b>: ' . $BR; // Step 2) Update the records having the non-active person ids for this person $person_dg_manager2 = new RowManager_PersonDGManager(); $person_dg_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $person_dg_manager2->setSortOrder('person_id'); $person_dg_manager2->setAscDesc('DESC'); // sort by descending person IDs $personDGData2 = $person_dg_manager2->getListIterator(); $personDGArray2 = $personDGData2->getDataList(); // If no record was found for the active person record - then set flag for updating // $updated = true; // if (count($personDGArray2) < 1) // { // $updated = false; // } // $j = 0; // echo 'DG array results = <pre>'.print_r($personDGArray2,true).'</pre>'; // echo 'dg - campus array: <pre>'.print_r($dg_campus_array,true).'</pre>'; reset($personDGArray2); foreach (array_keys($personDGArray2) as $l) { $record = current($personDGArray2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $personSubGroupID = $record['person_sub_group_id']; $personDGUpdater = new RowManager_PersonDGManager($personSubGroupID); $dg_id = $record['sub_group_id']; $campus_id = $record['organization_id']; // echo 'dg-id, campus-id = '.$dg_id.', '.$campus_id.'<br>'; // check to see if identical information was already stored under active person_id if (isset($dg_campus_array[$dg_id]) && $dg_campus_array[$dg_id] == $campus_id) { $personDGUpdater->deleteEntry(); $reportDataDump .= 'Deleting record for alternative person ID ' . $personID . $BR; $reportDataDump .= 'since it has information already stored for primary person ID ' . $savedPersonID . $BR . $BR; // echo "<br>TO BE DELETED FROM sch_person_sub_group: person_id = ".$personID.", dg = ".$dg_id.", campus = ".$campus_id."<br>"; } else { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // just to make sure... $updateValues['sub_group_id'] = $record['sub_group_id']; $updateValues['organization_id'] = $record['organization_id']; // echo "<br>update values from ".$personID.": <pre>".print_r($dg_campus_array,true)."</pre><br>"; // TODO: deal with case where two non-active person-ids contain identical info (currently both are saved with active person id) // update the person ID for a person-DG record (in database) $personDGUpdater->loadFromArray($updateValues); $personDGUpdater->updateDBTable(); $reportDataDump .= 'Updating record for alternative person ID ' . $personID . $BR; $reportDataDump .= 'since it has new information: setting person ID to be ' . $savedPersonID . $BR . $BR; } } next($personDGArray2); } /*** Update the personal schedule table (sch_schedule) **/ // Step 1) Find the information stored for the active person_id $schedule_array = array(); $schedule_manager = new RowManager_ScheduleManager(); $schedule_manager->setPersonID($savedPersonID); $schedule_manager->setSortOrder('schedule_id'); $schedule_manager->setAscDesc('DESC'); // sort by descending schedule_IDs $personScheduleData = $schedule_manager->getListIterator(); $personScheduleArray = $personScheduleData->getDataList(); reset($personScheduleArray); $idx = 0; foreach (array_keys($personScheduleArray) as $l) { $record = current($personScheduleArray); $schedule_block = $record['schedule_block']; $schedule_array[$idx] = $schedule_block; next($personScheduleArray); $idx++; } // echo 'active person schedule = <pre>'.print_r($personScheduleArray,true).'</pre>'; // echo 'person blocks array = <pre>'.print_r($schedule_array,true).'</pre>'; $reportDataDump .= 'Changes made to <b>sch_schedule table</b>: ' . $BR; // Step 2) Create new records for active person ID from data linked to the non-active person ids for this person $schedules = new RowManager_ScheduleManager(); $schedule_manager2 = new MultiTableManager(); $schedule_manager2->addRowManager($schedules); $schedule_manager2->addSearchCondition('person_id in (' . $person_ids_list . ')'); $schedule_manager2->addSortField('person_id', 'DESC'); // $schedule_manager2->setAscDesc( 'DESC' ); // sort by descending person ID $personScheduleData2 = $schedule_manager2->getListIterator(); $personScheduleArray2 = $personScheduleData2->getDataList(); // echo 'other person-ids schedule array = <pre>'.print_r($personScheduleArray2,true).'</pre>'; $toUpdate = false; if (count($schedule_array) < 1) { $toUpdate = true; // echo 'Staff update needed'; } // echo 'schedule array = <pre>'.print_r($personScheduleArray2,true).'</pre>'; $updatePersonID = -1; reset($personScheduleArray2); foreach (array_keys($personScheduleArray2) as $l) { $record = current($personScheduleArray2); $personID = $record['person_id']; if ($personID != $savedPersonID) { $found_sch_block = $record['schedule_block']; $schedule_id = $record['schedule_id']; $personScheduleUpdater = new RowManager_ScheduleManager($schedule_id); // $personScheduleUpdater->setPersonID($personID); // $personScheduleUpdater->setScheduleBlock($found_sch_block); // if the active person_id DOES NOT HAVE this schedule block, then update record with active person id // if (!in_array($found_sch_block, $schedule_array)) // COMMENTED OUT BECAUSE WE DON'T WANT TO MERGE SCHEDULES // { // if the active person_id DOES NOT HAVE **ANY** schedule block, then update record with active person id if ($toUpdate == true || $updatePersonID == $personID) { $updateValues = array(); $updateValues['person_id'] = $savedPersonID; // NEW VALUE $updateValues['schedule_block'] = $found_sch_block; // just to make sure... // update the person ID for a person-DG record (in database) $personScheduleUpdater->loadFromArray($updateValues); $personScheduleUpdater->updateDBTable(); if ($toUpdate == true) { $toUpdate = false; $updatePersonID = $personID; // set person ID whose schedule blocks to use for updating $reportDataDump .= 'No schedule block found for person ID ' . $savedPersonID . ',' . $BR; $reportDataDump .= 'updating using schedule blocks from person ID ' . $updatePersonID . $BR . $BR; } } else { // TODO: enable this code at mid-April 2008 // $personScheduleUpdater->deleteEntry(); // $reportDataDump .= 'Deleting record for alternative person ID '.$personID.$BR.$BR; // TODO: deal with case where two non-active person-ids contain identical info // (currently both are saved with active person id) } } next($personScheduleArray2); } /*** Remove all person records other than the active person ID (most often the one used in most-recent login) ***/ $personIDs = explode(',', $person_ids_list); foreach (array_values($personIDs) as $personID) { if ($personID != $savedPersonID) { $personUpdater = new RowManager_PersonManager($personID); $personUpdater->deleteEntry(); $reportDataDump .= 'Deleting redundant <b>cim_hrdb_person</b> record having person ID ' . $personID . $BR; } next($personIDs); } } // end if (isset($indivDataArray)) $reportDataDump = substr($reportDataDump, 0, -4); // remove the last <BR> $reportDataDump .= $HR; next($personDataArray); } $this->template->set('reportDataDump', $reportDataDump); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', RowManager_ReceiptManager::XML_NODE_NAME ); // store the primary key field name for the data being displayed // $this->template->set( 'primaryKeyFieldName', 'ccreceipt_sequencenum'); /* * Set up any additional data transfer to the Template here... */ $templateName = 'page_PersonRecordCleanUp.tpl.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_DisplayCCtransactionReceipt.php'; // send CC transaction confirmation e-mail (but first remove links) // $link_regex = '{<a.*?</a>}'; // $message_body = $this->template->fetch( $templateName ); // $message_body = preg_replace( $link_regex, '', $message_body); // // if (!defined('IGNORE_EMAILS')) // { // $this->sendCCTransactionEmail($message_body); // } return $this->template->fetch($templateName); }