本文整理汇总了PHP中CRM_Campaign_BAO_Campaign::addCampaign方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Campaign::addCampaign方法的具体用法?PHP CRM_Campaign_BAO_Campaign::addCampaign怎么用?PHP CRM_Campaign_BAO_Campaign::addCampaign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Campaign
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Campaign::addCampaign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
static function buildQuickForm(&$form)
{
//Added for CRM-12682: Add activity subject and campaign fields
CRM_Campaign_BAO_Campaign::addCampaign($form);
$form->add('text', 'subject', ts('Activity Subject'), array('size' => 45, 'maxlength' => 255), FALSE);
$form->add('static', 'pdf_format_header', NULL, ts('Page Format'));
$form->add('select', 'format_id', ts('Select Format'), array(0 => ts('- default -')) + CRM_Core_BAO_PdfFormat::getList(TRUE), FALSE, array('onChange' => "selectFormat( this.value, false );"));
$form->add('select', 'paper_size', ts('Paper Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();"));
$form->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
$form->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();"));
$form->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
$form->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('checkbox', 'bind_format', ts('Always use this Page Format with the selected Template'));
$form->add('checkbox', 'update_format', ts('Update Page Format (this will affect all templates that use this format)'));
$form->assign('useThisPageFormat', ts('Always use this Page Format with the new template?'));
$form->assign('useSelectedPageFormat', ts('Should the new template always use the selected Page Format?'));
$form->assign('totalSelectedContacts', count($form->_contactIds));
CRM_Mailing_BAO_Mailing::commonLetterCompose($form);
if ($form->_single) {
$cancelURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$form->_cid}&selectedChild=activity", FALSE, NULL, FALSE);
if ($form->get('action') == CRM_Core_Action::VIEW) {
$form->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
} else {
$form->addButtons(array(array('type' => 'submit', 'name' => ts('Make PDF Letter'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Done'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
}
} else {
$form->addButtons(array(array('type' => 'submit', 'name' => ts('Make PDF Letters'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Done'))));
}
$form->addFormRule(array('CRM_Contact_Form_Task_PDFLetterCommon', 'formRule'), $form);
}
示例2: buildQuickForm
/**
* Build the form
*
* @var CRM_Core_Form $form
*
* @return void
*/
static function buildQuickForm(&$form)
{
// This form outputs a file so should never be submitted via ajax
$form->preventAjaxSubmit();
//Added for CRM-12682: Add activity subject and campaign fields
CRM_Campaign_BAO_Campaign::addCampaign($form);
$form->add('text', 'subject', ts('Activity Subject'), array('size' => 45, 'maxlength' => 255), FALSE);
$form->add('static', 'pdf_format_header', NULL, ts('Page Format: %1', array(1 => '<span class="pdf-format-header-label"></span>')));
$form->addSelect('format_id', array('label' => ts('Select Format'), 'placeholder' => ts('Default'), 'entity' => 'message_template', 'field' => 'pdf_format_id', 'option_url' => 'civicrm/admin/pdfFormats'));
$form->add('select', 'paper_size', ts('Paper Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();"));
$form->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
$form->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();"));
$form->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
$form->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$form->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), TRUE);
$config = CRM_Core_Config::singleton();
if ($config->wkhtmltopdfPath == false) {
$form->add('text', 'stationery', ts('Stationery (relative path to PDF you wish to use as the background)'), array('size' => 25, 'maxlength' => 900, 'onkeyup' => "showUpdateFormatChkBox();"), FALSE);
}
$form->add('checkbox', 'bind_format', ts('Always use this Page Format with the selected Template'));
$form->add('checkbox', 'update_format', ts('Update Page Format (this will affect all templates that use this format)'));
$form->assign('useThisPageFormat', ts('Always use this Page Format with the new template?'));
$form->assign('useSelectedPageFormat', ts('Should the new template always use the selected Page Format?'));
$form->assign('totalSelectedContacts', count($form->_contactIds));
CRM_Mailing_BAO_Mailing::commonLetterCompose($form);
$buttons = array();
if ($form->get('action') != CRM_Core_Action::VIEW) {
$buttons[] = array('type' => 'submit', 'name' => $form->_single ? ts('Make PDF') : ts('Make PDFs'), 'isDefault' => TRUE);
}
$buttons[] = array('type' => 'cancel', 'name' => $form->get('action') == CRM_Core_Action::VIEW ? ts('Done') : ts('Cancel'));
$form->addButtons($buttons);
$form->addFormRule(array('CRM_Contact_Form_Task_PDFLetterCommon', 'formRule'), $form);
}
示例3: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_context == 'standalone') {
$this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
}
$showAdditionalInfo = FALSE;
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
$defaults = array();
$paneNames = array('Payment Reminders' => 'PaymentReminders');
foreach ($paneNames as $name => $type) {
$urlParams = "snippet=4&formType={$type}";
$allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams), 'open' => 'false', 'id' => $type);
// see if we need to include this paneName in the current form
if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
$showAdditionalInfo = TRUE;
$allPanes[$name]['open'] = 'true';
}
$fnName = "build{$type}";
CRM_Contribute_Form_AdditionalInfo::$fnName($this);
}
$this->assign('allPanes', $allPanes);
$this->assign('showAdditionalInfo', $showAdditionalInfo);
if ($this->_formType) {
$this->assign('formType', $this->_formType);
return;
}
$this->applyFilter('__ALL__', 'trim');
// pledge fields.
$attributes = CRM_Core_DAO::getAttribute('CRM_Pledge_DAO_Pledge');
$this->assign('isPending', $this->_isPending);
$js = array('onblur' => "calculatedPaymentAmount( );", 'onkeyup' => "calculatedPaymentAmount( );");
$currencyFreeze = FALSE;
if ($this->_id && !$this->_isPending) {
$currencyFreeze = TRUE;
}
$element = $this->addMoney('amount', ts('Total Pledge Amount'), TRUE, array_merge($attributes['pledge_amount'], $js), TRUE, 'currency', NULL, $currencyFreeze);
if ($this->_id && !$this->_isPending) {
$element->freeze();
}
$element =& $this->add('text', 'installments', ts('To be paid in'), array_merge($attributes['installments'], $js), TRUE);
$this->addRule('installments', ts('Please enter a valid number of installments.'), 'positiveInteger');
if ($this->_id && !$this->_isPending) {
$element->freeze();
}
$element =& $this->add('text', 'frequency_interval', ts('every'), $attributes['pledge_frequency_interval'], TRUE);
$this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger');
if ($this->_id && !$this->_isPending) {
$element->freeze();
}
// Fix frequency unit display for use with frequency_interval
$freqUnitsDisplay = array();
foreach ($this->_freqUnits as $val => $label) {
$freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
}
$element =& $this->add('select', 'frequency_unit', ts('Frequency'), array('' => ts('- select -')) + $freqUnitsDisplay, TRUE);
if ($this->_id && !$this->_isPending) {
$element->freeze();
}
$element =& $this->add('text', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE);
$this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger');
if ($this->_id && !$this->_isPending) {
$element->freeze();
}
$this->add('text', 'eachPaymentAmount', ts('each'), array('size' => 10, 'style' => "background-color:#EBECE4", 0 => 'READONLY'));
// add various dates
if (!$this->_id || $this->_isPending) {
$this->addDate('create_date', ts('Pledge Made'), TRUE);
$this->addDate('start_date', ts('Payments Start'), TRUE);
}
if ($this->_id && !$this->_isPending) {
$eachPaymentAmount = $this->_values['original_installment_amount'];
$this->assign('currency', $this->_values['currency']);
$this->assign('eachPaymentAmount', $eachPaymentAmount);
$this->assign('hideCalender', TRUE);
}
if (CRM_Utils_Array::value('status_id', $this->_values) != array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
$this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), NULL, array('onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );"));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
}
$this->addDate('acknowledge_date', ts('Acknowledgment Date'));
$this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE);
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
$pageIds = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgeBlock', 'entity_table', 'civicrm_contribution_page', $pageIds, array('entity_id'));
$pages = CRM_Contribute_PseudoConstant::contributionPage();
$pledgePages = array();
foreach ($pageIds as $key => $value) {
$pledgePages[$value['entity_id']] = $pages[$value['entity_id']];
}
$ele = $this->add('select', 'contribution_page_id', ts('Self-service Payments Page'), array('' => ts('- select -')) + $pledgePages);
$mailingInfo = Civi::settings()->get('mailing_backend');
$this->assign('outBound_option', $mailingInfo['outBound_option']);
//.........这里部分代码省略.........
示例4: buildQuickForm
//.........这里部分代码省略.........
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
// build array(event -> eventType) mapper
$query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
$dao = CRM_Core_DAO::executeQuery($query);
$eventAndTypeMapping = array();
while ($dao->fetch()) {
$eventAndTypeMapping[$dao->id] = $dao->event_type_id;
}
$eventAndTypeMapping = json_encode($eventAndTypeMapping);
// building of mapping ends --
//inherit the campaign from event.
$eventCampaigns = array();
$allEventIds = array_keys($events);
if (!empty($allEventIds)) {
CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id');
}
$eventCampaigns = json_encode($eventCampaigns);
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge'));
// CRM-6111
// note that embedding JS within PHP files is quite awful, IMO
// but we do the same for the onChange element and this form is complex
// and i did not want to break it late in the 3.2 cycle
$preloadJSSnippet = NULL;
if (CRM_Utils_Array::value('reset', $_GET) && $this->_eID) {
$preloadJSSnippet = "\ncj(function() {\ncj('#event_id').val( '{$this->_eID}' );\nbuildFeeBlock( {$this->_eID} );\nCRM.buildCustomData( 'Participant', {$this->_eID}, {$this->_eventNameCustomDataTypeID} );\nbuildEventTypeCustomData( {$this->_eID}, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );\nloadCampaign( {$this->_eID}, {$eventCampaigns} );\n});\n";
}
$this->assign('preloadJSSnippet', $preloadJSSnippet);
//frozen the field fix for CRM-4171
if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) {
$element->freeze();
}
}
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id');
}
if (!$campaignId) {
$eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
if ($eventId) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id');
}
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
$this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime'));
if ($this->_id) {
$this->assign('entityID', $this->_id);
}
$roleids = CRM_Event_PseudoConstant::participantRole();
foreach ($roleids as $rolekey => $rolevalue) {
$roleTypes[] = $this->createElement('checkbox', $rolekey, NULL, $rolevalue, array('onclick' => "showCustomData( 'Participant', {$rolekey}, {$this->_roleCustomDataTypeID} );"));
}
$this->addGroup($roleTypes, 'role_id', ts('Participant Role'));
$this->addRule('role_id', ts('Role is required'), 'required');
// CRM-4395
$checkCancelledJs = array('onchange' => "return sendNotification( );");
$confirmJS = NULL;
if ($this->_onlinePendingContributionId) {
$cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus());
$cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});");
$participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus());
$contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );");
}
// get the participant status names to build special status array which is used to show notification
// checkbox below participant status select
$participantStatusName = CRM_Event_PseudoConstant::participantStatus();
$notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired');
// get the required status and then implode only ids
$notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses)));
$this->assign('notificationStatusIds', $notificationStatusIds);
$this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + $this->_participantStatuses, TRUE, $checkCancelledJs);
$this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL);
$this->add('text', 'source', ts('Event Source'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
$buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS);
$path = CRM_Utils_System::currentPath();
$excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search');
if (!in_array($path, $excludeForPaths)) {
$buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS);
}
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
$this->addButtons($buttons);
if ($this->_action == CRM_Core_Action::VIEW) {
$this->freeze();
}
}
示例5: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$this->_first = TRUE;
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage');
// financial Type
$this->addSelect('financial_type_id', array(), TRUE);
// name
$this->add('text', 'title', ts('Title'), $attributes['title'], TRUE);
//CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
$this->add('wysiwyg', 'intro_text', ts('Introductory Message'), $attributes['intro_text']);
$this->add('wysiwyg', 'footer_text', ts('Footer Message'), $attributes['footer_text']);
//Register schema which will be used for OnBehalOf and HonorOf profile Selector
CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel', 'HouseholdModel'));
// is on behalf of an organization ?
$this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);"));
//CRM-15787 - If applicable, register 'membership_1'
$member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
$coreTypes = array('Contact', 'Organization');
$entities[] = array('entity_name' => array('contact_1'), 'entity_type' => 'OrganizationModel');
if ($member && $member['is_active']) {
$coreTypes[] = 'Membership';
$entities[] = array('entity_name' => array('membership_1'), 'entity_type' => 'MembershipModel');
}
$allowCoreTypes = array_merge($coreTypes, CRM_Contact_BAO_ContactType::subTypes('Organization'));
$allowSubTypes = array();
$this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities);
$options = array();
$options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1);
$options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2);
$this->addGroup($options, 'is_for_organization', '');
$this->add('textarea', 'for_organization', ts('On behalf of Label'), array('rows' => 2, 'cols' => 50));
// collect goal amount
$this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12));
$this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
// is confirmation page enabled?
$this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?'));
// is this page shareable through social media ?
$this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?'));
// is this page active ?
$this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
// should the honor be enabled
$this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()"));
$this->add('text', 'honor_block_title', ts('Honoree Section Title'), array('maxlength' => 255, 'size' => 45));
$this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), array('rows' => 2, 'cols' => 50));
$this->addSelect('soft_credit_types', array('label' => ts('Honor Types'), 'entity' => 'ContributionSoft', 'field' => 'soft_credit_type_id', 'multiple' => TRUE, 'class' => 'huge'));
$entities = array(array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'));
$allowCoreTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$allowSubTypes = array();
$this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities);
if (!empty($this->_submitValues['honor_block_is_active'])) {
$this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required');
$this->addRule('honoree_profile', ts('Please select a profile used for honoree'), 'required');
}
// add optional start and end dates
$this->addDateTime('start_date', ts('Start Date'));
$this->addDateTime('end_date', ts('End Date'));
$this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'), $this);
parent::buildQuickForm();
}
示例6: buildQuickForm
function buildQuickForm()
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
// add form elements
$this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
//get the mailing groups.
$groups = CRM_Core_PseudoConstant::group('Mailing');
$this->add('select', 'includeGroups', 'Select Group', array('' => '- select -') + $groups, true);
// Add campaign
// Start
$mailingId = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
$campaignId = NULL;
if ($mailingId) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailingId, 'campaign_id');
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
// End
// Add email subject and and template elements
// Start
$this->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', TRUE);
CRM_Mailing_BAO_Mailing::commonCompose($this);
// End
// Advanced options - Tracking options
// Start
$this->addElement('checkbox', 'override_verp', ts('Track Replies?'));
$defaults['override_verp'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies', NULL, FALSE);
$this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
$defaults['url_tracking'] = TRUE;
$this->add('checkbox', 'open_tracking', ts('Track Opens?'));
//$this->add('checkbox', 'open_tracking', ts('Track Opens?'), '', array('value' => '1'), array('checked' => 'checked'));
$defaults['open_tracking'] = TRUE;
$this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
$defaults['forward_replies'] = FALSE;
$this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
$defaults['auto_responder'] = FALSE;
$this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'), TRUE);
// End
// From email address and reply to options
// Start
$options = array();
// this seems so hacky, not sure what we are doing here and why. Need to investigate and fix
$session->getVars($options, "CRM_Mailing_Controller_Send_{$this->controller->_key}");
$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
if (empty($fromEmailAddress)) {
//redirect user to enter from email address.
$url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'group=from_email_address&action=add&reset=1');
$status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
$session->setStatus($status);
} else {
foreach ($fromEmailAddress as $key => $email) {
$fromEmailAddress[$key] = htmlspecialchars($fromEmailAddress[$key]);
}
}
$this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $fromEmailAddress, TRUE);
//echo "<pre>";print_r ($config);echo "</pre>";
//Added code to add custom field as Reply-To on form when it is enabled from Mailer settings
if (isset($config->replyTo) && !empty($config->replyTo) && !CRM_Utils_Array::value('override_verp', $options)) {
$this->add('select', 'reply_to_address', ts('Reply-To'), array('' => '- select -') + $fromEmailAddress);
} elseif (CRM_Utils_Array::value('override_verp', $options)) {
$trackReplies = TRUE;
$this->assign('trackReplies', $trackReplies);
}
// Mailing Header and footer
// Start
$this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
$this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
// End
#@madav getting default header na footer id to tpl
#start
$this->assign('headerId', key(CRM_Mailing_PseudoConstant::component('Header')));
$this->assign('footerId', key(CRM_Mailing_PseudoConstant::component('Footer')));
#end
// Exclude from groups, Innclude/Exclude mailings
// Start
$outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
$outG->setButtonAttributes('add', array('value' => ts('Add >>')));
$outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$mailings = CRM_Mailing_PseudoConstant::completed();
if (!$mailings) {
$mailings = array();
}
$inM =& $this->addElement('advmultiselect', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
$outM =& $this->addElement('advmultiselect', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
$inM->setButtonAttributes('add', array('value' => ts('Add >>')));
$outM->setButtonAttributes('add', array('value' => ts('Add >>')));
$inM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$outM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$this->assign('mailingCount', count($mailings));
// End
$this->addFormRule(array('CRM_Quickbulkemail_Form_QuickBulkEmail', 'formRule'));
// Schedule or send
// Start
//$this->addDateTime('start_date', ts('Schedule Mailing'), FALSE, array('formatType' => 'mailing'));
//$this->addElement('checkbox', 'now', ts('Send Immediately'));
// End
$buttons = array(array('type' => 'next', 'name' => ts('Schedule & Send >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')));
$this->addButtons($buttons);
// export form elements
// $this->assign('elementNames', $this->getRenderableElementNames());
//.........这里部分代码省略.........
示例7: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
//get the context
$context = $this->get('context');
if ($this->_searchBasedMailing) {
$context = 'search';
}
$this->assign('context', $context);
$this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
$hiddenMailingGroup = NULL;
$campaignId = NULL;
//CRM-7362 --add campaigns.
if ($this->_mailingID) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'campaign_id');
$hiddenMailingGroup = CRM_Mailing_BAO_Mailing::hiddenMailingGroup($this->_mailingID);
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
//dedupe on email option
$this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
//get the mailing groups.
$groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
// asort($groups);
if ($hiddenMailingGroup) {
$groups[$hiddenMailingGroup] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title');
}
$mailings = CRM_Mailing_PseudoConstant::completed();
if (!$mailings) {
$mailings = array();
}
// run the groups through a hook so users can trim it if needed
CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
//when the context is search add base group's.
if ($this->_searchBasedMailing) {
//CRM-16600 Include Smart Groups in Unsubscribe list as that matches
//all other practices in CiviMail
$this->add('select', 'baseGroup', ts('Unsubscription Group'), array('' => ts('- select -')) + $groups, TRUE);
}
if (count($groups) <= 10) {
// setting minimum height to 2 since widget looks strange when size (height) is 1
$groupSize = max(count($groups), 2);
} else {
$groupSize = 10;
}
$inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => $groupSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
//as we are having hidden smart group so no need.
if (!$this->_searchBasedMailing) {
$this->addRule('includeGroups', ts('Please select a group to be mailed.'), 'required');
}
$outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => $groupSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
$inG->setButtonAttributes('add', array('value' => ts('Add >>')));
$outG->setButtonAttributes('add', array('value' => ts('Add >>')));
$inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
if (count($mailings) <= 10) {
// setting minimum height to 2 since widget looks strange when size (height) is 1
$mailingSize = max(count($mailings), 2);
} else {
$mailingSize = 10;
}
$inM =& $this->addElement('advmultiselect', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => $mailingSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
$outM =& $this->addElement('advmultiselect', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => $mailingSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
$inM->setButtonAttributes('add', array('value' => ts('Add >>')));
$outM->setButtonAttributes('add', array('value' => ts('Add >>')));
$inM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$outM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$urls = array('' => ts('- select -'), -1 => ts('CiviCRM Search')) + CRM_Contact_Page_CustomSearch::info();
$this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
$buttons = array(array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
$this->addButtons($buttons);
$this->assign('groupCount', count($groups));
$this->assign('mailingCount', count($mailings));
if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search");
}
}
示例8: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
$this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign('additionalParticipant', $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single && $this->_context == 'standalone') {
$this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
}
$eventFieldParams = array('entity' => 'event', 'select' => array('minimumInputLength' => 0), 'api' => array('extra' => array('campaign_id', 'default_role_id', 'event_type_id')));
if ($this->_mode) {
// exclude events which are not monetary when credit card registration is used
$eventFieldParams['api']['params']['is_monetary'] = 1;
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
$element = $this->addEntityRef('event_id', ts('Event'), $eventFieldParams, TRUE);
//frozen the field fix for CRM-4171
if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) {
$element->freeze();
}
}
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id');
}
if (!$campaignId) {
$eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
if ($eventId) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id');
}
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
$this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime'));
if ($this->_id) {
$this->assign('entityID', $this->_id);
}
$this->addSelect('role_id', array('multiple' => TRUE, 'class' => 'huge'), TRUE);
// CRM-4395
$checkCancelledJs = array('onchange' => "return sendNotification( );");
$confirmJS = NULL;
if ($this->_onlinePendingContributionId) {
$cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus());
$cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});");
$participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus());
$contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );");
}
// get the participant status names to build special status array which is used to show notification
// checkbox below participant status select
$participantStatusName = CRM_Event_PseudoConstant::participantStatus();
$notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired');
// get the required status and then implode only ids
$notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses)));
$this->assign('notificationStatusIds', $notificationStatusIds);
$this->_participantStatuses = $statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'create');
// Only show refund status when editing
if ($this->_action & CRM_Core_Action::ADD) {
$pendingRefundStatusId = array_search('Pending refund', $participantStatusName);
if ($pendingRefundStatusId) {
unset($statusOptions[$pendingRefundStatusId]);
}
}
$this->addSelect('status_id', $checkCancelledJs + array('options' => $statusOptions, 'option_url' => 'civicrm/admin/participant_status'), TRUE);
$this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL);
$this->add('text', 'source', ts('Event Source'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
$buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS);
$path = CRM_Utils_System::currentPath();
$excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search');
if (!in_array($path, $excludeForPaths)) {
$buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS);
}
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
//.........这里部分代码省略.........
示例9: buildQuickForm
//.........这里部分代码省略.........
}
} else {
unset($status[CRM_Utils_Array::key('Refunded', $statusName)]);
}
$this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, FALSE);
// add various dates
$this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
if ($this->_online) {
$this->assign('hideCalender', TRUE);
}
$checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
$this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('textarea', 'cancel_reason', ts('Cancellation / Refund Reason'), $attributes['cancel_reason']);
$element = $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL, $recurJs);
if ($this->_online) {
$element->freeze();
}
$totalAmount = NULL;
if (empty($this->_lineItems)) {
$buildPriceSet = FALSE;
$priceSets = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute');
if (!empty($priceSets) && !$this->_ppID) {
$buildPriceSet = TRUE;
}
// don't allow price set for contribution if it is related to participant, or if it is a pledge payment
// and if we already have line items for that participant. CRM-5095
if ($buildPriceSet && $this->_id) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
$pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'id', 'contribution_id');
if ($pledgePaymentId) {
$buildPriceSet = FALSE;
}
if ($participantID = CRM_Utils_Array::value('participant', $componentDetails)) {
$participantLI = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($participantLI)) {
$buildPriceSet = FALSE;
}
}
}
$hasPriceSets = FALSE;
if ($buildPriceSet) {
$hasPriceSets = TRUE;
// CRM-16451: set financial type of 'Price Set' in back office contribution
// instead of selecting manually
$financialTypeIds = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute', 'financial_type_id');
$element = $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value, " . json_encode($financialTypeIds) . ");"));
if ($this->_online && !($this->_action & CRM_Core_Action::UPDATE)) {
$element->freeze();
}
}
$this->assign('hasPriceSets', $hasPriceSets);
$currencyFreeze = FALSE;
if (!($this->_action & CRM_Core_Action::UPDATE)) {
if ($this->_online || $this->_ppID) {
$attributes['total_amount'] = array_merge($attributes['total_amount'], array('READONLY' => TRUE, 'style' => "background-color:#EBECE4"));
$optionTypes = array('1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?'));
$this->addRadio('option_type', NULL, $optionTypes, array(), '<br/>');
$currencyFreeze = TRUE;
}
}
$totalAmount = $this->addMoney('total_amount', ts('Total Amount'), $hasPriceSets ? FALSE : TRUE, $attributes['total_amount'], TRUE, 'currency', NULL, $currencyFreeze);
}
$this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
CRM_Contribute_Form_SoftCredit::buildQuickForm($this);
$js = NULL;
if (!$this->_mode) {
$js = array('onclick' => "return verify( );");
}
$mailingInfo = Civi::settings()->get('mailing_backend');
$this->assign('outBound_option', $mailingInfo['outBound_option']);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
// if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type,
// Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail
if ($this->_id && $this->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) {
if ($totalAmount) {
$totalAmount->freeze();
}
$checkNumber->freeze();
$paymentInstrument->freeze();
$trxnId->freeze();
$financialType->freeze();
}
// if contribution is related to membership or participant freeze Financial Type, Amount
if ($this->_id && isset($this->_values['tax_amount'])) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) {
if ($totalAmount) {
$totalAmount->freeze();
}
$financialType->freeze();
$this->assign('freezeFinancialType', TRUE);
}
}
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
}
示例10: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
$this->_first = TRUE;
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage');
// name
$this->add('text', 'title', ts('Title'), $attributes['title'], TRUE);
$this->add('select', 'contribution_type_id', ts('Contribution Type'), CRM_Contribute_PseudoConstant::contributionType(), TRUE);
//CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
$this->addWysiwyg('intro_text', ts('Introductory Message'), $attributes['intro_text']);
$this->addWysiwyg('footer_text', ts('Footer Message'), $attributes['footer_text']);
// is on behalf of an organization ?
$this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);"));
$required = array('Contact', 'Organization');
$optional = array('Contribution', 'Membership');
$profiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional);
//Check profiles for Organization subtypes
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
foreach ($contactSubType as $type) {
$required = array('Contact', $type);
$subTypeProfiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional);
foreach ($subTypeProfiles as $profileId => $profileName) {
$profiles[$profileId] = $profileName;
}
}
$requiredProfileFields = array('organization_name', 'email');
if (!empty($profiles)) {
foreach ($profiles as $id => $dontCare) {
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($id, $requiredProfileFields);
if (!$validProfile) {
unset($profiles[$id]);
}
}
}
if (empty($profiles)) {
$invalidProfiles = TRUE;
$this->assign('invalidProfiles', $invalidProfiles);
}
$this->add('select', 'onbehalf_profile_id', ts('Organization Profile'), array('' => ts('- select -')) + $profiles);
$options = array();
$options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1);
$options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2);
$this->addGroup($options, 'is_for_organization', ts(''));
$this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']);
// collect goal amount
$this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12));
$this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
// is confirmation page enabled?
$this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?'));
// is this page shareable through social media ?
$this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?'));
// is this page active ?
$this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
// should the honor be enabled
$this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()"));
$this->add('text', 'honor_block_title', ts('Honoree Section Title'), $attributes['honor_block_title']);
$this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), $attributes['honor_block_text']);
// add optional start and end dates
$this->addDateTime('start_date', ts('Start Date'));
$this->addDateTime('end_date', ts('End Date'));
$this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'));
parent::buildQuickForm();
}
示例11: buildQuickForm
/**
* Actually build the components of the form.
*/
public function buildQuickForm()
{
// CRM-16398: If current recurring contribution got > 1 lineitems then make amount field readonly
$amtAttr = array('size' => 20);
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_coid);
if (count($lineItems) > 1) {
$amtAttr += array('readonly' => TRUE);
}
$this->addMoney('amount', ts('Recurring Contribution Amount'), TRUE, $amtAttr, TRUE, 'currency', $this->_subscriptionDetails->currency, TRUE);
$this->add('text', 'installments', ts('Number of Installments'), array('size' => 20), FALSE);
if ($this->_donorEmail) {
$this->add('checkbox', 'is_notify', ts('Notify Contributor?'));
}
if (CRM_Core_Permission::check('edit contributions')) {
CRM_Campaign_BAO_Campaign::addCampaign($this, $this->_subscriptionDetails->campaign_id);
}
if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($this->contributionRecurID)) {
$this->addEntityRef('financial_type_id', ts('Financial Type'), array('entity' => 'FinancialType'), TRUE);
}
$type = 'next';
if ($this->_selfService) {
$type = 'submit';
}
// define the buttons
$this->addButtons(array(array('type' => $type, 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例12: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Event');
if ($this->_eventType) {
$this->assign('customDataSubType', $this->_eventType);
}
$this->assign('entityId', $this->_id);
$this->_first = TRUE;
$this->applyFilter('__ALL__', 'trim');
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
if ($this->_isTemplate) {
$this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], TRUE);
}
if ($this->_action & CRM_Core_Action::ADD) {
$eventTemplates = CRM_Event_PseudoConstant::eventTemplates();
if (CRM_Utils_System::isNull($eventTemplates)) {
$this->assign('noEventTemplates', TRUE);
} else {
$this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, FALSE, array('onchange' => "reloadWindow( this.value );"));
}
}
// add event title, make required if this is not a template
$this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate);
$event = CRM_Core_OptionGroup::values('event_type');
$this->add('select', 'event_type_id', ts('Event Type'), array('' => ts('- select -')) + $event, TRUE, array('onChange' => "buildCustomData( 'Event', this.value );"));
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'campaign_id');
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
$participantRole = CRM_Core_OptionGroup::values('participant_role');
$this->add('select', 'default_role_id', ts('Participant Role'), $participantRole, TRUE);
$participantListing = CRM_Core_OptionGroup::values('participant_listing');
$this->add('select', 'participant_listing_id', ts('Participant Listing'), array('' => ts('Disabled')) + $participantListing, FALSE);
$this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']);
$this->addWysiwyg('description', ts('Complete Description'), $attributes['event_description']);
$this->addElement('checkbox', 'is_public', ts('Public Event?'));
$this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?'));
$this->addElement('checkbox', 'is_map', ts('Include Map to Event Location?'));
$this->addDateTime('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('end_date', ts('End Date / Time'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {show('id-waitlist','table-row'); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {hide('id-event_full','table-row'); hide('id-waitlist','table-row'); hide('id-waitlist-text','table-row'); return;}"));
$this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger');
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) {
$this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);"));
$this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']);
}
$this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']);
$this->addElement('checkbox', 'is_active', ts('Is this Event Active?'));
$this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule'));
parent::buildQuickForm();
}
示例13: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$button = ts('Delete');
if ($this->_action & CRM_Core_Action::RENEW) {
$button = ts('Restore');
}
$this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (!$this->_single && !empty($this->_contactIds)) {
$withArray = array();
foreach ($this->_contactIds as $contactId) {
$withDisplayName = self::_getDisplayNameById($contactId);
$withArray[] = "\"{$withDisplayName}\" ";
}
$this->assign('with', implode(', ', $withArray));
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//build other activity links
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );"));
//freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
foreach ($this->_fields as $field => $values) {
if (CRM_Utils_Array::value($field, $this->_fields)) {
$attribute = NULL;
if (CRM_Utils_Array::value('attributes', $values)) {
$attribute = $values['attributes'];
}
$required = FALSE;
if (CRM_Utils_Array::value('required', $values)) {
$required = TRUE;
}
if ($values['type'] == 'wysiwyg') {
$this->addWysiwyg($field, $values['label'], $attribute, $required);
} else {
$this->add($values['type'], $field, $values['label'], $attribute, $required);
}
}
}
//CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$this->add('select', 'engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
$this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
}
$this->assign('buildEngagementLevel', $buildEngagementLevel);
// check for survey activity
$this->_isSurveyActivity = FALSE;
if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
if ($this->_isSurveyActivity) {
$surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
$responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
if ($responseOptions) {
$this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
}
$surveyTitle = NULL;
if ($surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
}
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
// this option should be available only during add mode
if ($this->_action != CRM_Core_Action::UPDATE) {
$this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
}
$this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
//add followup date
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
//autocomplete url
$dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE);
$this->assign('dataUrl', $dataUrl);
//tokeninput url
$tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", FALSE, NULL, FALSE);
$this->assign('tokenUrl', $tokenUrl);
$admin = CRM_Core_Permission::check('administer CiviCRM');
//allow to edit source contact field field if context is civicase.
if ($this->_context == 'caseActivity') {
$admin = TRUE;
}
$this->assign('admin', $admin);
$sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], NULL, $admin);
$this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
CRM_Contact_Form_NewContact::buildQuickForm($this);
//.........这里部分代码省略.........
示例14: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Event');
if ($this->_eventType) {
$this->assign('customDataSubType', $this->_eventType);
}
$this->assign('entityId', $this->_id);
$this->_first = TRUE;
$this->applyFilter('__ALL__', 'trim');
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
if ($this->_isTemplate) {
$this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], TRUE);
}
if ($this->_action & CRM_Core_Action::ADD) {
$eventTemplates = CRM_Event_PseudoConstant::eventTemplates();
if (CRM_Utils_System::isNull($eventTemplates) && !$this->_isTemplate) {
$url = CRM_Utils_System::url('civicrm/admin/eventTemplate', array('reset' => 1));
CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the <a href="%1">Event Templates</a> feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info');
}
if (!CRM_Utils_System::isNull($eventTemplates)) {
$this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, FALSE, array('class' => 'crm-select2 huge'));
}
// Make sure this form redirects properly
$this->preventAjaxSubmit();
}
// add event title, make required if this is not a template
$this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate);
$this->addSelect('event_type_id', array('onChange' => "CRM.buildCustomData( 'Event', this.value );"), TRUE);
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'campaign_id');
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
$this->addSelect('default_role_id', array(), TRUE);
$this->addSelect('participant_listing_id', array('placeholder' => ts('Disabled'), 'option_url' => NULL));
$this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']);
$this->add('wysiwyg', 'description', ts('Complete Description'), $attributes['event_description']);
$this->addElement('checkbox', 'is_public', ts('Public Event'));
$this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?'));
$this->addElement('checkbox', 'is_map', ts('Include Map to Event Location'));
$this->addDateTime('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('end_date', ts('End Date / Time'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}"));
$this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger');
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$waitlist = 0;
if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) {
$this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);"));
$this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']);
$waitlist = 1;
}
$this->assign('waitlist', $waitlist);
$this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']);
$this->addElement('checkbox', 'is_active', ts('Is this Event Active?'));
$this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule'));
parent::buildQuickForm();
}
示例15: buildQuickForm
//.........这里部分代码省略.........
unset($selMemTypeOrg[0], $selOrgMemType[0][0]);
}
//sort membership organization and type, CRM-6099
natcasesort($selMemTypeOrg);
foreach ($selOrgMemType as $index => $orgMembershipType) {
natcasesort($orgMembershipType);
$selOrgMemType[$index] = $orgMembershipType;
}
$memTypeJs = array('onChange' => "buildMaxRelated(this.value,true); CRM.buildCustomData('Membership', this.value);");
if (!empty($this->_recurPaymentProcessors)) {
$memTypeJs['onChange'] = "" . $memTypeJs['onChange'] . "buildAutoRenew(this.value, null, '{$this->_mode}');";
}
$this->add('text', 'max_related', ts('Max related'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'max_related'));
$sel =& $this->addElement('hierselect', 'membership_type_id', ts('Membership Organization and Type'), $memTypeJs);
$sel->setOptions(array($selMemTypeOrg, $selOrgMemType));
$elements = array();
if ($sel) {
$elements[] = $sel;
}
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::ADD) {
$this->add('text', 'num_terms', ts('Number of Terms'), array('size' => 6));
}
$this->addDate('join_date', ts('Member Since'), FALSE, array('formatType' => 'activityDate'));
$this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDate'));
$endDate = $this->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDate'));
if ($endDate) {
$elements[] = $endDate;
}
$this->add('text', 'source', ts('Source'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'source'));
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'campaign_id');
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
if (!$this->_mode) {
$this->add('select', 'status_id', ts('Membership Status'), array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'));
$statusOverride = $this->addElement('checkbox', 'is_override', ts('Status Override?'), NULL, array('onClick' => 'showHideMemberStatus()'));
if ($statusOverride) {
$elements[] = $statusOverride;
}
$this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?'));
$this->add('text', 'total_amount', ts('Amount'));
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
$this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
$this->add('text', 'trxn_id', ts('Transaction ID'));
$this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id'));
$allowStatuses = array();
$statuses = CRM_Contribute_PseudoConstant::contributionStatus();
if ($this->_onlinePendingContributionId) {
$statusNames = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach ($statusNames as $val => $name) {
if (in_array($name, array('In Progress', 'Overdue'))) {
continue;
}
$allowStatuses[$val] = $statuses[$val];
}
} else {
$allowStatuses = $statuses;
}
$this->add('select', 'contribution_status_id', ts('Payment Status'), $allowStatuses);
$this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
} else {
//add field for amount to allow an amount to be entered that differs from minimum
$this->add('text', 'total_amount', ts('Amount'));
}
$this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action));
$this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
$this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
$this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, array('onclick' => "showEmailOptions()"));
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
$this->add('textarea', 'receipt_text', ts('Receipt Message'));
// Retrieve the name and email of the contact - this will be the TO for receipt email
if ($this->_contactID) {
list($this->_memberDisplayName, $this->_memberEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$this->assign('emailExists', $this->_memberEmail);
$this->assign('displayName', $this->_memberDisplayName);
}
$isRecur = FALSE;
if ($this->_action & CRM_Core_Action::UPDATE) {
$recurContributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id');
if ($recurContributionId && !CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id)) {
$isRecur = TRUE;
if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) {
$this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}"));
}
foreach ($elements as $elem) {
$elem->freeze();
}
}
}
$this->assign('isRecur', $isRecur);
$this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this);
$mailingInfo = Civi::settings()->get('mailing_backend');
$this->assign('isEmailEnabledForSite', $mailingInfo['outBound_option'] != 2);
parent::buildQuickForm();
}