actions['showMember'] = 'doShowMember'; $this->DB_Grid($Doc, $DBObj); $this->alias = $alias; $this->action = $action; if (strpos($alias,'ViewTeamReport') !== false) { $aAlias = split('/',$alias); $this->action = trim($aAlias[0]); $this->alias = trim($aAlias[1]); } } function doVCSFile($request) { $this->DBObj->id=$request[0]; $this->DBObj->initFromDB(); $this->DBObj->getVCSFile(); } function doViewTeamReport($request) { $this->DBObj->id = $request[0]; $this->Doc->addContent( array( 'tpl' => 'List/team-list.tpl', 'teams' => $this->DBObj->getTeamPersons4Report(), 'back_link' => 1, 'reportname' => $this->getGroupNameByID() . 's List', 'eventname' => $this->getEventNameByID(), 'eventdate' => $this->getEventDateByID() ) ); } function getEventNameByID() { $Events = SiteMap::getObj('Event/Event.php', $this->DBObj->id); $Events->initFromDB(); return $Events->getData('name'); } function getEventDateByID() { $Events = SiteMap::getObj('Event/Event.php', $this->DBObj->id); $Events->initFromDB(); return $Events->getData('eventdate'); } function getGroupNameByID() { $Events = SiteMap::getObj('Event/Event.php', $this->DBObj->id); $Events->initFromDB(); return $Events->getData('group_name') ? $Events->getData('group_name') : 'Foursome'; } function exec() { if (!empty($_REQUEST['action']) && 'showMember' == $_REQUEST['action']) { $this->action = $_REQUEST['action']; $function = $this->actions[$this->action] . 'Ajax'; } if (!key_exists($this->action, $this->actions)) { if (method_exists($this, 'do' . $this->action)) { $function = 'do' . $this->action; } else { $actionNames = array_keys($this->actions); $this->action = $actionNames[0]; $function = $this->actions[$this->action]; } } if (method_exists($this, $function)) { $this->$function(split('/', $this->alias)); } else { exit(); } } function getAssignForm() { $teams = $this->DBObj->getExistingTeams4Select(); if (empty($teams)) { return null; } $form = $this->_getBaseForm(); $form->setAttribute('id', 'event_assign_form'); $form->addElement('hidden', 'action', 'assign'); $form->addElement( 'select', 'id_team', 'Team Name', array('' => 'Select One') + (array)$this->DBObj->getExistingTeams4Select() ); $form->addRuleRequired(array('id_team'), 'server'); $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); $form->tpl = BASE_PATH . '/tpl/Event/assign-form.tpl'; $form->return_form_arr = true; return $form; // this is not the first return } function doShow($request) { if (CURR_PAGE == 'event/monthly-program') { $this->DBObj->id=$this->DBObj->db->queryOne('SELECT id FROM mn_Event WHERE montly_program=1 AND registration_startNOW() AND eventdate>NOW() ORDER BY eventdate LIMIT 1'); if (!$this->DBObj->id) $this->Doc->addContent(array('tpl' => 'text.tpl','text' => '
Currently there are no opened Monthly Program Events
')); } else $this->DBObj->id = $request[0]; if ($this->DBObj->id) { $this->DBObj->initFromDB(); if (null === ($data = $this->DBObj->getData())) { $this->Doc->display404(); return; } $this->Doc->setTitle($data['name'] . ' | MNCAR ' . (($data['exchange']) ? 'Training' : 'Event')); $this->Doc->setDescription('MNCAR ' . (($data['exchange']) ? 'Training' : 'Event') . ': ' . $data['name']); require_once ('class/Session.php'); $member = Session::getData('individual_user', 'individual_user'); if (is_null($member)) $member = Session::getData('individual_user_support', 'individual_user_support'); $this->DBObj->setMember($this->Doc->MemberAuth->getData()); $item = array( 'tpl' => 'Event/show.tpl', 'event' => $data, 'member_id' => (int)$member['id'], 'show_button' => ($this->DBObj->getData('registration_start') <= date("Y-m-d H:i:s"))?1:0, 'registration' => $this->DBObj->getMemberRegistration(), 'registered' => $this->DBObj->isRegistered(), 'teamsCount' => count($this->DBObj->getTeamPersons4Report()), ); if (!empty($request[1]) && 'attendees' == $request[1]) { $item['attendees_list'] = $this->DBObj->getAttendeesList(); $this->Doc->addItemProp('JSs', 'js/jquery.cluetip.js'); $this->Doc->addItemProp('CSSs', 'css/jquery.cluetip.css'); $this->Doc->addItemProp('JSs', 'js/jquery.dimensions-1.2.js'); $this->Doc->addItemProp('initFuncs', 'addtooltips'); } if (!$item['registration']['id_team']) { $assignForm = $this->getAssignForm(); if ($assignForm && 'POST' == $_SERVER['REQUEST_METHOD'] && 'assign' == Qs_Request::getPostValue('action')) { if ($assignForm->validate()) { $id_team = $assignForm->exportValue('id_team'); if (false === $this->DBObj->assignToTeam($id_team)) { $assignForm->_errors[] = 'Internal Error. Cannot assign to team'; } else { $teamName = $this->DBObj->getTeamName($id_team); if (empty($teamName)) { $teamName = 'No Name'; } $this->setBackMessage('You are successfully assigned to ' . $teamName . ' team'); $this->redirect($this->url() . '/' . $this->DBObj->id); } } } if ($assignForm) { $item['assignForm'] = $assignForm->exec(); $item['assignForm']['errors'] = $assignForm->_errors; } else { $item['assignForm'] = null; } } $this->Doc->addContent($item); } } function doCalendar($request) { $nMonth = date('n'); $nYear = date('Y'); if (isset($request[1])) $nMonth = (int) $request[1]; if (isset($request[0]) && (int) $request[0]) $nYear = (int) $request[0]; list ($cMonth, $nStartDay, $nAllDay) = explode(':', date('F:w:t', mktime(0, 0, 0, $nMonth, 1, $nYear))); for($i = 0; $i < 7; $i++) $aDays[$i] = date('D', mktime(0, 0, 0, $nMonth, 8 - $nStartDay + $i, $nYear)); if (strpos(CURR_PAGE, 'exchange') !== false) $nFilter = SHOW_EXCHANGE_EVENTS; elseif (strpos(CURR_PAGE, 'education') !== false) $nFilter = SHOW_EDUCATION_EVENTS; elseif (strpos(CURR_PAGE, 'monthly-programs') !== false) $nFilter = SHOW_MONTHLY_PROGRAMS; else $nFilter = SHOW_ALL_EVENTS; $aEvents = $this->DBObj->getList4Show($nMonth, $nYear, $nFilter); foreach ($aEvents as $aEvent) $aEventsbyDay[$aEvent['day']][] = $aEvent; $aItem = array('tpl' => 'Event/calendar.tpl', 'nMonth' => $nMonth, 'cMonth' => $cMonth, 'nYear' => $nYear, 'nPrevMonth' => $nMonth == 1 ? 12 : $nMonth - 1, 'nPrevYear' => $nYear - ($nMonth == 1 ? 1 : 0), 'nNextMonth' => $nMonth == 12 ? 1 : $nMonth + 1, 'nNextYear' => $nYear + ($nMonth == 12 ? 1 : 0), 'nStartDay' => $nStartDay, 'nEndDay' => (42 - $nStartDay - $nAllDay) % 7, 'nAllDays' => $nAllDay, 'aDays' => $aDays, 'events' => $aEventsbyDay); $this->Doc->addContent($aItem); } public function doShowMemberAjax() { require_once 'app/Event/Form/Req/Grid/Grid.php'; $member = Session::getData('individual_user', 'individual_user'); if (empty($member['id'])) { die(); } $adminEventGrid = new EventForm_Req_Grid($this->Doc, $this->DBObj); $adminEventGrid->doShowMemberAjax(true, $member['id']); die(); } function doRegistrationForm($request) { if (Constant::get('HAS_HTTPS') && CURRENT_PROTOCOL=='http') { require_once 'class/HTTP.php'; skHTTP::redirect('https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); } require_once ('class/Session.php'); $member = Session::getData('individual_user', 'individual_user'); if (is_null($member)) $member = Session::getData('individual_user_support', 'individual_user_support'); $this->DBObj->id = $request[0]; $this->DBObj->initFromDB(); if (null === ($data = $this->DBObj->getData())) { $this->Doc->display404(); return; } if ('n' == $this->DBObj->getData('is_allowed_registration')) { $this->Doc->displayMessage('This Event is currently closed for registration.'); return $this; } if ($this->DBObj->db->queryOne( 'SELECT count(id) FROM mn_EventFormReq WHERE id_event=' . (int) $this->DBObj->id . ' AND deleted="n" AND id_member=' . (int) $member['id']) && $_REQUEST['action'] != 'thank') { require_once 'class/HTTP.php'; skHTTP::redirect(Constant::get('BASE_URL') . '/event/show/' . $this->DBObj->id); } /* event with type 2 - Open Event, event with type 3 - Brokerage Basics */ if (in_array($this->DBObj->_data['id_type'], array(2, 3)) || Member::hasEventRegistration($member)) { $this->Doc->content['DOC']['keyword'] = $this->DBObj->getData('metakeywords'); $this->Doc->content['DOC']['description'] = $this->DBObj->getData('metadescription'); if ($this->DBObj->getData('title')) $this->Doc->content['DOC']['title'] = $this->DBObj->getData('title'); $id_fm = $this->DBObj->_data['id_form'] ? $this->DBObj->_data['id_form'] : 1; /** @var $EventForm Event_Form */ $EventForm = SiteMap::getObj('Event/Form/Form.php', $id_fm); $form = $EventForm->getForm($this->Doc, $this->DBObj->id); if ('HTML_QuickForm_Error' !== get_class($form->getElement('fild[19]')) ) { //if security code is present at form $this->Doc->addItemProp('JSs', 'js/jquery.cluetip.js'); $this->Doc->addItemProp('CSSs', 'css/jquery.cluetip.css'); $this->Doc->addInitInlineScript('cTipInit', "$('a.ctip').cluetip({width:'400px', cluetipClass: 'default'});"); } if (Constant::get('HAS_HTTPS')) { $form->_attributes['action'] = str_replace('http','https',$form->_attributes['action']); } $form->submitTitle='Complete Registration'; $justcomplete = null; if (count($form->_elements) < 3 && $_REQUEST['action'] != 'thank') { $justcomplete=true; $form->_required=array(); } if ($this->DBObj->getData('id_type') == 4 && false !== strpos(CURR_PAGE, 'admin')) { $this->Doc->addItemProp('initFuncs', 'showteaminfo'); } $aItem = array('tpl' => 'Event/show_brief.tpl', 'event' => $this->DBObj->getData()); $this->Doc->addContent($aItem); switch ($_REQUEST['action']) { case 'thank' : $aRegistered=Session::getData('event','registered'); Session::clearData('event','registered'); $teamData = $this->DBObj->db->queryRow(" SELECT `id_team`, `EventTeam`.`teamname` FROM {$this->DBObj->db->tblEventFormReq} `EventFormReq` LEFT JOIN {$this->DBObj->db->tblEventTeam} AS `EventTeam` ON `EventTeam`.`id` = `EventFormReq`.`id_team` AND `EventFormReq`.`id_event` = `EventTeam`.`id_event` WHERE `id_member`= {$this->DBObj->db->quote($member['id'], 'integer')} AND `deleted`='n' AND `EventFormReq`.`id_event` = {$this->DBObj->db->quote($this->DBObj->id, 'integer')} "); $teamId = $teamData['id_team']; if (empty($teamId)) { $aMemberList = array(); } else { $aMemberList = $this->DBObj->db->queryAll(" SELECT CONCAT(`Member`.`first_name`, ' ', `Member`.`last_name`) `name`, `EventFormReq`.`amount` FROM `{$this->DBObj->db->tblEventFormReq}` `EventFormReq` INNER JOIN `{$this->DBObj->db->tblMember}` `Member` ON `EventFormReq`.`id_member` = `Member`.`id` WHERE `EventFormReq`.`id_team` = {$this->DBObj->db->quote($teamId, 'integer')} AND `EventFormReq`.`deleted` = 'n' AND `EventFormReq`.`id_event` = {$this->DBObj->db->quote($this->DBObj->id, 'integer')} "); } $nTeamMembers = count($aMemberList); $this->Doc->addContent(array( 'tpl' => 'Event/thank.tpl', 'name' => $this->DBObj->getData('name'), 'id' => $this->DBObj->id, 'team_id' => $teamId, 'teamName' => $teamData['teamname'], 'member_list' => $aMemberList, 'spotsremain' => $this->DBObj->getData('group_limit')-(int)$nTeamMembers, 'amount' => $this->DBObj->getData('member_cost') * count($aRegistered), 'teamsCount' => count($this->DBObj->getTeamPersons4Report()), )); break; case 'submit' : if ($form->validate() || count($form->_elements) < 3) { /** @var $EventForm_Req EventForm_Req */ $EventForm_Req = SiteMap::getObj('Event/Form/Req/Req.php', $id_fm); $EventForm_Req->initFromForm($form); $EventForm_Req->save($this->DBObj->id, $EventForm->AuthorizeNetResponce); require_once 'class/HTTP.php'; $url = Constant::get('BASE_URL') . '/' . CURR_PAGE . '/' . $this->DBObj->id . '?action=thank'; if (Constant::get('HAS_HTTPS')) { $url = str_replace('http','https', $url); } skHTTP::redirect($url); } else { if (!$justcomplete) $this->Doc->addContent(array('tpl'=>'text.tpl', 'text'=>'Please enter your payment information below to complete your event registration')); $this->_addYourCostElement($form, $member); $form->exec(); } break; default : $this->_addYourCostElement($form, $member); $form->exec(); break; } } else { $this->Doc->addContent(array('tpl' => 'Event/registration_denied.tpl')); } } /** * @param $form Form * @param $member array * @return Event_Show */ protected function _addYourCostElement($form, $member) { $field = Member::hasMemberCost($member) ? 'member_cost' : 'nonmember_cost'; $nAmount = $this->DBObj->db->queryOne('SELECT `' . $field . '` FROM mn_Event WHERE id=' . (int)$this->DBObj->id); if (isset($_POST['memberId'])) { $nAmount *= (1 + count($_POST['memberId'])); } if ($nAmount) { $form->insertElementBefore( Form::createElement('static', 'amounttext', 'Your Cost:', '$' . number_format($nAmount, 2)), 'fild[1]' ); } else { if ($form->elementExists('paymentHeader')) { $form->removeElement('paymentHeader'); } } return $this; } }