[Request Approved]'; var $actions = array( 'list' => 'doList', 'cancel' => 'doBack', 'new' => 'doNew', 'insert' => 'doInsert', 'edit' => 'doEdit', 'update' => 'doUpdate', 'del' => 'doDelete', 'activate' => 'doActivate', 'get_company' => 'doGetCompany', 'get_location' => 'doGetLocation', 'edit_location' => 'doEditLocation', 'edit_company' => 'doEditCompany', 'assign_nrds_id' => 'doAssignNrdsId', 'assign_manualy_nrds_id' => 'doAssignManualyNrdsId', 'clear_nrds_id' => 'doClearNrdsId', 'export_search' => 'doExportSearch', 'export_purchasable' => 'doExportPurchasable', 'getStatus' => 'doGetStatus', 'saveSearch' => 'doSaveSearch', 'deleteSearch' => 'doDeleteSearch', 'getSavedSearch' => 'doGetSavedSearch', ); var $linkTextLength = 33; var $alias = 'admin/member'; /** * @param $DB_List DB_List * @return bool */ function _doListBind(&$DB_List) { $DB_List->insertColLast('nrds_id', array( 'title'=>'NRDS ID', 'order_by'=>'nrds_id', 'width'=>60, 'tpl'=>DB_LIST_CELL_TEXT, 'params'=>array('nrds_id'), )); $DB_List->insertColLast('name', array( 'title'=>'Member Name', 'order_by'=>'last_name', 'width'=>140, 'url' => CURR_PAGE_FULL.'?action=edit&id=', 'tpl'=>DB_LIST_CELL_LINK, 'params'=>array('id', 'name'), )); $DB_List->insertColLast('account_type', array( 'title'=>'Account Type', 'width'=>90, 'tpl'=>'Member/Admin/cells/account_type.tpl', 'params'=>array('account_type'), )); $DB_List->insertColLast('member_type', array( 'title'=>'Member Type', 'width'=>100, 'tpl'=> 'Member/Admin/cells/member_type.tpl', 'params'=>array('member_type'), )); $DB_List->insertColLast( 'status', array( 'title' =>'Status', 'width' => 80, 'tpl' => 'Member/Admin/cells/status.tpl', 'params' => array('status'), ) ); $DB_List->insertColLast('contact_information', array( 'title'=>'Contact Information', 'width'=>235, 'tpl'=>BASE_PATH.'/tpl/Member/List/cells/contact_information.tpl', 'params'=>array(), )); $DB_List->insertColLast('location_name', array( 'title'=>'Location', 'width'=>100, 'url' => 'admin/location?action=edit&id=', 'tpl'=>DB_LIST_CELL_LINK, 'params'=>array('id_location', 'location_name'), )); $DB_List->insertColLast('options', array( 'title'=>'Options', 'width'=>90, 'alias'=>$this->alias, 'tpl'=>BASE_PATH.'/tpl/Member/List/cells/options.tpl', 'params'=>array('id'), )); $DB_List->bind(); return true; } /** * @param $form Form * @param $elName * @return */ function formAddPhoneRule(&$form, $elName) { if (is_array($elName) && !empty($elName)) { foreach($elName as $k=>$v) { $this->formAddPhoneRule($form, $v); } return; } $el = &$form->getElement($elName); $regex = "/^\(\d{3}\)\s*\d{3}\s*-\s*\d{4}(\s.*)?$/"; $form->addRule($elName, $el->getLabel().' is in wrong format', 'regex', $regex); $form->addRule($elName, $el->getLabel().' is in wrong format', 'regex', $regex, 'client'); } /** * @param $form Form * @param $name * @param $list * @return array|bool */ function formCreateAdvcheckboxList(&$form, $name, $list) { if (!is_array($list) || empty($list)) { return false; } $elList = array(); foreach ($list as $id => $title) { $elList[$id] = $form->createElement('advcheckbox', $name.'['.$id.']', '', $title, null, array('0', $id)); } return $elList; } /** * @param $form Form * @param $list * @return array */ function formCreateElementLinks(&$form, $list) { $elList = array(); $elList[] = $form->createElement('static', 'static_area', '', '

 

