/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Find Totals for Events'); /** * Define the search form fields here */ $form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments')); $form->addElement('checkbox', 'show_payees', ts('Show payees')); $event_type = CRM_Core_OptionGroup::values('event_type', FALSE); foreach ($event_type as $eventId => $eventName) { $form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName); } $events = CRM_Event_BAO_Event::getEvents(1); $form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events); $form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id')); }
/** * build the form elements for a phone object * * @param CRM_Core_Form $form reference to the form object * @param int $addressBlockCount block number to build * @param boolean $blockEdit is it block edit * * @return void * @access public * @static */ static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE) { // passing this via the session is AWFUL. we need to fix this if (!$addressBlockCount) { $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1; } else { $blockId = $addressBlockCount; } $form->applyFilter('__ALL__', 'trim'); //phone type select $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')); //main phone number with crm_phone class $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve'))); // phone extension $form->addElement('text', "phone[{$blockId}][phone_ext]", ts('Extension'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone_ext')); if (isset($form->_contactType) || $blockEdit) { //Block type select $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')); //is_Primary radio $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js); } // TODO: set this up as a group, we need a valid phone_type_id if we have a phone number // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' ); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { CRM_Utils_System::setTitle(ts('Custom Search Group Contact')); $aElements = array(); #get all groups $aGroups = CRM_Core_PseudoConstant::group(); $form->addElement('advmultiselect', 'group_contact', ts('Group(s)') . ' ', $aGroups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); #assign to element $aElements[] = 'group_contact'; #date range $form->addDate('start_date', 'From :', FALSE, array('formatType' => 'searchDate')); $form->addDate('end_date', 'To :', FALSE, array('formatType' => 'searchDate')); $aElements[] = 'start_date'; $aElements[] = 'end_date'; #to get all status /*$oGroupContact = new CRM_Contact_DAO_GroupContact; $aGroupFields = $oGroupContact->fields(); $sStatus = $aGroupFields['status']['enumValues']; $aStatus = explode(', ', $sStatus);*/ $aStatus = CRM_Core_SelectValues::groupContactStatus(); foreach ($aStatus as $status) { //$form->addElement('checkbox', "status[{$status}]",$status, '', array('class' => 'group_status')); $form->addElement('checkbox', $status, ts("{$status}"), '', array('class' => 'group_status')); //$form->addElement('checkbox', "status[{$status}]" , $status, '', array('class' => 'group_status')); $aElements[] = $status; } /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $this->_elements = $aElements; $form->assign('elements', $aElements); }
/** * build the form elements for an email object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form, $addressBlockCount = null) { // passing this via the session is AWFUL. we need to fix this if (!$addressBlockCount) { $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1; } else { $blockId = $addressBlockCount; } $form->applyFilter('__ALL__', 'trim'); //Email box $form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType)) { //Block type $form->addElement('select', "email[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); //On-hold checkbox $form->addElement('advcheckbox', "email[{$blockId}][on_hold]", null); //Bulkmail checkbox $js = array('id' => "Email_" . $blockId . "_IsBulkmail", 'onClick' => 'singleSelect( this.id );'); $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", null, '', $js); //is_Primary radio $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40)); $form->addWysiwyg("email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40)); } } }
/** * This function provides the HTML form elements that are specific * to the Individual Contact Type * * @param CRM_Core_Form $form form object * @param int $inlineEditMode ( 1 for contact summary * top bar form and 2 for display name edit ) * * @access public * @return void */ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { $form->applyFilter('__ALL__', 'trim'); if (!$inlineEditMode || $inlineEditMode == 1) { $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2'); //prefix $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); if (isset($nameFields['Prefix']) && !empty($prefix)) { $form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' ')); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); if (isset($nameFields['Formal Title'])) { $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']); } // first_name if (isset($nameFields['First Name'])) { $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); } //middle_name if (isset($nameFields['Middle Name'])) { $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); } // last_name if (isset($nameFields['Last Name'])) { $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); } // suffix $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); if (isset($nameFields['Suffix']) && $suffix) { $form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' ')); } } if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name')); // job title // override the size for UI to look better $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); //Current Employer Element $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE); $form->assign('employerDataURL', $employerDataURL); $form->addElement('text', 'current_employer', ts('Current Employer'), ''); $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id')); $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); } if (!$inlineEditMode) { $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE); if ($checkSimilar == null) { $checkSimilar = 0; } $form->assign('checkSimilar', $checkSimilar); //External Identifier Element $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier')); $config = CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } }
/** * This function provides the HTML form elements that are specific * to the Individual Contact Type * * @param CRM_Core_Form $form * Form object. * @param int $inlineEditMode * ( 1 for contact summary. * top bar form and 2 for display name edit ) * * @return void */ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { $form->applyFilter('__ALL__', 'trim'); if (!$inlineEditMode || $inlineEditMode == 1) { $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2'); //prefix $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); if (isset($nameFields['Prefix']) && !empty($prefix)) { $form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix'))); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); if (isset($nameFields['Formal Title'])) { $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']); } // first_name if (isset($nameFields['First Name'])) { $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); } //middle_name if (isset($nameFields['Middle Name'])) { $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); } // last_name if (isset($nameFields['Last Name'])) { $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); } // suffix $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); if (isset($nameFields['Suffix']) && $suffix) { $form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix'))); } } if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name')); // job title // override the size for UI to look better $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"'); //Current Employer Element $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE); $form->addEntityRef('employer_id', ts('Current Employer'), $props); $attributes['source']['class'] = 'big'; $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); } if (!$inlineEditMode) { $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE); if ($checkSimilar == NULL) { $checkSimilar = 0; } $form->assign('checkSimilar', $checkSimilar); //External Identifier Element $form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier')); $config = CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } }
/** * build the form elements for an Website object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form) { $blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1; $form->applyFilter('__ALL__', 'trim'); //Website type select $form->addElement('select', "website[{$blockId}][website_type_id]", '', CRM_Core_PseudoConstant::websiteType()); //Website box $form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false"))); $form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url'); }
/** * Build form. * * @param CRM_Core_Form $form */ public static function buildForm(&$form) { // We should not build form elements in dashlet mode. if ($form->_section) { return; } // Check role based permission. $instanceID = $form->getVar('_id'); if ($instanceID && !CRM_Report_Utils_Report::isInstanceGroupRoleAllowed($instanceID)) { $url = CRM_Utils_System::url('civicrm/report/list', 'reset=1'); CRM_Core_Error::statusBounce(ts('You do not have permission to access this report.'), $url); } $attributes = CRM_Core_DAO::getAttribute('CRM_Report_DAO_ReportInstance'); $form->add('text', 'title', ts('Report Title'), $attributes['title']); $form->add('text', 'description', ts('Report Description'), $attributes['description']); $form->add('text', 'email_subject', ts('Subject'), $attributes['email_subject']); $form->add('text', 'email_to', ts('To'), $attributes['email_to']); $form->add('text', 'email_cc', ts('CC'), $attributes['email_subject']); $form->add('text', 'row_count', ts('Limit Dashboard Results'), array('maxlength' => 64, 'size' => 5)); $form->add('textarea', 'report_header', ts('Report Header'), $attributes['header']); $form->add('textarea', 'report_footer', ts('Report Footer'), $attributes['footer']); $form->addElement('checkbox', 'is_navigation', ts('Include Report in Navigation Menu?'), NULL, array('onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);")); $form->addElement('checkbox', 'addToDashboard', ts('Available for Dashboard?'), NULL, array('onclick' => "return showHideByValue('addToDashboard','','limit_result','table-row','radio',false);")); $form->addElement('checkbox', 'is_reserved', ts('Reserved Report?')); if (!CRM_Core_Permission::check('administer reserved reports')) { $form->freeze('is_reserved'); } $config = CRM_Core_Config::singleton(); if ($config->userFramework != 'Joomla' || $config->userFramework != 'WordPress') { $form->addElement('select', 'permission', ts('Permission'), array('0' => ts('Everyone (includes anonymous)')) + CRM_Core_Permission::basicPermissions()); // prepare user_roles to save as names not as ids if (function_exists('user_roles')) { $user_roles_array = user_roles(); foreach ($user_roles_array as $key => $value) { $user_roles[$value] = $value; } $grouprole =& $form->addElement('advmultiselect', 'grouprole', ts('ACL Group/Role'), $user_roles, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $grouprole->setButtonAttributes('add', array('value' => ts('Add >>'))); $grouprole->setButtonAttributes('remove', array('value' => ts('<< Remove'))); } } // navigation field $parentMenu = CRM_Core_BAO_Navigation::getNavigationList(); $form->add('select', 'parent_id', ts('Parent Menu'), array('' => ts('- select -')) + $parentMenu); // For now we only providing drilldown for one primary detail report only. In future this could be multiple reports foreach ($form->_drilldownReport as $reportUrl => $drillLabel) { $instanceList = CRM_Report_Utils_Report::getInstanceList($reportUrl); if (count($instanceList) > 1) { $form->add('select', 'drilldown_id', $drillLabel, array('' => ts('- select -')) + $instanceList); } break; } $form->addButtons(array(array('type' => 'submit', 'name' => ts('Save Report'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $form->addFormRule(array('CRM_Report_Form_Instance', 'formRule'), $form); }
/** * build the form elements for an IM object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form) { $blockId = $form->get('IM_Block_Count') ? $form->get('IM_Block_Count') : 1; $form->applyFilter('__ALL__', 'trim'); //IM provider select $form->addElement('select', "im[{$blockId}][provider_id]", '', CRM_Core_PseudoConstant::IMProvider()); //Block type select $form->addElement('select', "im[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); //IM box $form->addElement('text', "im[{$blockId}][name]", ts('Instant Messenger'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name')); //is_Primary radio $js = array('id' => "IM_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "im[{$blockId}][is_primary]", '', '', '1', $js); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, array('class' => 'crm-select2 huge')); // add select for groups $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup(); $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge')); // add select for categories $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge')); // text for sort_name $form->add('text', 'sort_name', ts('Name')); $form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag')); }
/** * Build the form object elements for an email object. * * @param CRM_Core_Form $form * Reference to the form object. * @param int $blockCount * Block number to build. * @param bool $blockEdit * Is it block edit. */ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) { // passing this via the session is AWFUL. we need to fix this if (!$blockCount) { $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1; } else { $blockId = $blockCount; } $form->applyFilter('__ALL__', 'trim'); //Email box $form->addField("email[{$blockId}][email]", array('entity' => 'email')); $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType) || $blockEdit) { //Block type $form->addField("email[{$blockId}][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight')); //TODO: Refactor on_hold field to select. $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail(); //On-hold select if ($multipleBulk) { $holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out')); $form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions); } else { $form->addField("email[{$blockId}][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox')); } //Bulkmail checkbox $form->assign('multipleBulk', $multipleBulk); if ($multipleBulk) { $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js); } else { $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js); } //is_Primary radio $js = array('id' => "Email_" . $blockId . "_IsPrimary"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40)); $form->add('wysiwyg', "email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40)); } } }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Find Contributors by Aggregate Totals'); /** * Define the search form fields here */ $form->add('text', 'min_amount', ts('Aggregate Total Between $')); $form->addRule('min_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money'); $form->add('text', 'max_amount', ts('...and $')); $form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money'); $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); $financial_types = CRM_Contribute_PseudoConstant::financialType(); foreach ($financial_types as $financial_type_id => $financial_type) { $form->addElement('checkbox', "financial_type_id[{$financial_type_id}]", 'Financial Type', $financial_type); } /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('min_amount', 'max_amount', 'start_date', 'end_date', 'financial_type_id')); }
/** * build the form elements for an open id object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form) { $blockId = $form->get('OpenID_Block_Count') ? $form->get('OpenID_Block_Count') : 1; $form->applyFilter('__ALL__', 'trim'); $form->addElement('text', "openid[{$blockId}][openid]", ts('OpenID'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OpenID', 'openid')); $form->addRule("openid[{$blockId}][openid]", ts('OpenID is not a valid URL.'), 'url'); //Block type $form->addElement('select', "openid[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); $config = CRM_Core_Config::singleton(); if ($config->userFramework == 'Standalone') { $js = array('id' => "OpenID_" . $blockId . "_IsLogin", 'onClick' => 'singleSelect( this.id );'); $form->addElement('advcheckbox', "openid[{$blockId}][allowed_to_login]", null, '', $js); } //is_Primary radio $js = array('id' => "OpenID_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "openid[{$blockId}][is_primary]", '', '', '1', $js); }
/** * This function provides the HTML form elements that are specific. * to the Household Contact Type * * @param CRM_Core_Form $form * Form object. * @param int $inlineEditMode * ( 1 for contact summary. * top bar form and 2 for display name edit ) * * @return void */ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); $form->applyFilter('__ALL__', 'trim'); if (!$inlineEditMode || $inlineEditMode == 1) { // household_name $form->add('text', 'household_name', ts('Household Name'), $attributes['household_name']); } if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name $form->addElement('text', 'nick_name', ts('Nickname'), $attributes['nick_name']); $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); } if (!$inlineEditMode) { $form->add('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], FALSE); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier')); } }
/** * build the form elements for a phone object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form) { $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1; $form->applyFilter('__ALL__', 'trim'); //phone type select $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::phoneType()); //phone box $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); if (isset($form->_contactType)) { //Block type select $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); //is_Primary radio $js = array('id' => "Phone_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js); } // TODO: set this up as a group, we need a valid phone_type_id if we have a phone number // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' ); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { $groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(FALSE); $form->addElement('select', 'group_id', ts('Group'), $groups, array('class' => 'crm-select2 huge')); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('group_id')); }
/** * Build the form object elements for an open id object. * * @param CRM_Core_Form $form * Reference to the form object. * @param int $blockCount * Block number to build. * @param bool $blockEdit * Is it block edit. */ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) { if (!$blockCount) { $blockId = $form->get('OpenID_Block_Count') ? $form->get('OpenID_Block_Count') : 1; } else { $blockId = $blockCount; } $form->applyFilter('__ALL__', 'trim'); $form->addElement('text', "openid[{$blockId}][openid]", ts('OpenID'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OpenID', 'openid')); $form->addRule("openid[{$blockId}][openid]", ts('OpenID is not a valid URL.'), 'url'); //Block type $form->addElement('select', "openid[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')); //is_Primary radio $js = array('id' => "OpenID_" . $blockId . "_IsPrimary"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "openid[{$blockId}][is_primary]", '', '', '1', $js); }
/** * build the form elements for an email object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form) { $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1; $form->applyFilter('__ALL__', 'trim'); //Email box $form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType)) { //Block type $form->addElement('select', "email[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); //On-hold checkbox $form->addElement('advcheckbox', "email[{$blockId}][on_hold]", null); //Bulkmail checkbox $js = array('id' => "Email_" . $blockId . "_IsBulkmail", 'onClick' => 'singleSelect( this.id );'); $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", null, '', $js); //is_Primary radio $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js); } }
/** * build the form elements for an IM object * * @param CRM_Core_Form $form reference to the form object * @param int $blockCount block number to build * @param boolean $blockEdit is it block edit * * @return void * @access public * @static */ static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) { if (!$blockCount) { $blockId = $form->get('IM_Block_Count') ? $form->get('IM_Block_Count') : 1; } else { $blockId = $blockCount; } $form->applyFilter('__ALL__', 'trim'); //IM provider select $form->addSelect("im[{$blockId}][provider_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL)); //Block type select $form->addSelect("im[{$blockId}][location_type_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL)); //IM box $form->addElement('text', "im[{$blockId}][name]", ts('Instant Messenger'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name')); //is_Primary radio $js = array('id' => 'IM_' . $blockId . '_IsPrimary'); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "im[{$blockId}][is_primary]", '', '', '1', $js); }
/** * Build the form object for Advance Settings. * * * @param CRM_Core_Form $form * * @return void */ public static function buildAdvanceSetting(&$form) { // should mapping be enabled for this group $form->addElement('checkbox', 'is_map', ts('Enable mapping for this profile?')); // should we allow updates on a exisitng contact $options = array(); $options[] = $form->createElement('radio', NULL, NULL, ts('Issue warning and do not save'), 0); $options[] = $form->createElement('radio', NULL, NULL, ts('Update the matching contact'), 1); $options[] = $form->createElement('radio', NULL, NULL, ts('Allow duplicate contact to be created'), 2); $form->addGroup($options, 'is_update_dupe', ts('What to do upon duplicate match')); // we do not have any url checks to allow relative urls $form->addElement('text', 'post_URL', ts('Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'post_URL')); $form->addElement('text', 'cancel_URL', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_URL')); // add select for groups $group = array('' => ts('- select -')) + $form->_group; $form->_groupElement =& $form->addElement('select', 'group', ts('Limit listings to a specific Group?'), $group); //add notify field $form->addElement('text', 'notify', ts('Notify when profile form is submitted?')); //group where new contacts are directed. $form->addElement('select', 'add_contact_to_group', ts('Add new contacts to a Group?'), $group); // add CAPTCHA To this group ? $form->addElement('checkbox', 'add_captcha', ts('Include reCAPTCHA?')); // should we display an edit link $form->addElement('checkbox', 'is_edit_link', ts('Include profile edit links in search results?')); // should we display a link to the website profile $config = CRM_Core_Config::singleton(); $form->addElement('checkbox', 'is_uf_link', ts('Include %1 user account information links in search results?', array(1 => $config->userFramework))); // want to create cms user $session = CRM_Core_Session::singleton(); $cmsId = FALSE; if ($form->_cId = $session->get('userID')) { $form->_cmsId = TRUE; } $options = array(); $options[] = $form->createElement('radio', NULL, NULL, ts('No account create option'), 0); $options[] = $form->createElement('radio', NULL, NULL, ts('Give option, but not required'), 1); $options[] = $form->createElement('radio', NULL, NULL, ts('Account creation required'), 2); $form->addGroup($options, 'is_cms_user', ts('%1 user account registration option?', array(1 => $config->userFramework))); // options for including Proximity Search in the profile search form $proxOptions = array(); $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('None'), 0); $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Optional'), 1); $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Required'), 2); $form->addGroup($proxOptions, 'is_proximity_search', ts('Proximity Search')); }
/** * build the form elements for Demographics object * * @param CRM_Core_Form $form reference to the form object * * @return void * @access public * @static */ static function buildQuickForm(&$form) { // radio button for gender $genderOptions = array(); $gender = CRM_Core_PseudoConstant::gender(); foreach ($gender as $key => $var) { $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key); } $form->addGroup($genderOptions, 'gender_id', ts('Gender')); $form->addDate('birth_date', ts('Date of birth'), false, array('formatType' => 'birth')); $form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'), array('onclick' => "showDeceasedDate()")); $form->addDate('deceased_date', ts('Deceased date'), false, array('formatType' => 'birth')); }
/** * build the form elements for Demographics object * * @param CRM_Core_Form $form reference to the form object * * @return void * @access public * @static */ static function buildQuickForm(&$form) { // radio button for gender $genderOptions = array(); $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE)); foreach ($gender as $key => $var) { $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key, array('id' => "civicrm_gender_{$var}_{$key}")); } $form->addGroup($genderOptions, 'gender_id', ts('Gender'))->setAttribute('unselectable', TRUE); $form->addDate('birth_date', ts('Date of Birth'), FALSE, array('formatType' => 'birth')); $form->addElement('checkbox', 'is_deceased', NULL, ts('Contact is deceased'), array('onclick' => "showDeceasedDate()")); $form->addDate('deceased_date', ts('Deceased date'), FALSE, array('formatType' => 'birth')); }
/** * Build the form object for Premium Information. * * Called from the CRM_Contribute_Form_Contribute function and seemingly nowhere else. * * Probably this should be on the form that uses it since it is not used on multiple forms. * * Putting it on this class doesn't seem to reduce complexity. * * @param CRM_Core_Form $form */ public static function buildPremium(&$form) { //premium section $form->add('hidden', 'hidden_Premium', 1); $sel1 = $sel2 = array(); $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; $dao->find(); $min_amount = array(); $sel1[0] = ts('-select product-'); while ($dao->fetch()) { $sel1[$dao->id] = $dao->name . " ( " . $dao->sku . " )"; $min_amount[$dao->id] = $dao->min_contribution; $options = explode(',', $dao->options); foreach ($options as $k => $v) { $options[$k] = trim($v); } if ($options[0] != '') { $sel2[$dao->id] = $options; } $form->assign('premiums', TRUE); } $form->_options = $sel2; $form->assign('mincontribution', $min_amount); $sel =& $form->addElement('hierselect', "product_name", ts('Premium'), 'onclick="showMinContrib();"'); $js = "<script type='text/javascript'>\n"; $formName = 'document.forms.' . $form->getName(); for ($k = 1; $k < 2; $k++) { if (!isset($defaults['product_name'][$k]) || !$defaults['product_name'][$k]) { $js .= "{$formName}['product_name[{$k}]'].style.display = 'none';\n"; } } $sel->setOptions(array($sel1, $sel2)); $js .= "</script>\n"; $form->assign('initHideBoxes', $js); $form->addDate('fulfilled_date', ts('Fulfilled'), FALSE, array('formatType' => 'activityDate')); $form->addElement('text', 'min_amount', ts('Minimum Contribution Amount')); }
/** * build the form elements for an Website object * * @param CRM_Core_Form $form reference to the form object * @param int $blockCount block number to build * * @return void * @access public * @static */ static function buildQuickForm(&$form, $blockCount = NULL) { if (!$blockCount) { $blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1; } else { $blockId = $blockCount; } $form->applyFilter('__ALL__', 'trim'); //Website type select $form->addSelect("website[{$blockId}][website_type_id]", array('entity' => 'website', 'class' => 'eight')); //Website box $form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false"))); $form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url'); }
/** * This is function is called by the form object to get the DataSource's * form snippet. It should add all fields necesarry to get the data * uploaded to the temporary table in the DB. * * @param CRM_Core_Form $form * * @return void * (operates directly on form argument) */ public function buildQuickForm(&$form) { $form->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_CSV'); $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $form->assign('uploadSize', $uploadSize); $form->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $form->setMaxFileSize($uploadFileSize); $form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $form->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { CRM_Utils_System::setTitle(ts('My Search Title')); $form->add('text', 'household_name', ts('Household Name'), TRUE); $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince(); $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince); // Optionally define default search values $form->setDefaults(array('household_name' => '', 'state_province_id' => NULL)); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('household_name', 'state_province_id')); }
/** * This function provides the HTML form elements. * * @param CRM_Core_Form $form * Form object. * @param int $contactID */ public static function buildQuickForm(&$form, $contactID) { // We provide a value for oplock_ts to client, but JS uses it carefully // -- i.e. when loading the first inline form, JS copies oplock_ts to a // global value, and that global value is used for future form submissions. // Any time a form is submitted, the value will be updated. This // handles cases like: // - V1:open V1.phone:open V1.email:open V1.email:submit V1.phone:submit // - V1:open E1:open E1:submit V1.email:open V1.email:submit // - V1:open V1.email:open E1:open E1:submit V1.email:submit V1:lock $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID); $form->addElement('hidden', 'oplock_ts', $timestamps['modified_date'], array('id' => 'oplock_ts')); $form->addFormRule(array('CRM_Contact_Form_Inline_Lock', 'formRule'), $contactID); }
/** * Build form. * * @param CRM_Core_Form $form */ public function buildForm(&$form) { $form->add('text', 'household_name', ts('Household Name'), TRUE); $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince(); $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince); /** * You can define a custom title for the search form */ $this->setTitle(ts('My Search Title')); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('household_name', 'state_province_id')); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Find Contribution Amounts by Tag'); /** * Define the search form fields here */ $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); $form->addElement('select', 'tag', ts('Tagged'), $tag); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('start_date', 'end_date', 'tag')); }
/** * Build form for honoree contact / on behalf of organization. * * @param CRM_Core_Form $form * */ public static function buildQuickForm(&$form) { $ufGroup = new CRM_Core_DAO_UFGroup(); $ufGroup->id = $form->_honoreeProfileId; if (!$ufGroup->find(TRUE)) { CRM_Core_Error::fatal(ts('Chosen honoree profile for this contribution is disabled')); } $prefix = 'honor'; $honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($form->_honoreeProfileId, FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::CREATE); $form->addElement('hidden', 'honoree_profile_id', $form->_honoreeProfileId); $form->assign('honoreeProfileFields', $honoreeProfileFields); // add the form elements foreach ($honoreeProfileFields as $name => $field) { // If soft credit type is not chosen then make omit requiredness from honoree profile fields if (count($form->_submitValues) && empty($form->_submitValues['soft_credit_type_id']) && !empty($field['is_required'])) { $field['is_required'] = FALSE; } CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix); } }