'choose_existing' ); function Event_Grid(&$Doc, &$DBObj) { $this->DB_Grid($Doc, $DBObj); $this->actions['viewreport'] = 'doViewReport'; $this->actions['getDocInfo'] = 'doGetDocInfo'; $this->actions['getEventInfo'] = 'doEventInfo'; } function doNew() { $form = $this->_getNewForm(); $form = $this->_bindFormRules($form); $data = array('eventdate' => date('Y-m-d H:i:s', mktime() + 7 * 24 * 60 * 60), 'time_end' => date('H:i:s', mktime() + (7 * 24 + 4) * 60 * 60), 'registration_start' => date('Y-m-d H:i:s'), 'registration_end' => date('Y-m-d H:i:s', mktime() + 7 * 24 * 60 * 60)); $form->setDefaults($data); $form->exec(); } function doEdit() { $this->DBObj->initFromDB(); $form = $this->_getEditForm(); $form = $this->_bindFormRules($form, 0, 'edit'); $form->setDefaults($this->DBObj->getData()); $form->exec(); } function _getEditForm() { $form = $this->_getBaseForm(); $form = $this->_bindFormFields($form); if ($this->DBObj->getData('id_type') == 3) { $form->updateElementAttr(array('id_type'), array('disabled')); if ($this->DBObj->getData('parent_event_id')) { $form->updateElementAttr(array('registration_limit', 'member_cost'), array('disabled')); $form->removeElement('registration_date'); $form->removeElement('form'); } $form->addElement('hidden', 'id_type_hidden', 3); } $form->action = CURR_PAGE . '?action=update'; $form->addElement('hidden', 'action', 'update'); $form->addElement('hidden', 'id', $this->DBObj->getData('id')); return $form; } function _bindFormRules(Form $form, $id_type = 0, $action = '') { $form->addRuleRequired(array('name')); if ($id_type[0] != 3) { $form->addRuleRequired(array('id_type')); } $form->addRuleRequired(array('description', 'eventdate'), 'server'); $form->addFormRule(array($this, 'valid' . $action . 'Form')); return $form; } function validnewForm($aData) { if (!$aData['id_type']) return array('id_type' => 'Event Type is required!'); elseif ($aData['id_type'] == 3 && $aData['eventdate']['M'] != 1) return array( 'eventdate' => 'Brokerage Event Month should be set to January'); elseif ($aData['id_type'] == 3 && in_array($aData['eventdate']['Y'],$this->DBObj->db->queryCol('SELECT DISTINCT DATE_FORMAT(eventdate,"%Y") FROM mn_Event WHERE id_type=3'))) return array('eventdate' => 'Brokerage Event for '.$aData['eventdate']['Y'].' already scheduled'); else return true; } function valideditForm($aData) { if (!$aData['id_type'] && !$aData['id_type_hidden']) return array('id_type' => 'Event Type is required!'); if ($aData['id_type_hidden'] == 3) { if ($aData['eventdate']['M'] + 100 * $aData['eventdate']['Y'] != $this->DBObj->db->queryOne( 'SELECT DATE_FORMAT(eventdate, "%Y%m") FROM mn_Event WHERE id=' . (int) $this->DBObj->id)) return array( 'eventdate' => 'Date of this Brokerage Event should be in ' . $this->DBObj->db->queryOne( 'SELECT DATE_FORMAT(eventdate, "%M %Y") FROM mn_Event WHERE id=' . (int) $this->DBObj->id)); } else return true; } function _bindCustomRegisterFields(Form $form) { $elements = array(); $elements[] = $form->createElement( 'advcheckbox', 'has_register_link', '', 'Use Custom Registration URL', array(), array('n', 'y') ); $elements[] = $form->createElement('extended_text', 'register_link', '', array(), '', '
Example: http://google.com
'); $form->addGroup($elements, 'gRegisterLink', 'Custom Registration URL', ' ', false); $form->addFormRule(array($this, 'validateRegisterLink')); } function validateRegisterLink($data) { $errors = array(); if ('n' === $data['has_register_link']) { return true; } if (empty($data['register_link'])) { $errors['gRegisterLink'] = 'URL is required'; } else { require_once('Qs/Validate/Url.php'); $validator = new Qs_Validate_Url(); if (!$validator->isValid($data['register_link'])) { $errors['gRegisterLink'] = implode(', ', $validator->getMessages()); } } return empty($errors) ? true : $errors; } function _bindFormFields(Form $form) { $addLink = array( 'tpl' => 'center_link.tpl', 'link_list' => array( array( 'link' => 'javascript: eventForm.showSeoRows()', 'title' => 'Click here to edit the page title, meta tags, header and more' ), array( 'link' => 'admin/event', 'title' => 'Back to events' ) ) ); $this->Doc->addContent($addLink); $form->addElement( 'select', 'id_type', 'Event Type', array('Choose One -->') + $this->DBObj->getTypes(), array( 'id' => 'id_type', 'onchange' => 'eventForm.typeOnChange(this);' ) ); $form->addElement( 'extended_text', 'name', 'Event Name', array('style'=>'width:88%;'), '', ' Event ID: ' . $this->DBObj->id . '' ); $gEventDate = array( Form::createElement( 'calendar', 'eventdate', '', array( 'format' => 'MdY\[\C\A\L\E\N\D\A\R\_\B\U\T\T\O\N\] \T\i\m\e\:giA', 'optionIncrement'=>array('i'=>15) ) ), Form::createElement( 'date', 'time_end', ' to ', array( 'format' => 'giA', 'optionIncrement' => array('i'=>15) ) ) ); $form->addGroup($gEventDate, 'eventdate', 'Event Date', null, false); $this->_bindCustomRegisterFields($form); /** * @var HTML_QuickForm_img_db $image */ $image = &$form->addElement('img_db', 'image', 'Upload Image', '', 'Delete image'); $image->titles['last'] = 'Note: preferable image size is 79x60'; $form->addElement('text', 'address', 'Event Location'); $form->addElement('text', 'title', 'Page Title'); $form->addElement('textarea', 'metakeywords', 'Meta Keywords', array('rows' => 3, 'cols' => 50)); $form->addElement('textarea', 'metadescription', 'Meta Description', array('rows' => 3, 'cols' => 50)); $form->addElement( 'extended_text', 'registration_limit', 'Registration Limit', null, '', 'Current Registrations: ' . $this->DBObj->getData('registered_count') . '' ); $form->addElement('extended_text', 'member_cost', 'Member Cost', null, '$'); $form->addElement('extended_text', 'nonmember_cost', 'Non-Member Cost', null, '$'); // commented cause never used at user end // $form->addElement('text', 'group_name', 'Group Name'); $form->addElement('text', 'group_limit', 'Group Limit'); $gRegistrationDate = array( Form::createElement( 'calendar', 'registration_start', '', array( 'format' => 'MdY\[\C\A\L\E\N\D\A\R\_\B\U\T\T\O\N\] giA', 'optionIncrement'=>array('i'=>15) ) ), Form::createElement( 'calendar', 'registration_end', '  to  ', array( 'format' => 'MdY\[\C\A\L\E\N\D\A\R\_\B\U\T\T\O\N\] giA', 'optionIncrement'=>array('i'=>15) ) ) ); $form->addGroup($gRegistrationDate, 'registration_date', 'Online Registration Data Range', null, false); $form->addElement('advcheckbox', 'exchange', 'Exchange Event', '', null, array(0, 1)); $form->addElement('advcheckbox', 'montly_program', 'Monthly Program', '', null, array(0, 1)); $form->addElement( 'advcheckbox', 'education', 'Education Event', '', array( 'id' => 'education', 'onchange' => 'eventForm.educationEventOnChange(this);', 'onclick' => 'this.blur()' ), array(0, 1) ); $this->_bindNewDocFields($form); $form->addElement( 'select', 'doc_number', 'Course Name', array('Choose One -->') + $this->DBObj->getDocuments(), array('id' => 'doc_number', 'onchange' => 'getDOCInfo();') ); $form->addElement('text', 'ce_credits', 'CE Credits', array('style' => 'width:50px;')); $form->addElement( 'extended_select', 'doc_status_id', 'Course Status', array('' => 'Select One') + (array) $this->DBObj->get4Select('DEventDocStatus'), array(), array('after' => '
Please note: in case you update the "CE credits" or "Course Status" ' . 'fields, the chosen DOC Course will be automatically updated with that data for every ' . 'event it is attached to.
') ); $gForm = array( Form::createElement( 'select', 'id_form', '', array('Do Not Collect Additional Information') + $this->DBObj->getForms(), array('id' => 'form_select') ), Form::createElement( 'button', 'formlink', 'Add A New Form Here', array('onclick' => 'donewform("' . BASE_URL . '/admin/event/form?action=new")') ) ); $form->addGroup($gForm, 'form', 'Collect Additional Data During Event Registration?', null, false); $form->addElement('advcheckbox', 'list_foursomes', 'Include List of Foursomes', '', null, array(0, 1)); $form->addElement('html_editor', 'description', 'Event Description'); $form->addElement('textarea', 'description_vcs', 'Event Description for *.vcs file', array('rows' => 8)); $this->Doc->addInitObject('App_Event_Form', array($form->getAttribute('id')), 'eventForm'); $this->Doc->addInitFunction('eventForm.hideSeoRows'); return $form; } protected function _bindNewDocFields(Form $form) { $groupDocCourse = array(); $groupDocCourse[] = $form->createElement('radio', 'doc_action', '', 'Choose Existing', 'choose_existing'); $groupDocCourse[] = $form->createElement('radio', 'doc_action', '', 'Add New', 'new'); $form->addGroup($groupDocCourse,'groupDocCourse', 'DOC Course Options', '
', false); $form->addElement('text', 'new_doc_number', 'Course ID', array('maxlength' => 16)); $form->addElement('text', 'new_doc_name', 'Course Name'); $renewal_date = $form->createElement('calendar', 'new_renewal_date', 'Renewal Date'); $renewal_date->_options['addEmptyOption'] = true; $form->addElement($renewal_date); $form->addElement('text', 'new_ce_hours', 'CE Credits'); $form->addElement('select', 'new_status_id', 'Course Status', array('' => 'Select One') + (array) $this->DBObj->get4Select('DEventDocStatus')); if ('new' == $this->_getData('doc_action') || in_array($this->_action, array('new', 'edit'))) { $form->addRuleRequired(array('new_doc_number','new_doc_name'), 'server'); $form->addFormRule(array(&$this, 'validateDocForm')); } } public function validateDocForm($data) { $errors = array(); if ('new' == $data['doc_action'] && !$this->DBObj->getTable('EventDocumentofCommerce')->isUnique('doc_number', $data['new_doc_number']) ) { $errors['new_doc_number'] = 'Course Number is not unique'; } return empty($errors) ? true : $errors; } function _doListBind(&$DB_List) { $DB_List->urlVarNames[] = 'eventyear'; $DB_List->insertColLast('date', array('title' => 'Date of Event', 'order_by' => 'eventdate', 'width' => '100', 'tpl' => DB_LIST_CELL_DATE, 'date_format' => '%b %e, %Y', 'params' => array('eventdate'))); $DB_List->insertColLast('type', array('title' => 'Event Type', 'order_by' => $this->DBObj->tableNameDB . 'Type.title', 'width' => '100', 'tpl' => DB_LIST_CELL_TEXT, 'params' => array('title'))); $DB_List->insertColLast('image', array('title' => 'Event Image', 'width' => '90', 'no_img_url' => 'img/announcement/default_event.jpg', 'imgW' => 79, 'imgH' => 60, 'tpl' => DB_LIST_CELL_IMG, 'params' => array('image'))); $DB_List->insertColLast('name', array('title' => 'Event Name', 'order_by' => 'name', 'width' => '200', 'tpl' => DB_LIST_CELL_TEXT, 'params' => array('name'))); $DB_List->insertColLast('registration', array('title' => 'Registration Deadline
Attendance Information', 'order_by' => 'registration_start', 'width' => '250', 'date_format' => '%b %e, %Y', 'tpl' => BASE_PATH . '/tpl/Event/List/cells/registration.tpl', 'params' => array('registration_start', 'registration_end', 'id', 'registered_count', 'registration_closed', 'education', 'ended', 'parent_event_id'))); $DB_List->insertColLast('options', array('title' => 'Options', 'width' => '150', 'tpl' => DB_LIST_CELL_EDIT_DEL, 'edit_link' => Constant::get('BASE_URL') . '/' . CURR_PAGE . '?action=edit&id=', 'edit_title' => 'Edit Event Details', 'del_link' => Constant::get('BASE_URL') . '/' . CURR_PAGE . '?action=del&id=', 'params' => array('id', 'title'))); $DB_List->def_order_by = 'eventdate DESC'; $DB_List->ipp=1048576; $DB_List->bind(); return true; } function addLink() { $this->Doc->addContent( array('tpl' => 'center_link.tpl', 'link_list' => array( array('title' => 'Add A New ' . $this->DBObj->itemName, 'link' => BASE_URL . '/' . CURR_PAGE . '?action=new'), array('title' => 'Go to Events Report ', 'link' => BASE_URL . '/admin/event/eventreports')))); return true; } function doInsert() { $form = $this->_getNewForm(); $id_type = $form->getElementValue('id_type'); $form = $this->_bindFormRules($form, $id_type[0], 'new'); if ($form->validate()) { $this->DBObj->initFromForm($form); $parent_id = $this->DBObj->insert(); if ($this->DBObj->_data['id_type'] == 3) { $this->insertBrokerageChild($parent_id); } if (isset($_REQUEST['submit_grp']['submit_post_btn'])) { $url = BASE_URL . '/admin/blog?action=new&id_category=3&id_event=' . $parent_id; skHTTP::redirect($url); } Session::setData(CURR_PAGE, 'msg', $this->DBObj->itemName . ' added'); $this->doBack(); } else { $form = $this->_bindFormRules($form, 0, 'new'); $form->exec(); } return true; } function insertBrokerageChild($parent_id) { $this->DBObj->_data['parent_event_id'] = (int) $parent_id; $cName = $this->DBObj->_data['name']; for($month = 2; $month < 13; $month++) { $this->DBObj->_data['parent_event_id'] = (int) $parent_id; $this->DBObj->_data['name'] = str_replace(date("F", mktime(0, 0, 0, 1, 1, 2001)), date("F", mktime(0, 0, 0, $month, 1, 2001)), $cName); list ($cDate, $cTime) = explode(' ', $this->DBObj->_data['eventdate']); $year = (int) $cDate; for($day = 15; $day < 22; $day++) if (date("w", mktime(0, 0, 0, $month, $day, $year)) == 4) break; $this->DBObj->_data['eventdate'] = $year . '-' . $month . '-' . $day . ' ' . $cTime; $this->DBObj->insert(); } } function updateBrokerageChild($parent_id) { $aFields = array('registration_limit', 'member_cost', 'registration_start', 'registration_end'); foreach ($aFields as $cField) $aData[$cField] = $this->DBObj->_data[$cField]; $this->DBObj->table->update($aData, 'parent_event_id = ' . $this->DBObj->db->quote($parent_id, 'integer')); } function doUpdate() { $form = $this->_getEditForm(); $nCurrentTypeID = $this->DBObj->db->queryOne('SELECT id_type FROM mn_Event WHERE id=' . (int) $this->DBObj->id); $nParentID = $this->DBObj->db->queryOne('SELECT parent_event_id FROM mn_Event WHERE id=' . (int) $this->DBObj->id); if ($nCurrentTypeID == 3) { $IDType = &$form->getElement('id_type'); $IDType->setValue(3); } $form = $this->_bindFormRules($form, $form->getElementValue('id_type'), 'edit'); if ($form->validate()) { $this->DBObj->initFromForm($form); $this->DBObj->update(); if ($nCurrentTypeID != 3 && $this->DBObj->_data['id_type'] == 3) $this->insertBrokerageChild($this->DBObj->id); if ($nCurrentTypeID == 3) $this->updateBrokerageChild($this->DBObj->id); Session::setData(CURR_PAGE, 'msg', $this->DBObj->itemName . ' updated'); $this->doBack(); } else { $form = $this->_bindFormRules($form, $form->getElementValue('id_type'), 'edit'); if ($nCurrentTypeID == 3) { $form->updateElementAttr(array('id_type'), array('disabled')); if ($nParentID) { $form->updateElementAttr(array('registration_limit', 'member_cost'), array('disabled')); $form->removeElement('registration_date'); $form->removeElement('form'); } $form->addElement('hidden', 'id_type_hidden', 3); } $form->exec(); } return true; } function doList() { $this->_saveBackUrl(); $this->addLink(); $filtFrm = $this->getFilterForm(); $this->DBObj->setFilter($filtFrm->getElementValue('query')); $this->DBObj->eventyear = (int)$filtFrm->exportValue('eventyear'); $filtFrm->exec(); if ($this->DBObj->_filterSql() || $this->DBObj->eventyear) { require_once('class/DB/List/List.php'); $DB_List = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $this->_doListBind($DB_List); $DB_List->exec(); } return true; } function getFilterForm() { $form = parent::getFilterForm(); $aYearsRow=$this->DBObj->db->queryRow('SELECT MAX(YEAR(eventdate)) maxyear, MIN(YEAR(eventdate)) minyear FROM mn_Event'); $aYears=array(''=>'Select Year'); for ($year=$aYearsRow['maxyear']; $year>=$aYearsRow['minyear']; $year--) { $aYears[$year]=$year; } $form->setTpl('tpl/Event/filterform.tpl'); $form->addElement('select', 'eventyear', '', $aYears, array('onchange' => 'this.form.submit();')); return $form; } function doGetDocInfoAjax() { $aDoc=$this->DBObj->getDocuments($_REQUEST['docid']); $this->displayJSON($aDoc); die(); } function doEventInfoAjax() { $this->DBObj->initFromDB(); $aEvent['id_type']=$this->DBObj->getData('id_type'); $aEvent['name']=$this->DBObj->getData('name'); $aEvent['member_cost']=$this->DBObj->getData('member_cost'); $aEvent['nonmember_cost']=$this->DBObj->getData('nonmember_cost'); $aEvent['eventdate']=strftime('%B %d, %Y %l:%M %p',strtotime($this->DBObj->getData('eventdate'))).'-'. strftime('%l:%M %p',strtotime($this->DBObj->getData('time_end'))); if ($this->DBObj->getData('address')) $aEvent['address']=$this->DBObj->getData('address').' (View Map)'; if (!$this->DBObj->getData('member_cost') && !$this->DBObj->getData('nonmember_cost')) $aEvent['cost']='Free'; elseif (!$this->DBObj->getData('member_cost')) $aEvent['cost']='Member: Free, Non-Member: $'.number_format($this->DBObj->getData('nonmember_cost'),2); elseif (!$this->DBObj->getData('nonmember_cost')) $aEvent['cost']='Member: $'.number_format($this->DBObj->getData('member_cost'),2); else $aEvent['cost']='Member: $'.number_format($this->DBObj->getData('member_cost'),2).', Non-Member: $'.number_format($this->DBObj->getData('nonmember_cost'),2); $aEvent['ce_credits']=$this->DBObj->getData('ce_credits'); if ($this->DBObj->getData('image')) $aEvent['image']=image_db($this->DBObj->getData('image'),79,60); else $aEvent['image']='img/announcement/default_event.jpg'; $Req = SiteMap::getObj('Event/Form/Req/Req.php', null, null, $this->DBObj->id); $EventForm = SiteMap::getObj('Event/Form/Form.php', $Req->getFormIDByID()); $form = $EventForm->getForm($this->Doc, $this->DBObj->id, 'eng', (int)$_REQUEST['id_member']); $form->return_form_arr=true; $aEvent['form']=$form->exec(false); $this->displayJSON($aEvent); die(); } function _getBaseForm($method = 'post') { $form = new EventForm($this->Doc, 'form_' . strtolower(get_class($this->DBObj)), $method, '', '_self', array('class' => 'form form_' . strtolower(get_class($this->DBObj)))); return $form; } function _getNewForm() { $form = parent::_getNewForm(); $form->setSubmitPostTitle('Save and Post'); $form->setDefaults($this->_formDefaults); return $form; } }