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; } }
protected function setRegistrationID() { // get registration ID for the rest of the reg. process $regs = new RowManager_RegistrationManager(); $people = new RowManager_PersonManager(); $people->setPersonID($this->person_id); $events = new RowManager_EventManager(); $events->setEventID($this->event_id); $personRegs = new MultiTableManager(); $personRegs->addRowManager($regs); $personRegs->addRowManager($people, new JoinPair($regs->getJoinOnPersonID(), $people->getJoinOnPersonID())); $personRegs->addRowManager($events, new JoinPair($regs->getJoinOnEventID(), $events->getJoinOnEventID())); $regsList = $personRegs->getListIterator(); $regsArray = $regsList->getDataList(); // echo "<pre>".print_r($regsArray,true)."</pre>"; reset($regsArray); foreach (array_keys($regsArray) as $k) { $registration = current($regsArray); $this->registration_id = $registration['registration_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) next($regsArray); } // create new registration record for this person (since none exists for current person-event combo) if (!isset($this->registration_id)) { // get status id for INITIAL_REG_STATUS $regStatus = new RowManager_StatusManager(); $regStatus->setStatusDesc(FormProcessor_EditMyInfo::INITIAL_REG_STATUS); $regStatusList = $regStatus->getListIterator(); $regStatusArray = $regStatusList->getDataList(); $statusID = 0; reset($regStatusArray); foreach (array_keys($regStatusArray) as $k) { $status = current($regStatusArray); $statusID = $status['status_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) next($regStatusArray); } // get the MAX(registration_id)... need to determine what insertion registration ID will be (used in confirmNum) $allRegs = new MultiTableManager(); $regs2 = new RowManager_RegistrationManager(); $allRegs->addRowManager($regs2); $allRegs->setFunctionCall('MAX', 'registration_id'); $allRegs->ignoreFields(); // only leave MAX(registration_id) in values to be returned $allRegsList = $allRegs->getListIterator(); $allRegsArray = $allRegsList->getDataList(); $maxID = -1; reset($allRegsArray); foreach (array_keys($allRegsArray) as $k) { $regRecord = current($allRegsArray); $maxID = $regRecord['MAX(registration_id)']; if ($maxID > -1) { break; // get out of the loop once MAX is found } next($allRegsArray); } // compile values needed for new registration record $regValues = array(); $nextRegID = $maxID + 1; $regValues['event_id'] = $this->event_id; // check if a new person record needs to be created if ($this->person_id == -1) { $this->person_id = $this->getNextPersonID(); // assumes processData() will properly use this value for insertion // create empty person record to start off... since otherwise FK constraint on cim_reg_registration is NOT satisfied $personManager = new RowManager_PersonManager($this->person_id); $personManager->loadFromArray($this->formValues); $personManager->setPersonID($this->person_id); $personManager->createNewEntry(true); //$this->assignCampus($this->person_id); -- save this step for when info properly entered into form } $regValues['person_id'] = $this->person_id; $timestamp = strtotime("now"); $date = date('Y-m-d H:i:s', $timestamp); // == NOW() : to bad I could pass that as non-string... $regValues['registration_date'] = $date; // set date-time to current date-time $regValues['registration_confirmNum'] = 'E' . $this->event_id . 'R' . $nextRegID . 'C' . $this->campus_id; $regValues['registration_status'] = $statusID; // store values in table manager object. $regs->loadFromArray($regValues); // set primary key to use for update (if maxID found) if ($maxID > -1) { $regValues['registration_id'] = $nextRegID; $regs->setRegID($regValues['registration_id']); } // now update the DB with the values if (!$regs->isLoaded()) { $regs->createNewEntry(true); // allow primary key to be set (in case auto_increment is off) $this->registration_id = $nextRegID; } // TODO: figure out how to show error if no registration made, or updated (IF it is even possible now...) } }
/** * 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); }
protected function createRegistrationRecord($eventID, $personID, &$regs) { if ($personID != -1 && $eventID != -1) { // $regs = new RowManager_RegistrationManager(); // get status id for INITIAL_REG_STATUS $regStatus = new RowManager_StatusManager(); $regStatus->setStatusDesc(FormProcessor_Register::INITIAL_REG_STATUS); $regStatusList = $regStatus->getListIterator(); $regStatusArray = $regStatusList->getDataList(); $statusID = 0; reset($regStatusArray); foreach (array_keys($regStatusArray) as $k) { $status = current($regStatusArray); $statusID = $status['status_id']; // NOTE: should only be one reg. per person per event (ENFORCE??) next($regStatusArray); } // get the MAX(registration_id)... need to determine what insertion registration ID will be (used in confirmNum) $allRegs = new MultiTableManager(); $allRegs->addRowManager($regs); $allRegs->setFunctionCall('MAX', 'registration_id'); $allRegs->ignoreFields(); // only leave MAX(registration_id) in values to be returned $allRegsList = $allRegs->getListIterator(); $allRegsArray = $allRegsList->getDataList(); $maxID = -1; reset($allRegsArray); foreach (array_keys($allRegsArray) as $k) { $regRecord = current($allRegsArray); $maxID = $regRecord['MAX(registration_id)']; if ($maxID > -1) { break; // get out of the loop once MAX is found } next($allRegsArray); } // compile values needed for new registration record $regValues = array(); $nextRegID = $maxID + 1; $regValues['event_id'] = $eventID; // check if a new person record needs to be created // if ($this->person_id == -1) // { // $this->person_id = $this->getNextPersonID(); // assumes processData() will properly use this value for insertion // } $regValues['person_id'] = $personID; $timestamp = strtotime("now"); $date = date('Y-m-d H:i:s', $timestamp); // == NOW() : to bad I could pass that as non-string... $regValues['registration_date'] = $date; // set date-time to current date-time $regValues['registration_confirmNum'] = 'E' . $eventID . 'R' . $nextRegID . 'AIA'; $regValues['registration_status'] = $statusID; $this->confirmNum = $regValues['registration_confirmNum']; // TODO: change means of assigning to global // store values in table manager object. $regs->loadFromArray($regValues); // set primary key to use for update (if maxID found) if ($maxID > -1) { $regValues['registration_id'] = $nextRegID; $regs->setRegID($regValues['registration_id']); } // now update the DB with the values if (!$regs->isLoaded()) { $regs->createNewEntry(true); // allow primary key to be set (in case auto_increment is off) return $nextRegID; } else { return -1; } // TODO: figure out how to show error if no registration made, or updated (IF it is even possible now...) } }
/** * function processData * <pre> * Processes the data for this form. * </pre> * @return [void] */ function processData() { if ($this->shouldCancel == true) { $status = new RowManager_StatusManager(); $status->setStatusDesc(RowManager_StatusManager::CANCELLED); $statusList = $status->getListIterator(); $statusArray = $statusList->getDataList(); reset($statusArray); // Assumption: status descriptions are unique $record = current($statusArray); $status_id = $record['status_id']; $reg_record['registration_status'] = $record['status_id']; // echo "<pre>".print_r($reg_record,true)."</pre>"; // $list = $this->itemManager->getListIterator(); // echo "manager = <pre>".print_r($list->getDataList(),true)."</pre>"; // change status of registration record $this->itemManager->setStatus($status_id); $this->itemManager->loadFromArray($reg_record); $this->itemManager->updateDBTable(); } }