'); return $elList; } function getSeparators4Table($list, $cntCol = 3) { $cntList = count($list); if ($cntList <= $cntCol) { $separators = array_fill(1, $cntList-1, ''); return $separators; } $listIPP = (int)ceil($cntList/$cntCol); $separators = array_fill(0, $cntList, '
'); foreach ($separators as $k=>&$v) { if ($k%$listIPP == $listIPP - 1 && isset($separators[$k+1])) { $v = ''; } } return $separators; } /** * @param $form Form * @param $elName * @param null $title * @param $list * @param $cntCol * @return void */ function formCreateTableOfCheckboxes(&$form, $elName, $title = null, $list, $cntCol) { $elList = array(); $separators = array(); $elList[] = $form->createElement('static', 'static_'.$elName, '', ((null !== $title)?'
'.$title.'
':'') .'
' ); $separators[] = ''; $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, $elName, $list)); $separators = array_merge($separators, $this->getSeparators4Table($list, $cntCol)); $separators[] = ''; $elList[] = $form->createElement('static', 'static_'.$elName, '', '
'); $form->addGroup($elList, 'g'.$elName, '', $separators, false); } /** * @param $form Form * @return void */ function formAddSectionBioCategories(&$form) { $form->addElement('header', 'header_bio_categories', 'BIO CATEGORIES'); $elList = array(); $separators = array(); $areaList = $this->DBObj->getDArea4Select('sorter', "info = 'y'"); $elList[] = $form->createElement('static', 'static_area_info', '', '
Market Area of Specialty:
'); $separators[] = ''; $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'id_area_info', $areaList)); $separators = array_merge($separators, array_fill(1, count($areaList), '
')); $elList[] = $form->createElement('static', 'static_area', '', '
Real Estate Specialty:
'); $separators[] = ''; $specialtyList = $this->DBObj->getDSpecialty4Select('sorter', "info = 'y'"); $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'id_specialty_info', $specialtyList)); $separators = array_merge($separators, array_fill(0, count($specialtyList), '
')); $elList[] = $form->createElement('static', 'static_area', '', '
These options are viewable by the public and appear in your online bio within mncar.org.
'); $separators[] = ''; $form->addGroup($elList, 'gMisc', '', $separators, false); } /** * @param $form Form * @return void */ function formAddSectionProfileCategories(&$form) { $form->addElement('header', 'header_member_profile_categories', 'MEMBER PROFILE CATEGORIES'); $elList = array(); $separators = array(); // Real Estate Specialty $elList[] = $form->createElement('static', 'static_area', '', '
These options are not viewable by the public and are used by MNCAR staff for statistical analysis.
'); $separators[] = ''; $elList[] = $form->createElement('static', 'static_area', '', '
Real Estate Specialty:
'); $separators[] = ''; $specialtyList = $this->DBObj->getDSpecialty4Select('sorter', "profile = 'y'"); $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'id_specialty', $specialtyList)); $separators = array_merge($separators, array_fill(0, count($specialtyList), '
')); $elList[] = $form->createElement('static', 'static_area', '', '
'); $separators[] = ''; // Line of work $elList[] = $form->createElement('static', 'static_area', '', '
Line of work:
'); $separators[] = ''; $lineOfWorkList = $this->DBObj->getDLineOfWork4Select(); $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'id_line_of_work', $lineOfWorkList)); $separators = array_merge($separators, array_fill(0, count($lineOfWorkList), '
')); $elList[] = $form->createElement('text', 'other_line_of_work', 'Other'); // Market Area of Specialty $areaList = $this->DBObj->getDArea4Select('sorter', "profile = 'y'"); $elList[] = $form->createElement('static', 'static_area', '', '
Market Area of Specialty:'); $separators[] = ''; $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'id_area', $areaList)); $separators = array_merge($separators, array_fill(1, count($areaList), '
')); $form->addGroup($elList, 'gMisc2', '', $separators, false); } /** * @param $form Form * @return void */ function formAddSectionTypeOfBusiness(&$form) { $form->addElement('header', 'header_type_of_business', 'TYPE OF BUSINESS'); $elList = array(); $separators = array(); // Real Estate Specialty $elList[] = $form->createElement('static', 'static_area', '', '
These options are not viewable by the public and are used by MNCAR staff for statistical analysis.
'); $separators[] = ''; $typeOfBusinessList = $this->DBObj->getDTypeOfBusiness4Select('sorter'); $itemPerColumn = ceil((count($typeOfBusinessList)+1)/3); for ($i = 0; $i < 3; $i++) { $elList[] = $form->createElement('static', 'static_area_start' . $i, '', '
'); $separators[] = ''; $checkboxList = array_slice($typeOfBusinessList, $itemPerColumn*$i, $itemPerColumn, true); $elList = array_merge($elList, $this->formCreateAdvcheckboxList($form, 'type_of_business_id', $checkboxList)); $separators = array_merge($separators, array_fill(0, count($checkboxList), '
')); if ($i == 2) { $elList[] = $form->createElement('text', 'other_type_of_business', 'Other'); $separators[] = '
'; } $elList[] = $form->createElement('static', 'static_area_end' . $i, '', '
'); $separators[] = ''; } $elList[] = $form->createElement('static', 'static_area_end' . $i, '', '
'); $form->addGroup($elList, 'gMisc3', '', $separators, false); } /** * @param $form Form * @return void */ function formAddSectionBillingPreferencesHeader(&$form) { $form->addElement('header', 'header_billing-preferences', 'MNCAR BILLING PREFERENCES'); } /** * @param $form Form * @param $groupBilling * @return void */ function formAddSectionBillingPreferencesFields($form, &$groupBilling) { $groupBilling[] = $form->createElement('static', 'billing_static_1', 'Invoicing Options'); $groupBilling[] = $form->createElement('radio', 'billing_send_paper_copy', '', 'Standard Invoicing - paper invoice sent by mail', 'y'); $groupBilling[] = $form->createElement('radio', 'billing_send_paper_copy', '', 'Green Invoicing - electronic invoice sent by email with no paper copy', 'n'); } /** * @param $form Form * @param $elName * @param $label * @param string $phoneFormat * @param string $regex * @return void */ function formAddTitledPhone(&$form, $elName, $label, $phoneFormat = ' Format: (xxx) xxx-xxxx', $regex = "/^\(\d{3}\)\s*\d{3}\s*-\s*\d{4}(\s.*)?$/") { $phoneTitles = $this->DBObj->getDPhoneTitle4Select(); $phoneTitles = array_values($phoneTitles); $phoneTitles = array(''=>'Choose a label for this number') + array_combine($phoneTitles, $phoneTitles) + array(' '=>'Other'); $group = array(); $group[] = $form->createElement('select', $elName.'_title', '', $phoneTitles); $group[] = $form->createElement('extended_text', $elName, '', array('class'=>'titled_phone', 'onblur'=>'hidehint(this);', 'onfocus'=>'showhint(this);', 'onkeyup'=>"formatPhone(this);"), null, $phoneFormat); $form->addGroup($group, 'g'.$elName, $label, ' ', false); if ($regex) { $form->addGroupRule('g'.$elName, array( $elName => array( array($label.' is in wrong format', 'regex', $regex), array($label.' is in wrong format', 'regex', $regex, 'client'), ) )); } } /** * @param $form Form * @return void */ function formAddSectionBroadcastEmailPreferences(&$form) { $form->addElement('header', 'header_profile_preferences', 'BROADCAST EMAIL PREFERENCES'); $emailTypeList = $this->DBObj->getDEmailType4Select(); $this->formCreateTableOfCheckboxes($form, 'id_email_type', ' Which types of emails would you like to receive?', $emailTypeList, 3); $emailGroupList = $this->DBObj->getDEmailGroupType4Select(); $this->formCreateTableOfCheckboxes($form, 'id_email_group', ' Which distribution group would you like to join?', $emailGroupList, 3); /*$areaListByType = $this->DBObj->getDAreaByType(); $gAreaSeparators = array(''); $gArea = array(); $gArea[] = $form->createElement('static', 'static_broadcast_area_table', '', '
 You can choose to receive e-mails only related to the markets you are interested in, please set those preferences:
