/** * Build all the data structures needed to build the form. * * @param CRM_Core_Form $form * * @return void */ public static function preProcess(&$form) { $messageText = array(); $messageSubject = array(); $dao = new CRM_Core_BAO_MessageTemplate(); $dao->is_active = 1; $dao->find(); while ($dao->fetch()) { $messageText[$dao->id] = $dao->msg_text; $messageSubject[$dao->id] = $dao->msg_subject; } $form->assign('message', $messageText); $form->assign('messageSubject', $messageSubject); CRM_Utils_System::setTitle('Create Printable Letters (PDF)'); }
/** * 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); }
/** * @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')); }
/** * @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')); }
/** * Function used to build form element for soft credit block. * * @param CRM_Core_Form $form * * @return \CRM_Core_Form */ public static function buildQuickForm(&$form) { if (!empty($form->_honor_block_is_active)) { $ufJoinDAO = new CRM_Core_DAO_UFJoin(); $ufJoinDAO->module = 'soft_credit'; $ufJoinDAO->entity_id = $form->_id; if ($ufJoinDAO->find(TRUE)) { $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit'); if ($jsonData) { foreach (array('honor_block_title', 'honor_block_text') as $name) { $form->assign($name, $jsonData[$name]); } $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE); // radio button for Honor Type foreach ($jsonData['soft_credit_types'] as $value) { $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value); } $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE); } } return $form; } // by default generate 10 blocks $item_count = 11; $showSoftCreditRow = 2; if ($form->getAction() & CRM_Core_Action::UPDATE) { $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE); } elseif (!empty($form->_pledgeID)) { //Check and select most recent completed contrubtion and use it to retrieve //soft-credit information to use as default for current pledge payment, CRM-13981 $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID); foreach ($pledgePayments as $id => $record) { if ($record['contribution_id']) { $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE); if ($record['status'] == 'Completed' && count($softCredits) > 0) { $form->_softCreditInfo = $softCredits; } } } } if (property_exists($form, "_softCreditInfo")) { if (!empty($form->_softCreditInfo['soft_credit'])) { $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']); $showSoftCreditRow++; } } for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) { $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE)); $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE); $form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type'))); if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) { $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']); } } self::addPCPFields($form); $form->assign('showSoftCreditRow', $showSoftCreditRow); $form->assign('rowCount', $item_count); $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id')); }
/** * @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')); }
/** * @param CRM_Core_Form $form * * @throws Exception */ public static function preProcess(&$form) { if (empty($form->_caseId)) { CRM_Core_Error::fatal(ts('Case Id not found.')); } if (count($form->_caseId) != 1) { CRM_Core_Resources::fatal(ts('Expected one case-type')); } $caseId = CRM_Utils_Array::first($form->_caseId); $form->assign('clientID', $form->_currentlyViewedContactId); $form->assign('sortName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $form->_currentlyViewedContactId, 'sort_name')); $form->assign('caseTypeLabel', CRM_Case_BAO_Case::getCaseType($caseId)); // get the related cases for given case. $relatedCases = $form->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $form->_currentlyViewedContactId); $form->set('relatedCases', empty($relatedCases) ? FALSE : $relatedCases); } }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { CRM_Utils_System::setTitle(ts('Find Post Code')); $form->add('text', 'post_code', 'Post Code'); $form->add('select', 'post_city', 'Post City', $this->citiesList); $defaults = $this->retrieveDefaultValues(); if (!empty($defaults)) { $form->setDefaults($defaults); } $form->assign('elements', array('post_code', 'post_city')); }
/** * Add element to form. * * @param CRM_Core_Form $form */ public static function add(&$form) { $error = NULL; $config = CRM_Core_Config::singleton(); $useSSL = FALSE; if (!function_exists('recaptcha_get_html')) { require_once 'packages/recaptcha/recaptchalib.php'; } // See if we are using SSL if (CRM_Utils_System::isSSL()) { $useSSL = TRUE; } $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useSSL); $form->assign('recaptchaHTML', $html); $form->assign('recaptchaOptions', $config->recaptchaOptions); $form->add('text', 'g-recaptcha-response', 'reCaptcha', NULL, TRUE); $form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA'); if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) { $form->setElementError('g-recaptcha-response', ts('Input text must match the phrase in the image. Please review the image and re-enter matching text.')); } }
/** * build the form elements for Communication Preferences object * * @param CRM_Core_Form $form reference to the form object * * @return void * @access public * @static */ static function buildQuickForm(&$form) { // since the pcm - preferred comminication method is logically // grouped hence we'll use groups of HTML_QuickForm // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues $privacy = $commPreff = $commPreference = array(); $privacyOptions = CRM_Core_SelectValues::privacy(); // we add is_opt_out as a separate checkbox below for display and help purposes so remove it here unset($privacyOptions['is_opt_out']); foreach ($privacyOptions as $name => $label) { $privacy[] = $form->createElement('advcheckbox', $name, NULL, $label); } $form->addGroup($privacy, 'privacy', ts('Privacy'), ' '); // preferred communication method $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', array('loclize' => TRUE)); foreach ($comm as $value => $title) { $commPreff[] = $form->createElement('advcheckbox', $value, NULL, $title); } $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)')); $form->addSelect('preferred_language'); if (!empty($privacyOptions)) { $commPreference['privacy'] = $privacyOptions; } if (!empty($comm)) { $commPreference['preferred_communication_method'] = $comm; } //using for display purpose. $form->assign('commPreference', $commPreference); $form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf()); $form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)')); $communicationStyleOptions = array(); $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id', array('localize' => TRUE)); foreach ($communicationStyle as $key => $var) { $communicationStyleOptions[$key] = $form->createElement('radio', NULL, ts('Communication Style'), $var, $key, array('id' => "civicrm_communication_style_{$var}_{$key}")); } if (!empty($communicationStyleOptions)) { $form->addGroup($communicationStyleOptions, 'communication_style_id', ts('Communication Style')); } //check contact type and build filter clause accordingly for greeting types, CRM-4575 $greetings = self::getGreetingFields($form->_contactType); foreach ($greetings as $greeting => $fields) { $filter = array('contact_type' => $form->_contactType, 'greeting_type' => $greeting); //add addressee in Contact form $greetingTokens = CRM_Core_PseudoConstant::greeting($filter); if (!empty($greetingTokens)) { $form->addElement('select', $fields['field'], $fields['label'], array('' => ts('- select -')) + $greetingTokens); //custom addressee $form->addElement('text', $fields['customField'], $fields['customLabel'], CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', $fields['customField']), $fields['js']); } } }
/** * 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')); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { $form->add('text', 'postal_code_low', ts('Postal Code Start'), TRUE); $form->add('text', 'postal_code_high', ts('Postal Code End'), TRUE); /** * You can define a custom title for the search form */ $this->setTitle('Zip Code Range Search'); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('postal_code_low', 'postal_code_high')); }
/** * 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')); }
/** * @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')); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { $form->add('text', 'segmentSize', ts('Segment Size'), TRUE); $groups = CRM_Core_PseudoConstant::nestedGroup(); $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -')); $form->add('select', 'includeGroups', ts('Include Group(s)'), $groups, FALSE, $select2style); $form->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style); $this->setTitle('Create a random segment of contacts'); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('segmentSize', 'includeGroups', 'excludeGroups')); }
/** * @param CRM_Core_Form $form * * @throws Exception */ public static function preProcess(&$form) { if (!isset($form->_caseId)) { CRM_Core_Error::fatal(ts('Case Id not found.')); } if (count($form->_caseId) != 1) { CRM_Core_Resources::fatal(ts('Expected one case-type')); } $caseId = CRM_Utils_Array::first($form->_caseId); $form->assign('clientID', $form->_currentlyViewedContactId); $form->assign('caseTypeLabel', CRM_Case_BAO_Case::getCaseType($caseId)); // get the related cases for given case. $relatedCases = $form->get('relatedCases'); if (!isset($relatedCases)) { $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $form->_currentlyViewedContactId); $form->set('relatedCases', empty($relatedCases) ? FALSE : $relatedCases); } $excludeCaseIds = array($caseId); if (is_array($relatedCases) && !empty($relatedCases)) { $excludeCaseIds = array_merge($excludeCaseIds, array_keys($relatedCases)); } $form->assign('excludeCaseIds', implode(',', $excludeCaseIds)); }
/** * Set variables up before form is built. * * @param CRM_Core_Form $form * * @return void */ public static function preProcess(&$form) { $form->_addBlockName = CRM_Utils_Request::retrieve('block', 'String', CRM_Core_DAO::$_nullObject); $additionalblockCount = CRM_Utils_Request::retrieve('count', 'Positive', CRM_Core_DAO::$_nullObject); $form->assign('addBlock', FALSE); if ($form->_addBlockName && $additionalblockCount) { $form->assign('addBlock', TRUE); $form->assign('blockName', $form->_addBlockName); $form->assign('blockId', $additionalblockCount); $form->set($form->_addBlockName . '_Block_Count', $additionalblockCount); } if (is_a($form, 'CRM_Event_Form_ManageEvent_Location') || is_a($form, 'CRM_Contact_Form_Domain')) { $form->_blocks = array('Address' => ts('Address'), 'Email' => ts('Email'), 'Phone' => ts('Phone')); } $form->assign('blocks', $form->_blocks); $form->assign('className', CRM_Utils_System::getClassName($form)); // get address sequence. if (!($addressSequence = $form->get('addressSequence'))) { $addressSequence = CRM_Core_BAO_Address::addressSequence(); $form->set('addressSequence', $addressSequence); } $form->assign('addressSequence', $addressSequence); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { $config = CRM_Earmarking_Config::singleton(); CRM_Utils_System::setTitle($config->translate('Search for Contacts with Recurring Contributions')); $paymentTypeList = $this->getPaymentTypeList(); $earmarkingList = $this->getEarmarkingList(); $contibutionStatusList = $this->getContributionStatusList(); $form->add('select', 'earmarking_id', $config->translate('Earmarking'), $earmarkingList); $form->add('select', 'payment_type_id', $config->translate('Payment Type'), $paymentTypeList); $form->add('select', 'status_id', ts('Contribution Status'), $contibutionStatusList); $form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom')); $form->assign('elements', array('earmarking_id', 'payment_type_id', 'status_id', 'start_date', 'end_date')); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { CRM_Utils_System::setTitle(ts('Search for Players on Teams')); $form->add('text', 'contact_id', ts('Player ID'), TRUE); $form->add('text', 'group_id', ts('Team ID'), TRUE); //$team = array('' => ts('- any team -')) + CRM_Core_PseudoConstant::stateProvince(); //$form->addElement('select', 'group_id', ts('Team'), $team); // Optionally define default search values $form->setDefaults(array('contact_id' => '', 'group_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('contact_id', 'group_id')); }
/** * 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')); }
/** * 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)); } } }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable */ function buildForm(&$form) { $this->setTitle('Addresses needing attention'); /** * Define the search form fields here */ $search_types = array('2' => 'Street address missing a number', '3' => 'Has street address and postcode, but not city', '4' => 'Missing or invalid postcode', '5' => 'Missing state_province_id', '6' => 'Address contains punctuation', '8' => 'Country is missing, or is one that is often entered incorrectly', '9' => 'State does not match Country', '10' => 'Street Address contains "NCA" (NCA addresses are hidden from other searches)'); $form->addRadio('search_type', ts('Search options'), $search_types, array(), '<br />', TRUE); // Filter on Minimum Contact ID $form->add('text', 'min_contact_id', ts('Only show contact records with ID greater than:')); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('search_type', 'min_contact_id')); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { CRM_Utils_System::setTitle(ts('Recently Registered Guest (Unassigned)')); /* $form->add('text', 'name', ts('Name'), TRUE ); $form->setDefaults(array( 'name' => '', )); */ /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('name')); }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Recurring Contribution Changes'); /** * Define the search form fields here */ $form->addDate('start_date', ts('Changes Since'), 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('start_date')); }
/** * @param CRM_Core_Form $form * @param bool $useTable */ public static function preProcessCommon(&$form, $useTable = FALSE) { $form->_participantIds = array(); $values = $form->controller->exportValues($form->get('searchFormName')); $form->_task = $values['task']; $eventTasks = CRM_Event_Task::tasks(); $form->assign('taskName', $eventTasks[$form->_task]); $ids = array(); if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } else { $queryParams = $form->get('queryParams'); $sortOrder = NULL; if ($form->get(CRM_Utils_Sort::SORT_ORDER)) { $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER); } $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT); $query->_distinctComponentClause = "civicrm_participant.id"; $query->_groupByComponentClause = " GROUP BY civicrm_participant.id "; $result = $query->searchQuery(0, 0, $sortOrder); while ($result->fetch()) { $ids[] = $result->participant_id; } } if (!empty($ids)) { $form->_componentClause = ' civicrm_participant.id IN ( ' . implode(',', $ids) . ' ) '; $form->assign('totalSelectedParticipants', count($ids)); } $form->_participantIds = $form->_componentIds = $ids; //set the context for redirection for any task actions $session = CRM_Core_Session::singleton(); $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $searchFormName = strtolower($form->get('searchFormName')); if ($searchFormName == 'search') { $session->replaceUserContext(CRM_Utils_System::url('civicrm/event/search', $urlParams)); } else { $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams)); } }
/** * Build the form object. * * * @param CRM_Core_Form $form * @param $proxSearch * * @return void */ public function buildQuickForm($form, $proxSearch) { // is proximity search required (2) or optional (1)? $proxRequired = $proxSearch == 2 ? TRUE : FALSE; $form->assign('proximity_search', TRUE); $form->add('text', 'prox_street_address', ts('Street Address'), NULL, FALSE); $form->add('text', 'prox_city', ts('City'), NULL, FALSE); $form->add('text', 'prox_postal_code', ts('Postal Code'), NULL, FALSE); $form->addChainSelect('prox_state_province_id', array('required' => $proxRequired)); $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(); $form->add('select', 'prox_country_id', ts('Country'), $country, $proxRequired); $form->add('text', 'prox_distance', ts('Distance'), NULL, $proxRequired); $proxUnits = array('km' => ts('km'), 'miles' => ts('miles')); $form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, $proxRequired); // prox_distance_unit $form->addFormRule(array('CRM_Contact_Form_Task_ProximityCommon', 'formRule'), $form); }
/** * @param CRM_Core_Form $form * @param bool $useTable */ public static function preProcessCommon(&$form, $useTable = FALSE) { $values = $form->controller->exportValues($form->get('searchFormName')); $form->_task = CRM_Utils_Array::value('task', $values); $mailingTasks = CRM_Mailing_Task::tasks(); $form->assign('taskName', CRM_Utils_Array::value('task', $values)); // ids are mailing event queue ids $ids = array(); if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } } } else { $queryParams = $form->get('queryParams'); $sortOrder = NULL; if ($form->get(CRM_Utils_Sort::SORT_ORDER)) { $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER); } $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_MAILING); $result = $query->searchQuery(0, 0, $sortOrder); while ($result->fetch()) { $ids[] = $result->mailing_recipients_id; } $form->assign('totalSelectedMailingRecipients', $form->get('rowCount')); } if (!empty($ids)) { $form->_componentClause = ' civicrm_mailing_recipients.id IN ( ' . implode(',', $ids) . ' ) '; } //set the context for redirection for any task actions $session = CRM_Core_Session::singleton(); $fragment = 'search'; if ($form->_action == CRM_Core_Action::ADVANCED) { $fragment .= '/advanced'; } $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); $urlParams = 'force=1'; if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&qfKey={$qfKey}"; } $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams); $session = CRM_Core_Session::singleton(); $session->replaceUserContext($url); }
/** * Build tag widget if correct parent is passed * * @param CRM_Core_Form $form * Form object. * @param string $parentNames * Parent name ( tag name). * @param string $entityTable * Entitytable 'eg: civicrm_contact'. * @param int $entityId * Entityid 'eg: contact id'. * @param bool $skipTagCreate * True if tag need be created using ajax. * @param bool $skipEntityAction * True if need to add entry in entry table via ajax. * @param string $tagsetElementName * If you need to create tagsetlist with specific name. */ public static function buildQuickForm(&$form, $parentNames, $entityTable, $entityId = NULL, $skipTagCreate = FALSE, $skipEntityAction = FALSE, $tagsetElementName = NULL) { $tagset = $form->_entityTagValues = array(); $form->assign("isTagset", FALSE); $mode = NULL; foreach ($parentNames as &$parentNameItem) { // get the parent id for tag list input for keyword $parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $parentNameItem, 'id', 'name'); // check if parent exists if ($parentId) { $tagsetItem = $tagsetElementName . 'parentId_' . $parentId; $tagset[$tagsetItem]['parentID'] = $parentId; list(, $mode) = explode('_', $entityTable); if (!$tagsetElementName) { $tagsetElementName = $mode . "_taglist"; } $tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName; $form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, array('entity' => 'tag', 'multiple' => TRUE, 'create' => !$skipTagCreate, 'api' => array('params' => array('parent_id' => $parentId)), 'data-entity_table' => $entityTable, 'data-entity_id' => $entityId, 'class' => "crm-{$mode}-tagset")); if ($entityId) { $tagset[$tagsetItem]['entityId'] = $entityId; $entityTags = CRM_Core_BAO_EntityTag::getChildEntityTags($parentId, $entityId, $entityTable); if ($entityTags) { $form->setDefaults(array("{$tagsetElementName}[{$parentId}]" => implode(',', array_keys($entityTags)))); } } else { $skipEntityAction = TRUE; } $tagset[$tagsetItem]['skipEntityAction'] = $skipEntityAction; } } if (!empty($tagset)) { // assign current tagsets which is used in postProcess $form->_tagsetInfo = $tagset; $form->assign("tagsetType", $mode); // Merge this tagset info with possibly existing info in the template $tagsetInfo = (array) $form->get_template_vars("tagsetInfo"); if (empty($tagsetInfo[$mode])) { $tagsetInfo[$mode] = array(); } $tagsetInfo[$mode] = array_merge($tagsetInfo[$mode], $tagset); $form->assign("tagsetInfo", $tagsetInfo); $form->assign("isTagset", TRUE); } }
/** * @param CRM_Core_Form $form */ public function buildForm(&$form) { $form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom')); $groups = CRM_Core_PseudoConstant::nestedGroup(); $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -')); $form->add('select', 'includeGroups', ts('Include Group(s)'), $groups, FALSE, $select2style); $form->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style); $this->setTitle('Search by date added to CiviCRM'); //redirect if group not available for search criteria if (count($groups) == 0) { CRM_Core_Error::statusBounce(ts("Atleast one Group must be present for search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1')); } /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('start_date', 'end_date', 'includeGroups', 'excludeGroups')); }
/** * @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')); }