actions['showMember'] = 'doShowMember'; $this->actions['setPosition'] = 'doSetPosition'; $groupData = $this->DBObj->getGroupData(); $this->Doc->setTitle(htmlspecialchars($groupData['title']) . ' ' . $this->Doc->getTitle()); return $this; } public function doSetPositionAjax() { $memberId = $_POST['memberId']; $position = $_POST['position']; $isPositionAvailable = $this->DBObj->isPositionAvailable4Member($memberId, $position); if ($isPositionAvailable) { $this->DBObj->updatePosition($memberId, $position); }; $this->displayJSON($this->getPositions4Ajax($memberId)); return $this; } protected function getPositions4Ajax($memberId) { $memberPosition = $this->DBObj->getMemberPosition($memberId); $groupPosition = $this->DBObj->getGroupPositions(); $positions = array(); foreach ($groupPosition as $value => $title) { if ($this->DBObj->isPositionAvailable4Member($memberId, $value)) { $positions[] = array( 'title' => $title, 'value' => $value, 'selected' => ($memberPosition == $value), ); } } return $positions; } public function doShowMemberAjax() { $query = strtolower(Qs_Request::getGetValue("q")); if (!$query) { die(); } $members = $this->DBObj->getMembers4Ajax($query); foreach ($members as $member) { echo str_replace('|', '/', $member['member']) . "|" . $member['id'] . "|" . $member['id_misc_status'] . "|" . $member['id_misc_type'] . "\n"; } die(); } function doNew() { $this->setBackUrl(Constant::get('BASE_URL') . '/' . CURR_PAGE_FULL ); parent::doNew(); return $this; } function _doListBind(&$DB_List) { $DB_List->insertColLast( 'title', array( 'title' => 'Member Name', 'order_by' => 'last_name', 'tpl' => 'Volunteer/Member/Admin/cells/memberName.tpl', ) ); $DB_List->insertColLast( 'type', array( 'title' => 'Member type(s)', 'tpl' => 'Volunteer/Member/Admin/cells/accountType.tpl', ) ); $DB_List->insertColLast( 'role', array( 'title' => 'Position in the Group', 'order_by' => 'type', 'tpl' => 'Volunteer/Member/Admin/cells/role.tpl', 'attribs' => array('width' => '200'), ) ); $baseLink = Constant::get('BASE_URL') . '/' . CURR_PAGE_FULL ; $DB_List->insertColLast( 'options', array( 'title' => 'Options', 'tpl' => 'Volunteer/Member/Admin/cells/options.tpl', 'edit_link' => $baseLink . '?action=edit&id=', 'del_link' => $baseLink . '?action=del&id=', 'params' => array('id'), 'attribs' => array('width' => '120'), ) ); $DB_List->additionalOptions['groupPositions'] = $this->DBObj->getGroupPositions(); return $this; } function doList() { $filterForm = $this->getFilterForm(); $filterForm->exec(); $this->DBObj->setFilter($filterForm->getElementValue('query')); $this->Doc->addItemProp('JSs', 'js/app/adminVolunteerMember.js'); $this->Doc->addInitFunction('App_AdminVolunteerMember_List.initialize'); return parent::doList(); } function getFilterForm() { $form = parent::getFilterForm(); $form->removeElement('cancel_btn'); $form->addElement('button', 'cancel_btn', 'Cancel', array('class' => 'btn', 'onclick' => "document.location.href='" . Constant::get('BASE_URL') . '/' . CURR_PAGE_FULL . "'")); return $form; } function renderForm(&$form) { $membersLink = BASE_URL . '/admin/volunteer/member/' . $this->DBObj->getParentId(); $item = array( 'tpl' => 'center_link.tpl', 'link_list' => array( array( 'title' => 'Back to Member\'s List', 'link' => $membersLink ) ), ); $this->Doc->addContent($item); parent::renderForm($form); } function _bindFormFields(Form $form) { $groupUrl = BASE_URL . '/' . Volunteer::ALIAS . '/' . $this->DBObj->getParentId(); $form->addElement('static', 'userEndLink', 'User End Link', '' . $groupUrl . '' ); $form->addElement('text', 'member', 'Member'); $form->addElement('hidden', 'id_parent', null, array('id' => 'id_parent')); $form->addElement('hidden', 'id_volunteer', $this->DBObj->getParentId()); $form->addElement('select', 'type', 'Position in the Group', $this->DBObj->getGroupPositions()); $groupData = $this->DBObj->getGroupData(); if ('board' == $groupData['type']) { $memberType = VolunteerMember::DIRECTOR; } else { $memberType = VolunteerMember::MEMBER; } $form->setDefaults(array('type' => $memberType)); $this->Doc->addItemProp('JSs', 'js/app/adminVolunteerMember.js'); $this->Doc->addInitFunction( 'App_AdminVolunteerMember_Form.initialize', array( array( 'positions' => $this->DBObj->getGroupPositions(), 'liaisonPosition' => VolunteerMember::STAFF_LIAISON ) ) ); $form->addRuleRequired(array('member')); $form->addFormRule(array(&$this, 'validateForm')); return $form; } public function validateForm($data) { $errors = array(); if (empty($data['id_parent'])) { //admin do not choose member from autocomplete $errors['member'] = 'Please choose one of the members by using autocomplete feature'; } return empty($errors) ? true : $errors; } function addLink() { $item = array( 'tpl' => 'center_link.tpl', 'link_list' => array( array( 'title' => 'Back to all groups' , 'link' => Constant::get('BASE_URL') . '/admin/volunteer?action=cancel' ), array( 'title' => 'Add ' . $this->DBObj->itemName, 'link' => Constant::get('BASE_URL') . '/' . CURR_PAGE_FULL . '?action=new' ), ), ); $this->Doc->addContent($item); return $this; } }