/** * function calcBalanceOwing * <pre> * calculates the balance owed by the person linked to a particular registration * </pre> * @param $registrant_id [INTEGER] The unique id of the registration we are dealing with. * @return [INTEGER] the balance owing by the registrant */ function simpleCalcBalanceOwing($registrant_id, $eventID = '', $campusID = '') { // variables to fill with data $eventBasePrice = ''; $priceRulesArray = array(); // $rulesApplied = array(); if ($eventID == '') { /** retrieve event ID from registration(s) array **/ $registration = new RowManager_RegistrationManager(); $registration->setRegID($registrant_id); $regsManager = $registration->getListIterator(); $regsArray = $regsManager->getDataList(); // echo "<pre>".print_r($regEventsArray,true)."</pre>"; //NOTE: should be only one record in array reset($regsArray); $result = current($regsArray); $eventID = $result['event_id']; // echo 'eventID = '.$eventID; } if ($campusID == '') { /** Retrieve campus registration data for single registration **/ $summaryTool = new RegSummaryTools(); $regInfo = array(); $regInfo = $summaryTool->getCampusRegistrations($eventID, '', false, '', $registrant_id); //NOTE: should be only one key-value pair reset($regInfo); $campusID = key($regInfo); // since key = campusID and value = total of registrations for that campus // echo 'campusID = '.$campusID; } /** Retrieve event base price **/ $event = new RowManager_EventManager($eventID); $eventBasePrice = $event->getEventBasePrice(); /** Retrieve price rules array **/ $priceRules = new RowManager_PriceRuleManager(); $priceRules->setEventID($eventID); $ruleManager = $priceRules->getListIterator(); $priceRulesArray = $ruleManager->getDataList(); $balanceOwing = 0; /** Use found data to retrieve base price for the $registrant_id parameter **/ $balanceOwing = $this->getBasePriceForRegistrant($registrant_id, $eventID, $campusID, $eventBasePrice, $priceRulesArray); $basePrice = $balanceOwing; // echo '0) original cost = '.$balanceOwing.'<br>'; // echo "<pre>".print_r($rulesApplied,true)."</pre>"; /** Search for scholarships **/ $scholarships = array(); $scholarships = $this->getScholarships($registrant_id); // echo "<pre>".print_r($scholarships,true)."</pre>"; /** Retrieve cash transactions **/ $cash_transactions = array(); $cash_transactions = $this->getCashTransactions($registrant_id); /** Retrieve credit card transactions **/ $cc_transactions = array(); $cc_transactions = $this->getCCTransactions($registrant_id); /** Calculate amount still owing **/ // subtract scholarship money from total owing $refund = array(); reset($scholarships); foreach (array_keys($scholarships) as $k) { $refund = current($scholarships); $balanceOwing -= $refund['scholarship_amount']; // echo '1) new amount = '.$balanceOwing.'<br>'; next($scholarships); } // subtract cash transactions received $cash_paid = array(); $cashReceived = 0; $cashOwed = 0; reset($cash_transactions); foreach (array_keys($cash_transactions) as $k) { $cash_paid = current($cash_transactions); if ($cash_paid['cashtransaction_recd'] == 1) { $balanceOwing -= $cash_paid['cashtransaction_amtPaid']; } // echo '2) new amount = '.$balanceOwing.'<br>'; next($cash_transactions); } // subtract credit card transactions processed $cc_paid = array(); $ccReceived = 0; $ccOwed = 0; reset($cc_transactions); foreach (array_keys($cc_transactions) as $k) { $cc_paid = current($cc_transactions); if ($cc_paid['cctransaction_processed'] == 1) { $balanceOwing -= $cc_paid['cctransaction_amount']; } // echo '3) new amount = '.$balanceOwing.'<br><br>'; next($cc_transactions); } return $balanceOwing; }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object //$this->pathModuleRoot.'templates/'; // Replace $path with the following line if you want to create a // template tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; // $adminLink = $this->linkValues[ 'adminHome' ]; // $this->template->set('adminLink', $adminLink ); // get pricing info // get base price for event participation $event = new RowManager_EventManager($this->event_id); $eventBasePrice = $event->getEventBasePrice(); // get price rules for specific event $priceRules = new RowManager_PriceRuleManager(); $priceRules->setEventID($this->event_id); $ruleManager = $priceRules->getListIterator(); $priceRulesArray = $ruleManager->getDataList(); // echo "<pre>".print_r($priceRulesArray,true)."</pre>"; // array storing the rules applied to a particular registrant $rulesApplied = array(); $priceGetter = new FinancialTools(); $basePriceForThisGuy = $priceGetter->getBasePriceForRegistrant($this->reg_id, $this->event_id, $this->campus_id, $eventBasePrice, $priceRulesArray, $rulesApplied); // get Personal Info $registration = new RowManager_RegistrationManager(); $registration->setRegID($this->reg_id); $person = new RowManager_PersonManager(); $assignment = new RowManager_AssignmentsManager(); // assigns campus to person $campus = new RowManager_CampusManager(); // $campus->setCampusID($this->campus_id); $personalInfo = new MultiTableManager(); $personalInfo->addRowManager($person); $personalInfo->addRowManager($assignment, new JoinPair($person->getJoinOnPersonID(), $assignment->getJoinOnPersonID())); $personalInfo->addRowManager($campus, new JoinPair($campus->getJoinOnCampusID(), $assignment->getJoinOnCampusID())); $personalInfo->addRowManager($registration, new JoinPair($registration->getJoinOnPersonID(), $person->getJoinOnPersonID())); $this->listManager = $personalInfo->getListIterator(); $personInfoArray = $this->listManager->getDataList(); // echo "<pre>".print_r($this->listManager,true)."</pre>"; // echo "<pre>".print_r($personInfoArray,true)."</pre>"; // cycle through registrations and store balance owing for each $this->owingArray = array(); $priceGetter = new FinancialTools(); reset($personInfoArray); foreach (array_keys($personInfoArray) as $k) { $personData = current($personInfoArray); $this->person_id = $personData['person_id']; $this->person_info['person_fname'] = ''; $this->person_info['person_fname'] = $personData['person_fname']; $this->person_info['person_lname'] = ''; $this->person_info['person_lname'] = $personData['person_lname']; $this->person_info['campus_desc'] = ''; $this->person_info['campus_desc'] = $personData['campus_desc']; $this->person_info['person_email'] = ''; $this->person_info['person_email'] = $personData['person_email']; $this->person_info['gender_id'] = ''; $this->person_info['gender_id'] = $personData['gender_id']; $this->person_info['person_local_addr'] = ''; $this->person_info['person_local_addr'] = $personData['person_local_addr']; $this->person_info['person_local_city'] = ''; $this->person_info['person_local_city'] = $personData['person_local_city']; $this->person_info['person_local_province_id'] = ''; $this->person_info['person_local_province_id'] = $personData['person_local_province_id']; $this->person_info['person_local_pc'] = ''; $this->person_info['person_local_pc'] = $personData['person_local_pc']; $this->person_info['person_local_phone'] = ''; $this->person_info['person_local_phone'] = $personData['person_local_phone']; $this->person_info['person_addr'] = ''; $this->person_info['person_addr'] = $personData['person_addr']; $this->person_info['person_city'] = ''; $this->person_info['person_city'] = $personData['person_city']; $this->person_info['province_id'] = ''; $this->person_info['province_id'] = $personData['province_id']; $this->person_info['person_pc'] = ''; $this->person_info['person_pc'] = $personData['person_pc']; $this->person_info['person_phone'] = ''; $this->person_info['person_phone'] = $personData['person_phone']; $this->person_info['registration_status'] = $personData['registration_status']; next($personInfoArray); } $this->linkValues["EditPersonInfo"] .= $this->person_id; $this->prepareTemplate($path); // set current registration status ID $this->template->set('currentRegStatus', $this->person_info['registration_status']); // get list of registration statuses $regStatuses = new RowManager_StatusManager(); $regStatusesList = $regStatuses->getListIterator(); $regStatusesArray = $regStatusesList->getDataList(); $statusList = array(); reset($regStatusesArray); foreach (array_keys($regStatusesArray) as $k) { $record = current($regStatusesArray); $statusList[key($regStatusesArray)] = $record['status_desc']; next($regStatusesArray); } // echo 'status list = <pre>'.print_r($statusList, true).'</pre>'; // set registration status information $this->template->set('statusFormAction', $this->formAction); $this->template->set('statusList', $statusList); $this->template->set('statusButtonText', 'Update'); // set some variables calculated previously; placed here because I need to get PERSON_ID for link // which had to be set before prepareTemplate(), which has to be executed BEFORE setting variables... $this->template->set('eventBasePrice', $eventBasePrice); $this->template->set('priceRules', $rulesApplied); $this->template->set('basePriceForThisGuy', $basePriceForThisGuy); //$priceGetter->calcBalanceOwing($this->reg_id); // NOT NEEDED BECAUSE TOTALS CALCULATED $this->template->set('person', $this->person_info); // get provinces and genders $provinces = new RowManager_ProvinceManager(); $provinceList = $provinces->getListIterator(); $provincesArray = $provinceList->getDataList(); // echo "<pre>".print_r($provincesArray,true)."</pre>"; $province_info = array(); reset($provincesArray); foreach (array_keys($provincesArray) as $k) { $province = current($provincesArray); $province_info[$province['province_id']] = $province['province_desc']; next($provincesArray); } $this->template->set('list_province_id', $province_info); $genders = new RowManager_GenderManager(); $genderList = $genders->getListIterator(); $genderArray = $genderList->getDataList(); // echo "<pre>".print_r($genderArray,true)."</pre>"; $gender_info = array(); reset($genderArray); foreach (array_keys($genderArray) as $k) { $gender = current($genderArray); $gender_info[$gender['gender_id']] = $gender['gender_desc']; next($genderArray); } $this->template->set('list_gender_id', $gender_info); // send in scholarships table, cash transactions table, and credit card transactions table $this->template->set('scholarshipsAdminBox', $this->generateScholarshipsTable()); $this->template->set('cashTransAdminBox', $this->generateCashTransactionsTable()); $this->template->set('ccTransAdminBox', $this->generateCCTransactionsTable()); // get scholarship total $scholarships = new RowManager_ScholarshipAssignmentManager(); $scholarships->setRegID($this->reg_id); $scholarshipTotal = new MultiTableManager(); $scholarshipTotal->addRowManager($scholarships); $scholarshipTotal->setFunctionCall('SUM', 'scholarship_amount'); $scholarshipTotal->setGroupBy('registration_id'); $scholarshipsList = $scholarshipTotal->getListIterator(); $scholarshipsArray = $scholarshipsList->getDataList(); reset($scholarshipsArray); foreach (array_keys($scholarshipsArray) as $k) { $scholarshp = current($scholarshipsArray); $scholarship_total = $scholarshp['SUM(scholarship_amount)']; next($scholarshipsArray); } if (!isset($scholarship_total)) { $scholarship_total = 0; } $this->template->set('scholarshipTotal', $scholarship_total); // get cash total $cashTrans = new RowManager_CashTransactionManager(); $cashTrans->setRegID($this->reg_id); $cashTrans->setReceived(true); $cashTransTotal = new MultiTableManager(); $cashTransTotal->addRowManager($cashTrans); $cashTransTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid'); $cashTransTotal->setGroupBy('reg_id'); $cashTransList = $cashTransTotal->getListIterator(); $cashTransArray = $cashTransList->getDataList(); reset($cashTransArray); foreach (array_keys($cashTransArray) as $k) { $cash_trans = current($cashTransArray); $cash_total = $cash_trans['SUM(cashtransaction_amtPaid)']; next($cashTransArray); } if (!isset($cash_total)) { $cash_total = 0; } $this->template->set('cashTotal', $cash_total); // get cash owed $cashOwed = new RowManager_CashTransactionManager(); $cashOwed->setRegID($this->reg_id); $cashOwed->setReceived(false); $cashOwedTotal = new MultiTableManager(); $cashOwedTotal->addRowManager($cashOwed); $cashOwedTotal->setFunctionCall('SUM', 'cashtransaction_amtPaid'); $cashOwedTotal->setGroupBy('reg_id'); $cashOwedList = $cashOwedTotal->getListIterator(); $cashOwedArray = $cashOwedList->getDataList(); reset($cashOwedArray); foreach (array_keys($cashOwedArray) as $k) { $cash_owed = current($cashOwedArray); $cash_owing = $cash_owed['SUM(cashtransaction_amtPaid)']; next($cashOwedArray); } if (!isset($cash_owing)) { $cash_owing = 0; } $this->template->set('cashOwed', $cash_owing); // get credit card total $ccTrans = new RowManager_CreditCardTransactionManager(); $ccTrans->setProcessed(true); $ccTrans->setRegID($this->reg_id); $ccTransTotal = new MultiTableManager(); $ccTransTotal->addRowManager($ccTrans); $ccTransTotal->setFunctionCall('SUM', 'cctransaction_amount'); $ccTransTotal->setGroupBy('reg_id'); $ccTransList = $ccTransTotal->getListIterator(); $ccTransArray = $ccTransList->getDataList(); reset($ccTransArray); foreach (array_keys($ccTransArray) as $k) { $cc_trans = current($ccTransArray); $cc_total = $cc_trans['SUM(cctransaction_amount)']; next($ccTransArray); } if (!isset($cc_total)) { $cc_total = 0; } $this->template->set('ccTotal', $cc_total); // TODO??: get credit card transactions NOT processed // set form for editing registration-specific form fields' values $this->template->set('eventFieldsFormSingle', $this->generateFieldValuesForm()); // store any additional link Columns // example: //$title = $this->labels->getLabel( '[title_groups]'); //$columnLabel = $this->labels->getLabel( '[groups]'); //$link = $this->linkValues[ 'groups' ]; //$fieldName = 'accessgroup_id'; //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // store the Row Manager's XML Node Name // $this->template->set( 'rowManagerXMLNodeName', RowManager_RegistrationManager::XML_NODE_NAME ); $this->template->set('rowManagerXMLNodeName', MultiTableManager::XML_NODE_NAME); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'registration_id'); // Load over-payment message, if necessary if ($this->ccTrans_subPage->hasOverPaid()) { $this->template->set('attemptedOverpayment', true); } // TODO: somehow merge the primary join with the balance owing join.... for efficiency /* * Set up any additional data transfer to the Template here... */ // $this->template->set( 'dataList', $this->dataList); $templateName = 'page_EditRegistrationDetails.tpl.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_EditCampusRegistrations.php'; return $this->template->fetch($templateName); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // 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]' ); if (!isset($this->linkLabels['cont'])) { $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); } // $this->linkLabels[ 'view' ] = 'new link label here'; // get pricing info // get base price for event participation $event = new RowManager_EventManager($this->event_id); $eventBasePrice = $event->getEventBasePrice(); $eventCashAllowed = $event->isEventCashAllowed(); // 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(); $this->basePriceForThisGuy = $priceGetter->getBasePriceForRegistrant($this->reg_id, $this->event_id, $this->campus_id, $eventBasePrice, $priceRulesArray, $rulesApplied); // echo "base price = ".$basePriceForThisGuy."<BR>"; $totalsList = $this->getFinancialTotals(); $totalsArray = explode(',', $totalsList); $scholarship_total = $totalsArray[0]; $cash_total = $totalsArray[1]; $cash_owing = $totalsArray[2]; $cc_total = $totalsArray[3]; $this->prepareTemplate($path); // retrieve deposit amount for event $deposit = $this->getEventDeposit(); /*** HACK: for AIA Winter Retreat '08 ***/ if ($this->event_id == 31) { $this->template->set('minPayNotice', "AIA Winter Retreat Registrants:<br> Please pay the \$" . $deposit . " or full price with credit card and remainder at registration and not to an AIA staff member.<br> Thank-you."); } else { $this->template->set('minPayNotice', "NOTE: you must have recorded a transaction covering the \$" . $deposit . " deposit in order to register for this event."); } $this->template->set('maxPayNotice', "'Total Paid' is only updated by credit transactions and confirmed cash transactions. "); // $this->template->set( 'maxPayNotice', 'The maximum amount that must be paid is'.$maxPayment); // 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', $this->basePriceForThisGuy); //$priceGetter->calcBalanceOwing($this->reg_id); // NOT NEEDED BECAUSE TOTALS CALCULATED AS SUM IN TEMPLATE // $this->template->set('person', $this->person_info ); // send in scholarships list, cash transactions table, and credit card transactions table $this->template->set('scholarshipsList', $this->generateScholarshipsList()); if ($eventCashAllowed == true) { $this->template->set('cashTransAdminBox', $this->generateCashTransactionsTable()); } // Load over-payment message, if necessary if ($this->ccTrans_form->hasOverPaid()) { $this->template->set('attemptedOverpayment', true); } $this->template->set('ccTransAdminBox', $this->generateCCTransactionsTable()); // $this->setFinancialTotals(); // moved up since it also sets a link label $this->template->set('scholarshipTotal', $scholarship_total); $this->template->set('cashTotal', $cash_total); $this->template->set('cashOwed', $cash_owing); $this->template->set('ccTotal', $cc_total); // 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'); // 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_ProcessFinancialTransactions.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); }