'); $lastKey = end(array_keys($areaListByType)); foreach ($areaListByType as $key => $type) { $static = $form->createElement('static', 'static_broadcast_area_'.$type['id'], '', '
'.$type['title'].'
'); array_push($gArea, $static); array_push($gAreaSeparators, ' '); $elements = $this->formCreateAdvcheckboxList($form, 'id_email_area['.$type['id'].']', $type['items']); $this->arrayPushArray($gArea, $elements); $this->arrayPushArray($gAreaSeparators, array_fill(0, count($type['items']) - 1, '
')); array_push($gAreaSeparators, ($key == $lastKey)?'
':'
'); } //$static = $form->createElement('static', 'static_broadcast_link', '', 'View Market Maps'); $static = $form->createElement('static', 'static_broadcast_link', '', '
How are markets defined? | View Market Maps
' ); array_push($gArea, $static); array_push($gAreaSeparators, ' '); $form->addGroup($gArea, 'gEmailArea', '', $gAreaSeparators, false);*/ $elList = array(); $elList[] = $form->createElement('static', 'static_specific_senders', '', '
You can list specific senders in the box below to avoid getting emails from them. Add their sending email address to this list below.
'); $elList[] = $form->createElement('textarea', 'specific_senders', '', array('rows'=>4, 'style'=>'width:99%')); $elList[] = $form->createElement('static', 'static_note', null, '
Note: You may enter one or more email addresses above separated by commas
'); $form->addGroup($elList, 'gSpecificSenders', '', '', false); $this->Doc->addContent(array('tpl'=>'text.tpl', 'text'=>" ")); } protected function _getNrdsIdAssignLinks() { return ' ' . '' . '' . '' . ''; } /** * @param $form Form * @return Form */ function _bindFormFields($form) { $this->Doc->addItemProp('JSs', 'js/element_links.js'); $this->Doc->addItemProp('JSs', 'js/admin_member_form.js'); $options = $this->DBObj->getAccessMap(); $this->Doc->addInitFunction( 'initMemberForm', array( $form->_attributes['id'], intval($this->DBObj->getData('id_company')), intval($this->DBObj->getData('id_location')), $options, time() * 1000, ) ); $form->addElement('hidden', 'redirect_url'); // NRDS SPECIFIC INFORMATION $form->addElement('header', 'header_nrds_specific_information', 'NRDS SPECIFIC INFORMATION'); if ($this->DBObj->id) { $form->addElement( 'extended_text', 'nrds_id', 'NRDS ID', array('class'=>'inp_nrds_id', 'size'=>15, 'readonly'=>'readonly'), '', $this->_getNrdsIdAssignLinks() ); } else { $form->addElement( 'static', 'nrds_not_available', 'NRDS ID', 'The ability to assign NRDS ID will be available once the member is successfully saved' ); } $form->addElement('static', 'nrds_id_date_joined', 'Date Joined'); // MNCAR MEMBERSHIP INFORMATION $form->addElement('header', 'header_mncar_membership_information', 'MNCAR MEMBERSHIP INFORMATION'); $gName = array(); $gName[] = $form->createElement('text', 'first_name', '*First Name ', array('size' => 25, 'class' => 'first_name')); $gName[] = $form->createElement('text', 'middle_initial', 'Middle Initial ', array('size' => 1, 'maxlength' => 1, 'class' => 'middle_initial')); $gName[] = $form->createElement('text', 'last_name', '*Last Name ', array('size' => 25, 'class' => 'last_name')); $form->addGroup($gName, 'gName', 'Name', ' ', false); $form->addGroupRule('gName', array( 'first_name' => array( array('First Name is required', 'required'), array('First Name is required', 'required', null, 'client'), ), 'last_name' => array( array('Last Name is required', 'required'), array('Last Name is required', 'required', null, 'client'), ) )); $form->addElement('hidden', 'id_company'); $form->addElement('static', 'company_special_element', 'Company', ' '.$this->DBObj->getCompanyName($this->DBObj->getData('id_company')).' '); $form->addElement('hidden', 'id_location'); $form->addElement('static', 'location_special_element', 'Location', ' '.$this->DBObj->getLocationName($this->DBObj->getData('id_location')).' '); // Account Type $gAccount = array(); $separators = array(); $gAccount[] = $form->createElement('static', 'account_table_start', '
'); $separators[] = ''; // MNCAR $gAccount[] = $form->createElement('select', 'id_mncar_type', '', array('' => 'MNCAR Member Type') + (array) $this->DBObj->getDMncarMemberType4Select()); $separators[] = '
'; $options = $this->DBObj->getDMemberStatus4Select('mncar', $this->_getData('id_mncar_type')); $calendarOptions = array( 'maxYear' => idate('Y') + 2, 'addEmptyOption' => true, ); $attribs = array(); if (empty($options)) { $attribs['disabled'] = 'disabled'; } $gAccount[] = $form->createElement('select', 'id_mncar_status', '', array('' => 'Status') + (array) $options, $attribs); /* DATE JOINED for mncar_status */ $separators[] = '
'; $gAccount[] = $form->createElement('static', 'mncar_status_joined_label', 'Date Joined:'); $separators[] = '
'; /** @var $calendar HTML_QuickForm_calendar */ $calendar = $form->createElement('calendar', 'mncar_status_joined', '', $calendarOptions, $attribs); $gAccount[] = $calendar; $separators[] = '
'; // MNCAR-L $gAccount[] = $form->createElement('select', 'id_mncar_l_type', '', array('' => 'MNCAR-L Member Type') + (array) $this->DBObj->getDMncarLMemberType4Select()); $separators[] = '
'; $options = $this->DBObj->getDMemberStatus4Select('mncar_l', $this->_getData('id_mncar_l_type')); $attribs = array(); if (empty($options)) { $attribs['disabled'] = 'disabled'; } // EDAM ID $form->addElement('hidden', 'edam_id'); $edam_id = $form->createElement('text', 'edam_id', 'EDAM ID', array('size' => 15)); $edam_id->setValue($this->_getData('edam_id')); // END EDAM ID $gAccount[] = $form->createElement( 'extended_select', 'id_mncar_l_status', '', array('' => 'Status') + (array) $options, $attribs, array(/*'after'=>''*/) ); /* DATE JOINED for mncar_l_status */ $separators[] = '
'; $gAccount[] = $form->createElement('static', 'mncar_l_status_joined_label', 'Date Joined:'); $separators[] = '
'; /** @var $calendar HTML_QuickForm_calendar */ $calendar = $form->createElement('calendar', 'mncar_l_status_joined', '', $calendarOptions, $attribs); $gAccount[] = $calendar; unset($calendar); unset($date); $separators[] = '
'; // Misc $gAccount[] = $form->createElement('select', 'id_misc_type', '', array('' => 'Miscellaneous Account Type') + (array) $this->DBObj->getDMiscMemberType4Select()); $separators[] = '
'; $options = $this->DBObj->getDMemberStatus4Select('mncar_l', $this->_getData('id_misc_type')); $attribs = array(); if (empty($options)) { $attribs['disabled'] = 'disabled'; } $gAccount[] = $form->createElement('select', 'id_misc_status', '', array('' => 'Status') + (array) $options, $attribs); /* DATE JOINED for misc status */ $separators[] = '
'; $gAccount[] = $form->createElement('static', 'misc_joined_label', 'Date Joined:'); $separators[] = '
'; /** @var $calendar HTML_QuickForm_calendar */ $calendar = $form->createElement('calendar', 'misc_status_joined', '', $calendarOptions, $attribs); $gAccount[] = $calendar; $separators[] = ''; $gAccount[] = $form->createElement('static', 'account_table_end', '
'); $separators[] = 'Other Options:'; $gAccount[] = $form->createElement('advcheckbox', 'send_focus_newsletter', '', 'Receive Focus', array(), array('n', 'y')); $separators[] = ' '; $gAccount[] = $form->createElement('advcheckbox', 'is_support_account', '', 'Assist Other Users', array(), array('n', 'y')); $separators[] = '
'; //volunteer attention $gAccount[] = $form->createElement( 'static', 'volunteer_attention', null, $this->_getVolunteerAttention() ); $form->addGroup($gAccount, 'gAccount', 'Account Options', $separators, false); // MCPE INFORMATION $form->addElement('header', 'header_mcpe_information', 'MCPE INFORMATION'); $form->addElement('extended_select', 'allow_mcpe_access', 'Allow MCPE Access', array('n'=>'No', 'y'=>'Yes'), null, array('after'=>' Date of last status change: '.$this->DBObj->getData('mcpe_status_date')) ); $form->addElement('select', 'id_mcpe_access_type', 'MCPE Access Type', array(0=>'N/A') + (array)$this->DBObj->getDMCPEAccessType4Select()); // INDIVIDUAL BASIC INFORMATION $form->addElement('header', 'header_individual_basic_information', 'INDIVIDUAL BASIC INFORMATION'); $form->addElement('text', 'generation', 'Generation'); $form->addElement('text', 'designations', 'Designations'); $phoneFormat = ' Format: (xxx) xxx-xxxx'; $this->formAddTitledPhone($form, 'primary_phone', 'Primary Phone #'); $this->formAddTitledPhone($form, 'secondary_phone', 'Secondary Phone #'); $form->addElement('extended_text', 'fax', 'Direct Fax Number', array('class'=>'titled_phone', 'onblur'=>'hidehint(this);', 'onfocus'=>'showhint(this);', 'onkeyup'=>"formatPhone(this);"), null, $phoneFormat); $this->formAddPhoneRule($form, array('fax')); $form->addElement('extended_text', 'website', 'Website', array('class'=>'inp_website'), 'http://'); $form->addElement('text', 'email', 'Email Address (Web Site Login)', array('class'=>'inp_email', 'size'=>80)); $form->addRuleRequired(array('email')); $form->addElement('select', 'id_market', 'MNCAR Market', array(0=>'') + (array)$this->DBObj->getDMarket4Select()); $form->addRule('email', 'Email Address (Web Site Login) is in wrong format', 'email'); $form->addRule('email', 'Email Address (Web Site Login) is in wrong format', 'email', null, 'client'); $form->addElement('password', 'password', 'Web Site Password'); $form->addElement('password', 'confirm_password', 'Confirm Password'); $form->setConstants(array('password' => '', 'confirm_password' => '')); $form->addFormRule(array($this, 'validForm')); $this->_bindFormBirthDate($form); $this->_bindFormIndustryExperience($form); $form->addElement('text', 're_license_number', 'RE License'); $form->addRuleEx(array('re_license_number'), ' is in wrong format. Please use at least one number', 'regex', '/\d+/', 'server'); $form->addElement('advcheckbox', 'bill_to_home_address', 'Bill to Home Address', 'Bill to Home Address', array(), array('n', 'y')); $form->addElement('text', 'address', 'Home Address'); $this->_bindFormCityStateZip($form); $form->addElement('advcheckbox', 'use_admin_email', 'Use Admin Email?', 'Use Admin Email?', array(), array('n', 'y')); $form->addElement('text', 'admin_email', 'Admin Email'); $form->addRule('admin_email', 'Admin Email Address is in wrong format', 'email'); $form->addRule('admin_email', 'Admin Email Address is in wrong format', 'email', null, 'client'); //SUPPORTED AGENTS $form->addElement('header', 'header_supported_accounts', 'SUPPORTED AGENTS'); $sSupportedAccounts=&$form->addElement('advmultiselect', 'supported_accounts', 'Supported Agents', $this->DBObj->getAllSupportedAccount(), array('style'=>'width:200px;')); $sSupportedAccounts->_elementTemplate = ' {javascript}
Agents Not Supported{unselected} {add}{remove} Supported Agents{selected}
'; //status changes notes $statusChanges = $this->DBObj->getStatusChanges(); if (!empty($statusChanges)) { $form->addElement('header', 'header_status_history', 'ACCOUNT NOTES'); $form->addElement( 'static', 'status_history', null, $this->_getStatusChangesText(array_slice($statusChanges, 0, 10), count($statusChanges) > 10) ); } //ACCOUNT NOTES $form->addElement('header', 'header_account_notes', 'ADMIN NOTES'); $form->addElement('textarea', 'note', null, array('cols'=>5, 'rows'=>6, 'style'=>'width:99%')); // PROFILE INFORMATION $form->addElement('header', 'header_profile_information', 'PROFILE INFORMATION'); $form->addElement('img_db', 'img', 'Individual Image'); $list_2009_2020 = array(''=>'') + array_keys(array_fill(2009, 12, '')); $list_2009_2020 = array_combine($list_2009_2020, $list_2009_2020); $_date = $form->createElement( 'calendar', 'profile_update_date', 'Date: ', array('maxYear' => idate('Y'), 'addEmptyOption' => true) ); $_time = $form->createElement( 'date', 'profile_update_time', 'Time: ', array( 'format' => 'giA', 'optionIncrement' => array('i' => 1), 'addEmptyOption' => true ) ); $form->addGroup(array($_date, $_time), 'profile_update_group', 'Member Profiling Update', ' ', false); $bio = &$form->createElement('html_editor_basic', 'bio', 'Individual Biography'); $bio->width = 535; $form->addelement($bio); $this->formAddSectionBioCategories($form); $this->formAddSectionProfileCategories($form); $this->formAddSectionTypeOfBusiness($form); $form->addElement('header', 'header_volunteer', 'VOLUNTEER'); $form->addElement('static', 'volunteers', null, $this->_getVolunteerSection()); // BROADCAST EMAIL PREFERENCES $this->formAddSectionBroadcastEmailPreferences($form); return $form; } protected function _getVolunteerAttention() { return $this->Doc->getSmarty()->fetch('Member/Admin/volunteerAttention.tpl'); } protected function _getVolunteerSection() { $smarty = $this->Doc->getSmarty(); $smarty->assign('volunteerGroups', $this->DBObj->getVolunteerGroups()); $smarty->assign('volunteerPositions', $this->DBObj->getVolunteerPositions()); return $smarty->fetch('Member/Admin/volunteer.tpl'); } protected function _getStatusChangesText($statusChanges, $showViewAllLink = true) { $smarty = $this->Doc->getSmarty(); $smarty->assign('statusChanges', $statusChanges); $smarty->assign('memberId', $this->DBObj->id); $smarty->assign('showViewAllLink', $showViewAllLink); return $smarty->fetch('Member/Admin/statusChangesHistory.tpl'); } /** * @param $form Form * @return void */ protected function _bindFormBirthDate($form) { /** * @var HTML_QuickForm_calendar $birth_date */ $birth_date = &$form->createElement('calendar', 'birth_date', 'Birthdate'); $birth_date->_options['minYear'] = '1902'; $birth_date->_options['maxYear'] = date('Y'); $birth_date->_options['format'] = 'Md'; $birth_date->_options['addEmptyOption'] = true; $form->addElement($birth_date); } /** * @param $form Form * @return void */ protected function _bindFormIndustryExperience($form) { $list_1_50 = array_keys(array_fill(1, 50, '')); $list_1_50 = array_combine($list_1_50, $list_1_50); $form->addElement('select', 'industry_experience', 'Industry Experience (Years)', array(0 => '') + (array)$list_1_50); } /** * @param $form Form * @return void */ protected function _bindFormCityStateZip($form) { $gAddress = array(); $gAddress[] = $form->createElement('text', 'city', 'City ', array('size' => 25, 'class' => 'city')); $gAddress[] = $form->createElement('select', 'state', 'State ', array('' => '') + (array)$this->DBObj->getState4Select()); $gAddress[] = $form->createElement('text', 'zip', 'Zip Code ', array('size' => 25, 'class' => 'zip')); $form->addGroup($gAddress, 'gAddress', 'City, State, Zip Code', ' ', false); } function validForm($data) { $err = array(); $gAccountErrors = array(); if (!$this->DBObj->isUnique('email', $data['email'])){ $err['email'] = 'This email is already in use. Please use another one.'; } if ($data['password'] != $data['confirm_password']) { $err['password'] = 'Web Site Password and Confirm password entries do not match'; } $nrdsId = ctype_digit($data['nrds_id']) ? $data['nrds_id'] : 0; if ( $nrdsId && ( !$this->DBObj->isNRDSUniqueApplied($data['nrds_id'], $this->DBObj->id) /*|| !$this->DBObj->isUnique('nrds_id', $data['nrds_id'])*/ ) ){ $err['nrds_id'] = 'The NRDS ID must be unique'; } if(intval($data['id_company']) && !intval($data['id_location'])) { $err['location_special_element'] = 'Company Location is required'; } // if ($data['id_mncar_l_type'] == 4 && empty($data['edam_id'])) { // $gAccountErrors[] = 'EDAM ID is required'; // } // emails if (true !== ($_errors = $this->_validateFormSpecificEmails($data))) { $err = array_merge($err, $_errors); } if (empty($data['id_mncar_type']) && empty($data['id_mncar_l_type']) && empty($data['id_misc_type'])) { $gAccountErrors[] = 'Account type is required'; } else { if (!empty($data['id_mncar_type']) && empty($data['id_mncar_status'])) { $gAccountErrors[] = 'MNCAR Status is required'; } if (!empty($data['id_mncar_l_type']) && empty($data['id_mncar_l_status'])) { $gAccountErrors[] = 'MNCAR-L Status is required'; } if (!empty($data['id_misc_type']) && empty($data['id_misc_status'])) { $gAccountErrors[] = 'Misc Status is required'; } } if (!empty($gAccountErrors)) { $err['gAccount'] = implode('
', $gAccountErrors); } $gProfileUpdate = array(); foreach (array('date', 'time') as $name) { $field = 'profile_update_' . $name; if (array_key_exists($field, $data)) { $parts = array_filter($data[$field], 'strlen'); if (!empty($parts) && 3 != count($parts)) { $gProfileUpdate[] = ucfirst($name) . ' is in wrong format'; } } } if (!empty($gProfileUpdate)) { $err['profile_update_group'] = implode('; ', $gProfileUpdate); } if ('y' == $data['use_admin_email'] && empty($data['admin_email'])) { $err['admin_email'] = "Since you've checked \"Use Admin Email\" checkbox, please fill \"Admin Email\"" . " field in"; } if ( $nrdsId && !empty($data['id_company']) && !$this->DBObj->isFreeNrdsAtCompany($nrdsId, $data['id_company'])) { $err['nrds_id'] = self::MSG_ERR_NRDS_NOT_UNIQUE_AT_COMPANY; } return (empty($err))? true : $err; } protected function _validateFormSpecificEmails($data) { $err = array(); $regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/'; $data['specific_senders'] = preg_replace('/[\r\n]+/',' ', $data['specific_senders']); require_once('app/Settings/Settings.php'); $arrEmails = Settings::parseEmails($data['specific_senders'], false); foreach ($arrEmails as $k=>$v) { if (!strlen(trim($v, ',; '))) unset($arrEmails[$k]); } $arrEmails = array_unique($arrEmails); $errEmails = array(); $errEmailsNotExists = array(); foreach ($arrEmails as $k=>$email) { if (!preg_match($regex, $email)) { $errEmails[] = $email; } if (!$this->DBObj->isEmailExists($email)) { $errEmailsNotExists[] = $email; } } $_errorsSpecificSenders = array(); if (count($errEmails)) { $_errorsSpecificSenders[] = 'Wrong email address ('.implode(', ',$errEmails).')'; } if (count($errEmailsNotExists)) { $_errorsSpecificSenders[] = 'Not found members with email address (' . implode(', ', $errEmailsNotExists) . ')'; } if (!empty($_errorsSpecificSenders)) { $err['gSpecificSenders'] = implode('
', $_errorsSpecificSenders); } return (empty($err))? true : $err; } function _getNewForm() { $form = $this->_getBaseForm(); $form = $this->_bindFormFields($form); $this->setFormTitle($form, 'Add '.$this->DBObj->itemName); $form->addElement('hidden', 'action', 'insert') ; //$form->addRuleRequired(array('password', 'confirm_password')); return $form; } function _getEditForm() { $form = $this->_getBaseForm(); $form = $this->_bindFormFields($form); $this->setFormTitle($form, 'Edit '.$this->DBObj->itemName); $form->action = CURR_PAGE.'?action=update'; $form->addElement('hidden', 'action', 'update') ; $form->addElement('hidden', 'id', $this->DBObj->getData('id')) ; return $form; } function doNew() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); $form = $this->_getNewForm(); //$data['birth_date'] = (date('Y')-30).'-01-01'; /* $areaListByType = $this->DBObj->getDAreaByType(); foreach ($areaListByType as $id_type => $type) { foreach ($type['items'] as $id_area => $title) { $data['id_email_area'][$id_type][$id_area] = $id_area; } } $emailSpesialtyList = $this->DBObj->getDSpecialty4Select(); $emailSpesialtyList = array_keys($emailSpesialtyList); $data['id_email_specialty'] = array_combine($emailSpesialtyList, $emailSpesialtyList); $emailTypeList = $this->DBObj->getDSpecialty4Select(); $emailTypeList = array_keys($emailTypeList); $data['id_email_type'] = array_combine($emailTypeList, $emailTypeList); */ $form->setDefaults($data); $this->renderForm($form); } function doActivate() { $this->DBObj->activate(); Session::setData($this->_getPage4SaveMessage(), 'msg', $this->DBObj->itemName.' activated'); require_once 'class/HTTP.php'; skHTTP::redirect(Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=edit&id='.$this->DBObj->id); } function doEdit() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); if (!intval($data['id'])) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Invalid Member ID')); return; } $this->_initData4Form($data); $form = $this->_getEditForm(); $id = $form->createElement('static', 'individual_id', 'Individual ID', $data['id']); $form->insertElementAfter($id, 'header_mncar_membership_information'); $changed = &$form->createElement('text', 'formatted_changed', 'Last Updated'); $changed->freeze(); $form->insertElementBefore($changed, 'gName'); $form->setDefaults($data); if (($data['email_verified']=='n' || $data['info_verified']=='n')) { $addLink = array( 'tpl' => 'center_link.tpl', 'description' => 'This member is not active yet -> ', 'link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=activate&id='.$this->DBObj->id, 'title' => 'Activate this '.$this->DBObj->itemName, ); $this->Doc->addContent($addLink); } $this->renderForm($form); } protected function _initData4Form(&$data) { $data['birth_date'] = str_replace('1900', '1902', $data['birth_date']); if (empty($data['birth_date'])) { unset($data['birth_date']); } return $this; } function doInsert() { $form = $this->_getNewForm(); if ($form->validate()) { $this->DBObj->initFromForm($form ); $this->DBObj->insert(); $this->initTabRedirect(); if (empty($this->DBObj->_data['redirect_url'])) { Session::setData(CURR_PAGE_FULL, 'msg', $this->DBObj->itemName.' added'); } $this->updateLocationPayMember(); $this->doBack(); }else { $this->renderForm($form); } return true; } function doUpdate() { $form = $this->_getEditForm(); if ($form->validate()){ $this->DBObj->initFromForm($form); $this->DBObj->update(); $this->initTabRedirect(); if (empty($this->DBObj->_data['redirect_url'])) { Session::setData(CURR_PAGE_FULL, 'msg', $this->DBObj->itemName.' updated'); } $this->updateLocationPayMember(); $this->doBack(); }else { $this->renderForm($form); } return true; } function updateLocationPayMember() { $data = $this->DBObj->getData(); $this->DBObj->initFromDB(); $oldData = $this->DBObj->getData(); $data = array_merge($oldData, $data); if ($data['billing_approve_pay_exchange'] == 'y' && $this->DBObj->id != $data['location_id_pay_member'] && $data['id_location']) { $this->DBObj->tableLocation->update( array('id_pay_member' => $this->DBObj->id), 'id=' . intval($data['id_location']) ); $this->_sendMailWantPayRequestApproved($data); } } function renderForm(&$form) { $linkItem = array( 'tpl' => 'center_link.tpl', 'link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=cancel', 'title' => '<< Back to list' ); $this->Doc->addContent($linkItem); $form->return_form_arr = true; $form->setTpl(SiteMap::getPath('Member/tpl/form.tpl')); $item = $form->exec(); if ($_REQUEST['action'] != 'new') { $item['menu'] = array( CURR_PAGE.'/history/'.$this->DBObj->id =>'Individual Login History', CURR_PAGE.'/event_history/'.$this->DBObj->id =>'Events / Attendance', CURR_PAGE.'/event_history/'.$this->DBObj->id.'?action=new' =>'Add Event', //CURR_PAGE.'/invoice/'.$this->DBObj->id =>'Invoice History', CURR_PAGE.'/credit_history/'.$this->DBObj->id =>'CE Credit History', ); } $this->addTabHeader(); $this->Doc->addContent($item); $this->Doc->addItemProp('JSs', 'js/format_phone.js'); $this->addTabFooter(); } function doGetCompanyAjax() { $data = array(); $data['list'] = $this->DBObj->getCompany(); $this->displayJSON($data); } function doGetLocationAjax() { $data = array(); $opt = array(); $opt['id_company'] = intval($_REQUEST['id_company']); $data['list'] = $this->DBObj->getLocation($opt); $this->displayJSON($data); } function getTabs() { $tabs = array(); $tabs[0] = array('alias'=>CURR_PAGE.'?action=edit&id='.$this->DBObj->id, 'title'=>'Individual Information', 'current'=>1); $tabs[1] = array('alias'=>CURR_PAGE.'?action=edit_location&id='.$this->DBObj->id, 'title'=>'Location Information'); $tabs[2] = array('alias'=>CURR_PAGE.'?action=edit_company&id='.$this->DBObj->id, 'title'=>'Company Information'); return $tabs; } function addTabHeader() { if (!$this->DBObj->id) { return; } $item = array(); $item['tpl'] = 'Member/tab_header.tpl'; $item['tabs'] = $this->getTabs(); $this->Doc->addContent($item); } function addTabFooter() { if (!$this->DBObj->id) { return; } $item = array(); $item['tpl'] = 'Member/tab_footer.tpl'; $this->Doc->addContent($item); } function initTabRedirect() { if (!empty($this->DBObj->_data['redirect_url'])) { $this->setBackUrl($this->DBObj->_data['redirect_url']); } else { $this->setBackUrl(BASE_URL.'/'.CURR_PAGE_FULL.'?action=edit&id='.$this->DBObj->id); } } function doEditLocation() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); require_once('class/HTTP.php'); if (intval($data['id_location'])) { skHTTP::redirect(BASE_URL.'/admin/location?action=edit&id='.intval($data['id_location']).'&id_individual='.$this->DBObj->id); } skHTTP::redirect(BASE_URL.'/admin/location?action=new&id_individual='.$this->DBObj->id); } function doEditCompany() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); require_once('class/HTTP.php'); if (intval($data['id_company'])) { skHTTP::redirect(BASE_URL.'/admin/company?action=edit&id='.intval($data['id_company']).'&id_individual='.$this->DBObj->id); } skHTTP::redirect(BASE_URL.'/admin/location?action=new&id_individual='.$this->DBObj->id); } function getFilterForm() { require_once 'class/Form/Form.class.php'; $form = new Form($this->Doc, 'form_search_member', 'get', '', '_self', array('class'=>'form form_search_member')); $form->tpl = SiteMap::getPath('Member/tpl/filter.tpl'); $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); $form->addElement('select', 'search_type', 'Type of Search', array('individual'=>'Individual', 'company'=>'Companies', 'location'=>'Locations')); $form->addElement('text', 'query', 'Search For', array('style'=>'width:400px;')); $form->addElement('select', 'id_company', 'Company', array('all'=>'All Companies')); $form->addElement('select', 'id_location', 'Location', array('all'=>'All Locations')); $form->addElement('select', 'id_mncar_type', 'MNCAR Member', $this->DBObj->getDMncarMemberType4Select(), array('multiple' => 'multiple', 'size' => 7)); $form->addElement('select', 'id_mncar_status', 'MNCAR Status', array('0' => 'No Status') + (array)$this->DBObj->getDMemberStatus4Select('mncar'), array('multiple' => 'multiple', 'size' => 6)); $form->addElement('select', 'id_mncar_l_type', 'MNCAR-L Member', $this->DBObj->getDMncarLMemberType4Select(), array('multiple' => 'multiple', 'size' => 4)); $form->addElement('select', 'id_mncar_l_status', 'MNCAR-L Status', array('0' => 'No Status') + (array)$this->DBObj->getDMemberStatus4Select('mncar_l'), array('multiple' => 'multiple', 'size' => 4)); $form->addElement('select', 'id_misc_type', 'Misc.', $this->DBObj->getDMiscMemberType4Select(), array('multiple' => 'multiple', 'size' => 3)); $form->addElement('select', 'id_misc_status', 'Misc. Status', array('0' => 'No Status') + (array)$this->DBObj->getDMemberStatus4Select('misc'), array('multiple' => 'multiple', 'size' => 3)); $form->addElement('select', 'id_volunteer', 'Volunteers', $this->DBObj->getVolunteer4Select(), array('multiple' => 'multiple', 'size' => 5)); // $form->addElement('select', 'id_specialty', 'Real Estate Specialty', $this->DBObj->getDSpecialty4Select('sorter', "profile = 'y'"), array('multiple'=>'multiple', 'size'=>5)); // $form->addElement('select', 'id_area', 'Market Area of Specialty', $this->DBObj->getDArea4Select('sorter', "profile = 'y'"), array('multiple'=>'multiple', 'size'=>5)); $form->addElement('select', 'id_market', 'MNCAR Market', $this->DBObj->getDMarket4Select('sorter'), array('multiple'=>'multiple', 'size'=>3)); $form->addElement('select', 'send_focus_newsletter', 'Receive Focus', $this->_yesNoFilterOptions); $form->addElement('select', 'is_support_account', 'Support Account', $this->_yesNoFilterOptions); $form->addElement('select', 'allow_mcpe_access', 'MCPE Access', $this->_yesNoFilterOptions); $form->addElement('select', 'raw_datafeeds', 'Raw Data Feeds', $this->_yesNoFilterOptions); // for location only $form->addElement('select', 'data_feeds_office', 'Data Feeds - Office', $this->_yesNoFilterOptions); // for location only $form->addElement('select', 'data_feeds_individual', 'Data Feeds - Individual', $this->_yesNoFilterOptions); // for location only $form->addElement('select', 'templates', 'Templates', $this->_yesNoFilterOptions); // for location only $form->addElement('select', 'id_mcpe_access_type', 'MCPE Access Type', (array)$this->DBObj->getDMCPEAccessType4Select(), array('multiple'=>'multiple', 'size'=>3)); // $form->addElement('select', 'record_type', 'Company or Location?', array('all'=>'Either', 'company'=>'Companies', 'location'=>'Locations')); $form->addElement('select', 'id_company_type', 'Company Type', $this->DBObj->getDCompanyType4Select() + array(0=>'Other'), array('multiple'=>'multiple', 'size'=>5)); $form->addElement('select', 'id_location_type', 'Location Type', $this->DBObj->getDLocationType4Select(), array('multiple'=>'multiple', 'size'=>3)); $form->addElement('submit', 'submit', 'Search', array( 'class' => 'btn') ); $form->addElement('button', 'cancel', 'Cancel', array( 'class' => 'btn' , 'onclick' => "document.location.href='".Constant::get('BASE_URL').'/'.CURR_PAGE."'" )); return $form; } function addLink() { $item = array( 'tpl'=>'Member/toolbar.tpl', 'list'=>array( array('title'=>'Basic Search', 'current'=>1), array('alias'=>'admin/company?action=new', 'title'=>'Add New Company'), array('alias'=>'admin/location?action=new', 'title'=>'Add New Location'), array('alias'=>'admin/member?action=new', 'title'=>'Add New Individual'), ) ); $this->Doc->addContent($item); } function getFilterForm4List($request = null) { if (null == $request) { $request = $_REQUEST; } $filterForm = $this->getFilterForm(); if (isset($request['id_company']) && intval($request['id_company'])) { $companyData = $this->DBObj->getCompanyById(intval($request['id_company'])); $filterForm->getElement('id_company')->addOption($companyData['name'], intval($request['id_company'])); } else { $filterForm->removeElement('id_company'); } if (isset($request['id_location']) && intval($request['id_location'])) { $locationData = $this->DBObj->getLocationById(intval($request['id_location'])); $filterForm->getElement('id_location')->addOption($locationData['title'], intval($request['id_location'])); } else { $filterForm->removeElement('id_location'); } return $filterForm; } function getSavedSearchForm() { require_once 'class/Form/Form.class.php'; $form = new Form($this->Doc, 'form_saved_search', 'get', '', '_self', array('class' => 'form form_saved_search')); $form->tpl = SiteMap::getPath('Member/tpl/savedSearchForm.tpl'); $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); require_once('app/MemberSearch/MemberSearch.php'); $memberSearch = MemberSearch::getInstance(); $savedSearch = $memberSearch->getSavedSearch4Select($this->Doc->UserAuth->getData('id')); if (empty($savedSearch)) { $savedSearch = array('' => 'No Saved Search'); } else { $savedSearch = array('' => 'Select Saved Search') + $savedSearch; } $form->addElement('select', 'saved_search_id', 'Saved Searches', $savedSearch); $form->addElement( 'submit', 'btnSavedSearchSelected', 'Search', array('onclick' => 'return false;') ); $form->addElement( 'submit', 'btnSavedSearchSave', 'Save Search', array('onclick' => 'return false;') ); $form->addElement( 'submit', 'btnSavedSearchDelete', 'Delete Selected Search', array('onclick' => 'return false;') ); $this->Doc->addItemProp('JSs', 'js/jquery.deserialize.js'); $this->Doc->addItemProp('JSs', 'js/app/adminMemberSearch.js'); $this->Doc->addInitFunction('App_AdminMemberSearch_Form.initialize'); return $form; } function doList() { $this->addLink(); $searchForm = $this->getSavedSearchForm(); $searchForm->return_form_arr = true; $itemSearch = $searchForm->exec(); $itemSearch['show_filter_options'] = !isset($_REQUEST['submit']); $this->Doc->addContent($itemSearch); $filterForm = $this->getFilterForm4List(); $this->DBObj->filter = $filterForm->exportValues(); $filterForm->return_form_arr = true; $item = $filterForm->exec(); $item['show_filter_options'] = !isset($_REQUEST['submit']); $this->DBObj->setFilter($filterForm->getElementValue('query')); if (!$this->DBObj->_filterSql() && isset($_REQUEST['submit'])) { $this->Doc->addContent(array('tpl'=>'text.tpl','text'=>'
Please choose at least one another search option
')); } $this->Doc->addContent($item); $this->_saveBackUrl(); require_once('class/DB/List/List.php'); $DB_List = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $DB_List->urlVarNames = array_keys($this->DBObj->filter); $DB_List->urlVarNames[] = 'ipp'; $DB_List->def_order_by='last_name'; $this->_doListBind($DB_List); $this->setIpp($DB_List); if ($this->DBObj->_filterSql()) $DB_List->exec(); return true; } function doAssignNrdsIdAjax() { $res = $this->DBObj->assignNrdsId($_REQUEST['record_type']); $this->displayJSON($res); } function doAssignManualyNrdsIdAjax() { $res = $this->DBObj->assignManualyNrdsId($_REQUEST['record_type'], $_REQUEST['nrds_id']); $this->displayJSON($res); } function doClearNrdsIdAjax() { if ($this->DBObj->id) { $res = $this->DBObj->clearNrdsId(); } else { $res = array('id'=>''); } $this->displayJSON($res); } function arrayPushArray(&$array1, $array2) { foreach($array2 as $k=>$v) { array_push($array1, $v); } } function doExportSearch() { $filterForm = $this->getFilterForm4List(); $this->DBObj->filter = $filterForm->exportValues(); $this->DBObj->setFilter($filterForm->getElementValue('query')); require_once('class/DB/List/List.php'); $DB_List = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $this->_doListBind($DB_List); $opt = array(); $opt['order_by'] = $DB_List->getOrderBy(); $res = $this->DBObj->_getRes4Grid($this->DBObj->_getWhat4Grid($opt), $opt); if (PEAR::isError($res)) { if (DEBUG) { vdie('MemberGrid->doExportSearch error', $res->getUserInfo(), null, debug_backtrace()); } else { sendDeveloperEmail($res->getUserInfo()); return; } } $this->outSearchResultsCSV($res); } function outSearchResultsCSV(&$res) { $fields = array( 'nrds_id' => 'NRDS ID', 'nrds_id_date_joined' => 'Date Joined', 'id' => 'Individual ID', 'changed' => 'Last Updated', 'company_id' => 'Company ID', 'company_name' => 'Company', 'location_id' => 'Location ID', 'location_nrds_id' => 'Location NRDS ID', 'location_name_original' => 'Location Name', 'location_physical_address' => 'Location Address', 'location_physical_city' => 'Location City', 'location_physical_state' => 'Location State', 'location_physical_zip' => 'Location Zip', 'location_phone' => 'Location Phone', 'mncar_type' => 'MNCAR Member', 'mncar_status' => 'MNCAR Status', 'mncar_l_type' => 'MNCAR-L Member', 'mncar_l_status' => 'MNCAR-L Status', 'misc_type' => 'Misc. Member', 'misc_status' => 'Misc. Status', 'send_focus_newsletter' => 'Receive Focus', 'is_support_account' => 'Support Account', //'edam_id' => 'EDAM ID', 'allow_mcpe_access' => 'Allow MCPE Access', 'mcpe_access_type' => 'MCPE Access Type', 'billing_send_paper_copy' => 'Send a paper copy of invoice?', 'billing_omit_from_invoicing' => 'Omitted from Billing', 'first_name' => 'First Name', 'middle_initial' => 'Middle Inidial', 'last_name' => 'Last Name', 'generation' => 'Generation', 'designations' => 'Designations', 'primary_phone' => 'Primary Phone #', 'secondary_phone' => 'Secondary Phone #', 'fax' => 'Direct Fax Number', 'website' => 'Website', 'email' => 'Email Address (Web Site Login)', 'market' => 'MNCAR Market', 'password' => 'Web Site Password', 'birth_date' => 'Birthdate', 'industry_experience' => 'Industry Experience (Years)', 're_license_number' => 'RE License', 'address' => 'Home Address', 'city' => 'Home City', 'state' => 'Home State', 'zip' => 'Home Zip', 'use_admin_email' => 'Use Admin Email?', 'admin_email' => 'Admin Email', 'note' => 'ACCOUNT NOTES', 'img' => 'Individual Image', 'profile_update' => 'Member Profile Update', 'bio' => 'Individual Biography', ); $bioArea = $this->DBObj->getDArea4Select('sorter', "info = 'y'"); foreach ($bioArea as $id => $title) { $fields['id_area_info_'.$id] = 'Bio Area - '.$title; } $bioSpecialty = $this->DBObj->getDSpecialty4Select('sorter', "info = 'y'"); foreach ($bioSpecialty as $id => $title) { $fields['id_specialty_info_'.$id] = 'Bio Specialty - '.$title; } $profileArea = $this->DBObj->getDArea4Select('sorter', "profile = 'y'"); foreach ($profileArea as $id => $title) { $fields['id_area_profile_'.$id] = 'Profile Area - '.$title; } $profileSpecialty = $this->DBObj->getDSpecialty4Select('sorter', "profile = 'y'"); foreach ($profileSpecialty as $id => $title) { $fields['id_specialty_profile_'.$id] = 'Profile Specialty - '.$title; } $lineOfWork = $this->DBObj->getDLineOfWork4Select(); foreach ($lineOfWork as $id => $title) { $fields['id_line_of_work_'.$id] = 'Line Of Work - '.$title; } $fields['other_line_of_work'] = 'Line Of Work - Other'; $typeOfBusiness = $this->DBObj->getDTypeOfBusiness4Select(); foreach ($typeOfBusiness as $id => $title) { $fields['type_of_business_id_'.$id] = 'Type Of Business - '.$title; } $fields['other_type_of_business'] = 'Type Of Business - Other'; $volunteer = $this->DBObj->getVolunteer4Select(); foreach ($volunteer as $id => $title) { $fields['id_volunteer_'.$id] = 'Volunteer - '.$title; } $emailType = $this->DBObj->getDEmailType4Select(); foreach ($emailType as $id => $title) { $fields['id_email_type_'.$id] = 'Email Type - '.$title; } $emailSpecialty = $this->DBObj->getDSpecialty4Select('sorter', "broadcast = 'y'"); foreach ($emailSpecialty as $id => $title) { $fields['id_email_specialty_'.$id] = 'Email Specialty - '.$title; } $areaListByType = $this->DBObj->getDAreaByType(); foreach ($areaListByType as $id_type => $type) { foreach ($type['items'] as $id_area => $title) { $fields['id_email_area_'.$id_type.'_'.$id_area] = $type['title'].' - '.$title; } } $fields['specific_senders'] = 'Specific senders to avoid'; require_once('Structures/DataGrid/Renderer/CSV.php'); $csv = new Structures_DataGrid_Renderer_CSV(); $csv->setStreaming(true); $row = $res->fetchRow(); if (!$row) { Session::setData($this->_getPage4SaveMessage(), 'msg', 'No data for export'); $this->doBack(); return; } header ('Last-Modified: ' . gmdate('D,d M YH:i:s') . ' GMT'); header ('Cache-Control: no-cache, must-revalidate'); header ('Pragma: no-cache'); header ("Content-type: text/comma-separated-values"); header('Content-disposition: attachment; filename=search_results.csv'); echo $csv->_recordToCsv(array_values($fields)); echo $csv->_recordToCsv($this->prepareRow($row, $fields)); while (($row = $res->fetchRow())) { echo $csv->_recordToCsv($this->prepareRow($row, $fields)); } exit; } function prepareRow($row, $fields) { $ids_area_info = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2AreaInfo', $this->DBObj->db->tblDArea, 'id_area_info', $row['id']); $ids_specialty_info = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2SpecialtyInfo', $this->DBObj->db->tblDSpecialty, 'id_specialty_info', $row['id']); $ids_area_profile = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2Area', $this->DBObj->db->tblDArea, 'id_area', $row['id']); $ids_specialty_profile = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2Specialty', $this->DBObj->db->tblDSpecialty, 'id_specialty', $row['id']); $ids_line_of_work = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2LineOfWork', $this->DBObj->db->tblDLineOfWork, 'id_line_of_work', $row['id']); $ids_volunteer = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2Volunteer', $this->DBObj->db->tblVolunteer, 'id_volunteer', $row['id']); $ids_email_type = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2EmailType', $this->DBObj->db->tblDEmailType, 'id_email_type', $row['id']); $ids_email_specialty = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2EmailSpecialty', $this->DBObj->db->tblDSpecialty, 'id_specialty', $row['id']); $type_of_business_ids = $this->DBObj->getIdsFromDB($this->DBObj->tableNameDB.'2TypeOfBusiness', $this->DBObj->db->tblDTypeOfBusiness, 'type_of_business_id', $row['id'], 'member_id'); $ids_email_area = $this->DBObj->getEmailAreaIdsFromDB($this->DBObj->tableNameDB.'2EmailArea', $row['id']); $out = array(); foreach ($fields as $k=>$v) { if ( strncmp($k, 'id_area_info_', 13) == 0 || strncmp($k, 'id_specialty_info_', 18) == 0 || strncmp($k, 'id_area_profile_', 16) == 0 || strncmp($k, 'id_specialty_profile_', 21) == 0 || strncmp($k, 'id_line_of_work_', 16) == 0 || strncmp($k, 'id_volunteer_', 13) == 0 || strncmp($k, 'id_email_', 9) == 0 || strncmp($k, 'type_of_business_id_', 20) == 0 ) { $out[$k] = 'No'; } else { $out[$k] = @$row[$k]; } } $out['specific_senders'] = str_replace("\r\n", " ", $out['specific_senders']); $out['note'] = str_replace("\r\n", " ", $out['note']); $out['bio'] = html_entity_decode(strip_tags(str_replace(array("
", "\r\n"), " ", $out['bio']))); $out['send_focus_newsletter'] = ($out['send_focus_newsletter'] == 'y')?'Yes':'No'; $out['is_support_account'] = ($out['is_support_account'] == 'y')?'Yes':'No'; $out['allow_mcpe_access'] = ($out['allow_mcpe_access'] == 'y')?'Yes':'No'; $out['billing_send_paper_copy'] = ($out['billing_send_paper_copy'] == 'y') ? 'Yes' : 'No'; $out['billing_omit_from_invoicing'] = ($out['billing_omit_from_invoicing'] == 'y') ? 'Yes' : 'No'; $out['birth_date'] = str_replace('-','/',substr($out['birth_date'],5)); $this->prepareRowMarkYesByIds($out, 'id_area_info_', $ids_area_info); $this->prepareRowMarkYesByIds($out, 'id_specialty_info_', $ids_specialty_info); $this->prepareRowMarkYesByIds($out, 'id_area_profile_', $ids_area_profile); $this->prepareRowMarkYesByIds($out, 'id_specialty_profile_', $ids_specialty_profile); $this->prepareRowMarkYesByIds($out, 'id_line_of_work_', $ids_line_of_work); $this->prepareRowMarkYesByIds($out, 'id_volunteer_', $ids_volunteer); $this->prepareRowMarkYesByIds($out, 'id_email_type_', $ids_email_type); $this->prepareRowMarkYesByIds($out, 'id_email_specialty_', $ids_email_specialty); $this->prepareRowMarkYesByIds($out, 'type_of_business_id_', $type_of_business_ids); foreach ($ids_email_area as $id_type => $ids) { $this->prepareRowMarkYesByIds($out, 'id_email_area_'.$id_type.'_', $ids); } return $out; } function prepareRowMarkYesByIds(&$out, $prefix, $list) { if (is_array($list) && !empty($list)) { foreach($list as $id) { $out[$prefix.$id] = 'Yes'; } } } function doExportPurchasable() { $res = $this->DBObj->getRes4ExportPurchasable(); $fields = array( 'id' => 'Agent ID', 'mncar_type' => 'MNCAR Member', 'mncar_status' => 'MNCAR Status', 'mncar_l_type' => 'MNCAR-L Member', 'mncar_l_status' => 'MNCAR-L Status', 'misc_type' => 'Misc. Member', 'misc_status' => 'Misc. Status', 'first_name' => 'First Name', 'middle_initial' => 'Middle Initial', 'last_name' => 'Last Name', 'primary_phone' => 'Primary Phone #', 'secondary_phone' => 'Secondary Phone #', 'email' => 'Email', 'company_name' => 'Company', 'location_name_original' => 'Location Name', 'location_physical_address' => 'Location Address', 'location_physical_city' => 'Location City', 'location_physical_state' => 'Location State', 'location_physical_zip' => 'Location Zip', 'location_phone' => 'Location Phone', ); $emailType = $this->DBObj->getDEmailType4Select(); foreach ($emailType as $id => $title) { $fields['id_email_type_'.$id] = 'Email Type - '.$title; } $options = $this->DBObj->getDEmailGroupType4Select(); foreach ($options as $id => $title) { $fields['id_email_group_type_' . $id] = 'Email Group Type - ' . $title; } require_once 'Structures/DataGrid/Renderer/CSV.php'; $csv = new Structures_DataGrid_Renderer_CSV(); $csv->setStreaming(true); $row = $res->fetchRow(); if (!$row) { Session::setData($this->_getPage4SaveMessage(), 'msg', 'No data for export'); $this->doBack(); return; } header ("Content-type: text/comma-separated-values"); header('Content-disposition: attachment; filename=Purchasable_Member_List.csv'); echo $csv->_recordToCsv(array_values($fields)); echo $csv->_recordToCsv($this->prepareRow4ExportPurchasable($row, $fields)); while (($row = $res->fetchRow())) { echo $csv->_recordToCsv($this->prepareRow4ExportPurchasable($row, $fields)); } exit; } function prepareRow4ExportPurchasable($row, $fields) { $ids_email_type = $this->DBObj->getIdsFromDB( $this->DBObj->tableNameDB . '2EmailType', $this->DBObj->db->tblDEmailType, 'id_email_type', $row['id'] ); $ids_email_group_type = $this->DBObj->getIdsFromDB( $this->DBObj->tableNameDB . '2EmailGroup', $this->DBObj->db->tblDEmailGroupType, 'group_id', $row['id'], 'member_id' ); $out = array(); foreach ($fields as $k=>$v) { if (strncmp($k, 'id_email_group_type_', 20) == 0 || strncmp($k, 'id_email_type_', 14) == 0) { $out[$k] = 'No'; } else { $out[$k] = @$row[$k]; } } if (is_array($ids_email_type) && !empty($ids_email_type)) { foreach($ids_email_type as $id_email_type) { $out['id_email_type_' . $id_email_type] = 'Yes'; } } if (is_array($ids_email_group_type) && !empty($ids_email_group_type)) { foreach($ids_email_group_type as $id_group) { $out['id_email_group_type_' . $id_group] = 'Yes'; } } return $out; } protected function _sendMail($options) { extract($options); $to = array_unique($to); require_once('lib/htmlMimeMail/htmlMimeMail.php'); $mail = new htmlMimeMail(); $this->Doc->assign('item', $item); Constant::set('DEBUG', false); $mail->setSubject($subject); $mail->setFrom($from); $mail->setHtml($this->Doc->fetch($template)); foreach ($to as $email) { $mail->send(array($email)); } } protected function _sendMailWantPayRequestApproved($member) { $subject = 'Approved Request to Pay Exchange Dues Online'; $admin = $this->Doc->UserAuth->getData(); require_once('app/Settings/Settings.php'); $from = Settings::get('admin_email_from'); $to = array($member['email']); $this->_sendMail(array( 'subject' => $subject, 'from' => $from, 'to' => $to, 'item' => array('admin' => $admin, 'member' => $member), 'template' => SiteMap::getPath('Member/tpl/Profile/email-want-pay-approved.tpl'), )); } protected function doGetStatusAjax() { $result = array( 'options' => $this->DBObj->getDMemberStatus4Select(Qs_Request::getPostValue('type'), Qs_Request::getPostValue('id_type')) ); $this->displayJSON($result); } }