require '../modules/app_cim_reg/objects_da/CreditCardTransactionManager.php';
$toolName = '../Tools/tools_Finances.php';
$toolPath = '';
//Page::findPathExtension( $toolName );
require_once $toolPath . $toolName;
// get privileges for the current viewer
$privManager = new PrivilegeManager($this->viewer->getID());
if ($privManager->isCampusAdmin($this->EVENT_ID, $this->CAMPUS_ID) == true) {
    /********** NOTE: make sure 60 second PHP timeout is not activated: use filters, such as event_id  ************/
    $EVENT_ID = 18;
    // retrieve registration records
    $regs = new RowManager_RegistrationManager();
    $regs->setEventID($EVENT_ID);
    $regsList = $regs->getListIterator();
    $regsArray = $regsList->getDataList();
    $priceGetter = new FinancialTools();
    reset($regsArray);
    foreach (array_keys($regsArray) as $k) {
        $record = current($regsArray);
        $reg_id = $record['registration_id'];
        $owed = $priceGetter->simpleCalcBalanceOwing($reg_id);
        // store calculated balance owing in registration record
        $singleReg = new RowManager_RegistrationManager($reg_id);
        $balance = array();
        $balance['registration_balance'] = $owed;
        $singleReg->loadFromArray($balance);
        $singleReg->updateDBTable();
        next($regsArray);
    }
    echo "SUCCESS!";
} else {
Пример #2
0
 private function sendConfirmationEmail($appendHTML = false)
 {
     // retrieve basic confirmation e-mail info.
     $INFO_FIELDS_TOTAL = 9;
     $emailInfo = $this->getConfirmEmailInfo($this->reg_id);
     $financeGetter = new FinancialTools();
     // retrieve financial data for inclusion in e-mail
     $rulesApplied = array();
     $basePriceForThisGuy = 0;
     $priceRules = array();
     $scholarships = array();
     $cash_paid = 0;
     $cash_owed = 0;
     $cc_paid = 0;
     $cc_owed = 0;
     $balance_owing = $financeGetter->calcBalanceOwing($this->reg_id, $rulesApplied, $basePriceForThisGuy, $priceRules, $scholarships, $cash_paid, $cash_owed, $cc_paid, $cc_owed);
     $eventBasePrice = $this->getEventBasePrice($this->event_id);
     if (isset($emailInfo) && count($emailInfo) == $INFO_FIELDS_TOTAL) {
         // 	    $confirmationLabels = new MultiLingual_Labels( SITE_LABEL_PAGE_GENERAL, SITE_LABEL_SERIES_SITE, TEMPLATE_SIGNUP_CONFIRMATION, $langID );
         $to = $emailInfo['email'];
         $subject = $this->labels->getLabel('[Subject]');
         // HACK for french and eastern WC
         $headers = '';
         $htmlBreak = '';
         $message = '';
         // To send HTML mail, the Content-type header must be set
         if ($appendHTML == true) {
             $headers .= 'MIME-Version: 1.0' . "\r\n";
             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
             $htmlBreak = '<br/>';
             $message .= '<html><body>';
         }
         // Create the message
         $message .= $this->labels->getLabel('[ThankYou]') . " " . $emailInfo['event_name'] . "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[ConfirmationNumber]') . ': ' . $emailInfo['confirmNum'] . "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[fName]') . ': ' . $emailInfo['person_fname'] . "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[lName]') . ': ' . $emailInfo['person_lname'] . "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[campus]') . ': ' . $emailInfo['campus_name'] . "\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         $message .= "---- " . $this->labels->getLabel('[FinanceInfo]') . " ----\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         // event base price
         $message .= $this->labels->getLabel('[eventBasePrice]') . "  ";
         $message .= '$' . $emailInfo['event_basePrice'] . "\n" . $htmlBreak;
         // first print out the rules the computer has applied
         foreach ($rulesApplied as $key => $ruleApplied) {
             $message .= $ruleApplied['pricerules_desc'] . ':  ' . $ruleApplied['pricerules_discount'] . "\n" . $htmlBreak;
         }
         $message .= "\n" . $htmlBreak;
         // Total of above base price + discounts
         $message .= $this->labels->getLabel('[BasePriceForYou]') . "  ";
         $message .= '$' . $basePriceForThisGuy . "\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         //  print out the scholarships for the registrant
         if (isset($scholarships) && count($scholarships) > 0) {
             $message .= $this->labels->getLabel('[ScholarshipsInfo]') . ": \n" . $htmlBreak;
         }
         foreach ($scholarships as $key => $scholarship) {
             $message .= '$' . $scholarship['scholarship_amount'] . ' from: ' . $scholarship['scholarship_sourceDesc'] . "\n" . $htmlBreak;
         }
         $message .= "\n" . $htmlBreak;
         // cash and credit card transaction information
         $message .= $this->labels->getLabel('[cashReceived]') . "  ";
         $message .= '$' . $cash_paid . "  \t\t";
         // "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[cashNotReceived]') . "  ";
         $message .= '$' . $cash_owed . "\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[ccProcessed]') . "  ";
         $message .= '$' . $cc_paid . "  \t\t";
         // "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[ccNotProcessed]') . "  ";
         $message .= '$' . $cc_owed . "\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         $message .= $this->labels->getLabel('[BalanceOwing]') . "  ";
         if (substr($balance_owing, 0, 1) == '-') {
             $message .= "-\$" . substr($balance_owing, 1) . "\n" . $htmlBreak;
         } else {
             $message .= "\$" . $balance_owing . "\n" . $htmlBreak;
         }
         $message .= "\n" . $htmlBreak;
         $message .= "---- " . $this->labels->getLabel('[ImpInfo]') . " ----\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         // event admin specific:  event confirmation text
         $message .= $emailInfo['confirm_text'];
         $message .= "\n" . $htmlBreak;
         $message .= "-------------------------------\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         $message .= "\n" . $htmlBreak;
         // check if proper event e-mail address was found, if NOT then use default address
         $event_email = $emailInfo['event_email'];
         if (!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$", $event_email)) {
             // echo "The e-mail was not valid";
             $isValid = false;
             $event_email = page_EditCampusRegistrations::DEFAULT_EMAIL;
         }
         $message .= $this->labels->getLabel('[footer]') . $event_email . "\n" . $htmlBreak;
         // add the end tags
         if ($appendHTML) {
             $message .= "</body></html>";
         }
         $message = wordwrap($message, 70);
         $headers .= 'From: ' . $event_email . "\n" . 'Reply-To: ' . $event_email . "\n" . 'X-Mailer: PHP/' . phpversion();
         // 'Bcc: '.$emailInfo['adminEmail'] . "\n" .
         // 				echo "<BR>HEADERS: ".$headers;
         // 				echo "TO: ".$to;
         // 				echo "<br>SUBJECT: ".$subject;
         // 				echo "<BR>MESSAGE: ".$message;
         ini_set('SMTP', EMAIL_SMTP_SERVER);
         ini_set('smtp_port', EMAIL_SMTP_PORT);
         $success = mail($to, $subject, $message, $headers);
         if (!$success) {
             return 'Error Sending Confirmation E-mail!';
             // TODO: replace with a label
         } else {
             return 'Confirmation E-mail Successfully Sent';
             // TODO: replace with a label
         }
     } else {
         return 'Error Retrieving Confirmation Information: E-mail *Not* Sent!';
         // TODO: replace with a label
     }
 }
 /**
  * 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);
 }
Пример #4
0
 function loadAdminEventHome()
 {
     // get privileges for the current viewer
     $privManager = new PrivilegeManager($this->viewer->getID());
     if ($privManager->isBasicAdmin($this->EVENT_ID) == true) {
         $links = array();
         $parameters = array();
         //[RAD_CALLBACK_PARAMS]
         $link = $this->getCallBack(modulecim_reg::PAGE_ADMINHOME, '', $parameters);
         $links["BackLink"] = $link;
         if ($privManager->isEventAdmin($this->EVENT_ID) == true) {
             /** Check if recalculation link was clicked **/
             if ($this->IS_RECALC == FinancialTools::RECALC_COMPLETE) {
                 // run recalculation of balance owing
                 $balanceSetter = new FinancialTools();
                 $balanceSetter->recalculateBalances($this->EVENT_ID);
                 $this->IS_RECALC = FinancialTools::RECALC_NOTNEEDED;
                 $eventPriceRules = new RowManager_PriceRuleManager();
                 $eventPriceRules->setEventID($this->EVENT_ID);
                 $eventPriceRules->setPriceRuleType(RowManager_PriceRuleTypeManager::VOLUME_RULE);
                 $ruleList = $eventPriceRules->getListIterator();
                 $ruleArray = $ruleList->getDataList();
                 $ruleIDs = array();
                 reset($ruleArray);
                 // cycle through volume rules
                 foreach (array_keys($ruleArray) as $k) {
                     $record = current($ruleArray);
                     $activeRule = new RowManager_ActiveRuleManager($record['pricerules_id']);
                     $setRecord = array();
                     $setRecord['is_recalculated'] = RowManager_ActiveRuleManager::IS_TRUE;
                     $activeRule->loadFromArray($setRecord);
                     $activeRule->updateDBTable();
                     next($ruleArray);
                 }
             }
             /**  Check if a volume rule exists; if so, check if volume rule triggered ***/
             if ($this->triggerBalanceRecalculation($this->EVENT_ID) == true) {
                 $this->IS_RECALC = FinancialTools::RECALC_NEEDED;
             }
         }
         // end eventAdmin privilege check 1
         // Need to set campus-link so that summary table data can be created for download PDF link
         $parameters = array('EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID);
         //[RAD_CALLBACK_PARAMS]
         $campus_link = $this->getCallBack(modulecim_reg::PAGE_EDITCAMPUSREGISTRATIONS, '', $parameters);
         $campus_link .= "&" . modulecim_reg::CAMPUS_ID . "=";
         $this->pageDisplay = new page_AdminEventHome($this->moduleRootPath, $this->viewer, $this->EVENT_ID, $this->IS_RECALC, $campus_link);
         // 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)
         $parameters = array('EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID);
         //[RAD_CALLBACK_PARAMS]
         $pageCallBack = $this->getCallBack(modulecim_reg::PAGE_ADMINEVENTHOME, $this->sortBy, $parameters);
         $this->setPageCallBack($pageCallBack);
         if ($privManager->isSuperAdmin() == true) {
             $parameters = array('EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID);
             //[RAD_CALLBACK_PARAMS]
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITFIELDTYPES, '', $parameters);
             $links["EditFieldTypes"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITPRICERULETYPES, '', $parameters);
             $links["EditPriceRuleTypes"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITCREDITCARDTYPES, '', $parameters);
             $links["EditCreditCardTypes"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITPRIVILEGETYPES, '', $parameters);
             $links["EditPrivilegeTypes"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_ADDSUPERADMIN, '', $parameters);
             $links["AddSuperAdmins"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITSTATUSES, '', $parameters);
             $links["EditStatusTypes"] = $link;
         }
         //         	  if ($privManager->isCampusAdmin($this->EVENT_ID,null)==true)	// check if privilege level is high enough
         // 	        {
         $links["CampusLink"] = $campus_link;
         // 	        }
         if ($privManager->isEventAdmin($this->EVENT_ID) == true) {
             /**** NOTE: PDF generation TEMPORARILY disabled until PDF plugin added to production PHP environment ****/
             /** GENERATE PDF OF SUMMARY DATA **/
             $fileName = 'summary' . rand(1, MAX_TEMP_SEED) . '.pdf';
             $filePath = getcwd() . "/Reports/" . $fileName;
             // change to '\\' for local use ?
             $linkPath = SITE_PATH_REPORTS . $fileName;
             $page_margin = 20;
             $column_widths = array();
             $column_widths[0] = 0;
             $column_widths[1] = 195;
             //campus
             $column_widths[2] = 70;
             // link
             $column_widths[3] = 35;
             // males total
             $column_widths[4] = 50;
             // females total
             $column_widths[5] = 30;
             // both genders total
             $column_widths[6] = 70;
             // cancellations
             $column_widths[7] = 55;
             // completed regs
             $column_widths[8] = 55;
             // incomplete regs
             $table_pdf = new PDF_Template_Table($filePath, $page_margin, $column_widths, "Registrations");
             $table_pdf->generateTable();
             //(true,true);
             // 				  $metaRegSummaryHeadings = $this->pageDisplay->getMetaSummaryHeadings();
             $metaRegSummaryData = $this->pageDisplay->getMetaSummaryData();
             $campusRegSummaryHeadings = $this->pageDisplay->getSummaryHeadings();
             $campusRegSummaryData = $this->pageDisplay->getSummaryData();
             // 				  echo 'summary data = <pre>'.print_r($campusRegSummaryData,true).'</pre>';
             $table_pdf->fillTable($campusRegSummaryHeadings, $metaRegSummaryData, $campusRegSummaryData, true, true);
             /*** Add a pie chart of campus registrations  **/
             $chart_pdf = new PDF_Template_Charts($table_pdf->getPDF());
             $event = new RowManager_EventManager($this->EVENT_ID);
             $title = 'Total Campus Registrations for ' . $event->getEventName();
             $chart_width = 5;
             //PDF::PAGEWIDTH_LETTER*0.5;
             $chart_height = 5;
             //PDF::PAGEHEIGHT_LETTER*0.5;
             // 					echo 'chart height/width = '.$chart_height.', '.$chart_height;
             $found_nonzero = false;
             $campus_totals = array();
             reset($campusRegSummaryData);
             foreach (array_keys($campusRegSummaryData) as $key) {
                 $record = current($campusRegSummaryData);
                 $campus_totals[$key] = $record['campusTotal'];
                 if ($record['campusTotal'] > 0) {
                     $found_nonzero = true;
                 }
                 next($campusRegSummaryData);
             }
             // 				  echo 'campus totals data = <pre>'.print_r($campus_totals,true).'</pre>';
             // required to avoid divide-by-zero error when generating pie chart with no data
             if ($found_nonzero == true) {
                 $chart_pdf->createPieChart($title, $chart_width, $chart_height, $campus_totals);
             }
             $table_pdf->Output();
             $link = $linkPath;
             $links["DownloadSummary"] = $link;
             /** <END> PDF GENERATION **/
             $emailPageParameters = array('EVENT_ID' => $this->EVENT_ID);
             //[RAD_CALLBACK_PARAMS]
             $email_link = $this->getCallBack(modulecim_reg::PAGE_EMAILCOMPOSER, '', $emailPageParameters);
             $links["EmailRegistrants"] = $email_link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EVENTDETAILS, '', $parameters);
             $links["EditEventDetails"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_ADDEVENTADMIN, '', $parameters);
             $links["AddEventAdmins"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_ADDCAMPUSADMIN, '', $parameters);
             $links["AddCampusAdmins"] = $link;
             $this->IS_RECALC = FinancialTools::RECALC_COMPLETE;
             $recalcParams = array('IS_RECALC' => $this->IS_RECALC, 'EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID);
             $link = $this->getCallBack(modulecim_reg::PAGE_ADMINEVENTHOME, '', $recalcParams);
             $links["RecalculateBalances"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITFORMFIELDS, '', $parameters);
             $links["EditEventFormFields"] = $link;
             $link = $this->getCallBack(modulecim_reg::PAGE_EDITPRICERULES, '', $parameters);
             $links["EditEventPriceRules"] = $link;
             /* Output the file to be downloaded */
             /*        if (isset($this->DOWNLOAD_TYPE))	//($_REQUEST["file"]))	//		//if (isset($_REQUEST["file"])) {
             		        {	
             			        $fileDir = SITE_PATH_REPORTS;
             			        
             			        echo "Data type = ".$this->DOWNLOAD_TYPE;    
             			        switch($this->DOWNLOAD_TYPE)
             			        {
             				        case modulecim_reg::DOWNLOAD_EVENT_DATA:    
             				        		$fileName = $this->getSummaryData($this->EVENT_ID, 1);	//$_REQUEST["file"];	
             				        		echo "FILE NAME = ".$fileName;					
             					    		$file=$fileDir.$fileName;
             					    		
             		//			    		echo "headers: <pre>".print_r(headers_list(),true)."</pre><br>";
             					    		
             					    		// TODO: move below code out of SWITCH
             					    		 header("Content-Location: ".$file);
             							    header("Content-type: text/comma-separated-values");
             							    header("Content-Transfer-Encoding: Binary");
             							    header("Content-length: ".filesize($file));
             							    header("Content-disposition: attachment; filename=\"".basename($file)."\"");
             							    readfile("$file");
             							    
             		
             					    		break;
             					     case modulecim_reg::DOWNLOAD_SCHOLARSHIP_DATA:
             		/*		        		$fileName = $this->getSummaryData($this->EVENT_ID, 1);	//$_REQUEST["file"];	
             				        		echo "FILE NAME = ".$fileName;					
             					    		$file=$fileDir.$fileName;
             					    		
             					    		// TODO: move below code out of SWITCH
             							    header("Content-type: text/comma-separated-values");
             							    header("Content-Transfer-Encoding: Binary");
             							    header("Content-length: ".filesize($file));
             							    header("Content-disposition: attachment; filename=\"".basename($file)."\"");
             							    readfile("$file"); */
             /*			     		echo "NOT YET IMPLEMENTED";
             					     		break;
             					     default:
             					     		break;
             				     }
             				     unset($this->DOWNLOAD_TYPE);
             		
             					} else {
             					    echo "No file selected";
             					} 
             					/** above code gratefully modified from code found at: 
             						http://www.higherpass.com/php/tutorials/File-Download-Security/1/ **/
             //$this->DOWNLOAD_TYPE = modulecim_reg::DOWNLOAD_EVENT_DATA;
             //$fileDownloadParameters = array('EVENT_ID'=>$this->EVENT_ID , 'CAMPUS_ID'=>$this->CAMPUS_ID, 'DOWNLOAD_TYPE'=>$this->DOWNLOAD_TYPE);//[RAD_CALLBACK_PARAMS]
             //        $link2 = SITE_PATH_MODULES.'app_'.modulecim_reg::MODULE_KEY.'/objects_pages/'.modulecim_reg::CSV_DOWNLOAD_TOOL.'?'.modulecim_reg::EVENT_ID.'='.$this->EVENT_ID.'&'.modulecim_reg::DOWNLOAD_TYPE.'='.modulecim_reg::DOWNLOAD_EVENT_DATA;	//$this->getCallBack( modulecim_reg::PAGE_ADMINEVENTHOME, '', $fileDownloadParameters );
             //        $links["EventDataDump"] = $link2;             //Event Data Dump - for importing into Excel
             $this->DOWNLOAD_TYPE = modulecim_reg::DOWNLOAD_EVENT_DATA;
             $fileDownloadParameters = array('EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID, 'DOWNLOAD_TYPE' => $this->DOWNLOAD_TYPE);
             //[RAD_CALLBACK_PARAMS]
             $link2 = $this->getCallBack(modulecim_reg::PAGE_DOWNLOADREPORT, '', $fileDownloadParameters);
             $links["EventDataDump"] = $link2;
             //Event Data Dump - for importing into Excel
             $this->DOWNLOAD_TYPE = modulecim_reg::DOWNLOAD_SCHOLARSHIP_DATA;
             $fileDownloadParameters = array('EVENT_ID' => $this->EVENT_ID, 'CAMPUS_ID' => $this->CAMPUS_ID, 'DOWNLOAD_TYPE' => $this->DOWNLOAD_TYPE);
             //[RAD_CALLBACK_PARAMS]
             $link3 = $this->getCallBack(modulecim_reg::PAGE_DOWNLOADREPORT, '', $fileDownloadParameters);
             $links["EventScholarshipList"] = $link3;
             //Event Scholarship List - for importing into Excel
         }
         // end event-admin privilege check 2
         /*[RAD_LINK_INSERT]*/
         $this->pageDisplay->setLinks($links);
         //$this->previous_page = modulecim_reg::PAGE_ADMINEVENTHOME;
     } else {
         $this->pageDisplay = new page_NotAuthorized($this->moduleRootPath, $this->viewer);
     }
 }
 /**
  * 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();
         }
     }
 }
 /**
  * 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);
 }