本文整理汇总了PHP中CRM_Core_BAO_Preferences::mailingPreferences方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Preferences::mailingPreferences方法的具体用法?PHP CRM_Core_BAO_Preferences::mailingPreferences怎么用?PHP CRM_Core_BAO_Preferences::mailingPreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Preferences
的用法示例。
在下文中一共展示了CRM_Core_BAO_Preferences::mailingPreferences方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
/**
* retrieve a mailer to send any mail from the applciation
*
* @param
* @access private
* @return object
*/
static function &getMailer()
{
if (!isset(self::$_mail)) {
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
if (defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL) {
require_once 'CRM/Mailing/BAO/Spool.php';
self::$_mail = new CRM_Mailing_BAO_Spool();
} elseif ($mailingInfo['outBound_option'] == 0) {
if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) {
CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
$params['port'] = $mailingInfo['smtpPort'] ? $mailingInfo['smtpPort'] : 25;
if ($mailingInfo['smtpAuth']) {
require_once 'CRM/Utils/Crypt.php';
$params['username'] = $mailingInfo['smtpUsername'];
$params['password'] = CRM_Utils_Crypt::decrypt($mailingInfo['smtpPassword']);
$params['auth'] = true;
} else {
$params['auth'] = false;
}
// set the localhost value, CRM-3153
$params['localhost'] = $_SERVER['SERVER_NAME'];
self::$_mail =& Mail::factory('smtp', $params);
} elseif ($mailingInfo['outBound_option'] == 1) {
if ($mailingInfo['sendmail_path'] == '' || !$mailingInfo['sendmail_path']) {
CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the Sendmail Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['sendmail_path'] = $mailingInfo['sendmail_path'];
$params['sendmail_args'] = $mailingInfo['sendmail_args'];
self::$_mail =& Mail::factory('sendmail', $params);
} else {
CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or SendMail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
}
return self::$_mail;
}
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->applyFilter('__ALL__', 'trim');
$this->addDate('renewal_date', ts('Date Renewal Entered'), false, array('formatType' => 'activityDate'));
if (!$this->_mode) {
$this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), null, array('onclick' => "checkPayment();"));
require_once 'CRM/Contribute/PseudoConstant.php';
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$this->add('text', 'total_amount', ts('Amount'));
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
$this->add('select', 'payment_instrument_id', ts('Paid By'), 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'));
$this->add('select', 'contribution_status_id', ts('Payment Status'), CRM_Contribute_PseudoConstant::contributionStatus());
$this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
}
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);"));
$this->add('textarea', 'receipt_text_renewal', ts('Renewal Message'));
if ($this->_mode) {
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::buildCreditCard($this, true);
}
require_once 'CRM/Contact/BAO/Contact/Location.php';
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$this->assign('email', $this->_contributorEmail);
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
$this->assign('outBound_option', $mailingInfo['outBound_option']);
$this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule'));
}
示例3: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
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') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
}
$showAdditionalInfo = false;
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
//fix to load honoree pane on edit.
$defaults = array();
if ($this->_honorID) {
$defaults['hidden_Honoree'] = 1;
}
$paneNames = array('Honoree Information' => 'Honoree', '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 || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) {
$showAdditionalInfo = true;
$allPanes[$name]['open'] = 'true';
}
eval('CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $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( );");
$element =& $this->add('text', 'amount', ts('Total Pledge Amount'), array_merge($attributes['pledge_amount'], $js), true);
$this->addRule('amount', ts('Please enter a valid monetary amount.'), 'money');
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['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 => $val));
}
$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", 'READONLY'));
//add various dates
if (!$this->_id || $this->_isPending) {
$this->addDate('create_date', ts('Pledge Made'));
$this->addDate('start_date', ts('Payments Start'));
}
if ($this->_id && !$this->_isPending) {
$eachPaymentAmount = floor($this->_values['amount'] / $this->_values['installments']);
$this->assign("eachPaymentAmount", $eachPaymentAmount);
$this->assign("hideCalender", true);
}
if (CRM_Utils_Array::value('status_id', $this->_values) != array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), null, array('onclick' => "return showHideByValue('is_acknowledge','','acknowledgeDate','table-row','radio',true);"));
}
$this->addDate('acknowledge_date', ts('Acknowledgment Date'));
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true);
$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);
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
//.........这里部分代码省略.........
示例4: buildQuickForm
//.........这里部分代码省略.........
*/
static function buildQuickForm(&$form)
{
if ($form->_eventId) {
$form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
if ($form->_isPaidEvent) {
$form->addElement('hidden', 'hidden_feeblock', 1);
}
// make sure this is for backoffice registration.
if ($form->getName() == 'Participant') {
require_once "CRM/Event/BAO/Participant.php";
$eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId);
$form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg'));
}
}
if ($form->_pId) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) {
$form->_online = true;
}
}
if ($form->_isPaidEvent) {
require_once "CRM/Event/BAO/Event.php";
$params = array('id' => $form->_eventId);
CRM_Event_BAO_Event::retrieve($params, $event);
//retrieve custom information
$form->_values = array();
require_once "CRM/Event/Form/Registration/Register.php";
CRM_Event_Form_Registration::initPriceSet($form, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($form, true, $form->_discountId);
$lineItem = array();
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
$lineItem[] = $form->_values['line_items'];
}
$form->assign('lineItem', empty($lineItem) ? false : $lineItem);
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$discounts[$key] = $value['name'];
}
$element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, false, array('onchange' => "buildFeeBlock( {$form->_eventId}, this.value );"));
if ($form->_online) {
$element->freeze();
}
}
if ($form->_mode) {
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::buildCreditCard($form, true);
} else {
if (!$form->_mode) {
$form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), null, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"));
require_once 'CRM/Contribute/PseudoConstant.php';
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->addDate('receive_date', ts('Received'), false, array('formatType' => 'activityDate'));
$form->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), false, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
// don't show transaction id in batch update mode
$path = CRM_Utils_System::currentPath();
$form->assign('showTransactionId', false);
if ($path != 'civicrm/contact/search/basic') {
$form->add('text', 'trxn_id', ts('Transaction ID'));
$form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'));
$form->assign('showTransactionId', true);
}
$allowStatuses = array();
$statuses = CRM_Contribute_PseudoConstant::contributionStatus();
if ($form->get('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;
}
$form->add('select', 'contribution_status_id', ts('Payment Status'), $allowStatuses);
$form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
}
}
} else {
$form->add('text', 'amount', ts('Event Fee(s)'));
}
$form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId'));
$form->assign("paid", $form->_isPaidEvent);
$form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);"));
$form->add('textarea', 'receipt_text', ts('Confirmation Message'));
// Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone)
if ($form->_context != 'standalone') {
if ($form->_contactID) {
list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactID);
$form->assign('email', $form->_contributorEmail);
} else {
//show email block for batch update for event
$form->assign('batchEmail', true);
}
}
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
$form->assign('outBound_option', $mailingInfo['outBound_option']);
}
示例5: validOutBoundMail
/**
* Get the Active outBound email
* @return boolean true if valid outBound email configuration found, false otherwise
* @access public
* @static
*/
static function validOutBoundMail()
{
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
if ($mailingInfo['outBound_option'] == 0) {
if (!isset($mailingInfo['smtpServer']) || $mailingInfo['smtpServer'] == '' || $mailingInfo['smtpServer'] == 'YOUR SMTP SERVER' || $mailingInfo['smtpAuth'] && ($mailingInfo['smtpUsername'] == '' || $mailingInfo['smtpPassword'] == '')) {
return false;
}
return true;
} else {
if ($mailingInfo['outBound_option'] == 1) {
if (!$mailingInfo['sendmail_path'] || !$mailingInfo['sendmail_args']) {
return false;
}
return true;
}
}
return false;
}
示例6: 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', 'Membership');
$this->assign('customDataSubType', $this->_memType);
$this->assign('entityID', $this->_id);
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') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
}
$selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
$dao =& new CRM_Member_DAO_MembershipType();
$dao->find();
while ($dao->fetch()) {
if ($dao->is_active) {
if ($this->_mode && !$dao->minimum_fee) {
continue;
} else {
if (!CRM_Utils_Array::value($dao->member_of_contact_id, $selMemTypeOrg)) {
$selMemTypeOrg[$dao->member_of_contact_id] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->member_of_contact_id, 'display_name', 'id');
$selOrgMemType[$dao->member_of_contact_id][0] = ts('- select -');
}
if (!CRM_Utils_Array::value($dao->id, $selOrgMemType[$dao->member_of_contact_id])) {
$selOrgMemType[$dao->member_of_contact_id][$dao->id] = $dao->name;
}
}
}
}
// show organization by default, if only one organization in
// the list
if (count($selMemTypeOrg) == 2) {
unset($selMemTypeOrg[0], $selOrgMemType[0][0]);
}
$sel =& $this->addElement('hierselect', 'membership_type_id', ts('Membership Organization and Type'), array('onChange' => "buildCustomData( 'Membership', this.value ); setPaymentBlock( this.value );"));
$sel->setOptions(array($selMemTypeOrg, $selOrgMemType));
$this->applyFilter('__ALL__', 'trim');
$this->addDate('join_date', ts('Join Date'), false, array('formatType' => 'activityDate'));
$this->addDate('start_date', ts('Start Date'), false, array('formatType' => 'activityDate'));
$this->addDate('end_date', ts('End Date'), false, array('formatType' => 'activityDate'));
$this->add('text', 'source', ts('Source'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'source'));
if (!$this->_mode) {
$this->add('select', 'status_id', ts('Membership Status'), array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus());
$this->addElement('checkbox', 'is_override', ts('Status Override?'), null, array('onClick' => 'showHideMemberStatus()'));
$this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?'), null, array('onclick' => "return showHideByValue('record_contribution','','recordContribution','table-row','radio',false);"));
require_once 'CRM/Contribute/PseudoConstant.php';
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$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' => 'activityDate'));
$this->add('select', 'payment_instrument_id', ts('Paid By'), 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'));
}
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);"));
$this->add('textarea', 'receipt_text_signup', ts('Receipt Message'));
if ($this->_mode) {
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::buildCreditCard($this, true);
}
// Retrieve the name and email of the contact - this will be the TO for receipt email
if ($this->_contactID) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$this->assign('emailExists', $this->_contributorEmail);
}
$this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this);
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
$this->assign('outBound_option', $mailingInfo['outBound_option']);
parent::buildQuickForm();
}
示例7: buildQuickForm
//.........这里部分代码省略.........
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Contribution');
$this->assign('customDataSubType', $this->_contributionType);
$this->assign('entityID', $this->_id);
if ($this->_context == 'standalone') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution');
$element =& $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true, array('onChange' => "buildCustomData( 'Contribution', this.value );"));
if ($this->_online) {
$element->freeze();
}
if (!$this->_mode) {
$element =& $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), false, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
if ($this->_online) {
$element->freeze();
}
}
$element =& $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']);
if ($this->_online) {
$element->freeze();
} else {
$this->addRule('trxn_id', ts('This Transaction ID already exists in the database. Include the account number for checks.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id'));
}
//add receipt for offline contribution
$this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'), null, array('onclick' => "return showHideByValue('is_email_receipt','','receiptDate','table-row','radio',true);"));
$status = CRM_Contribute_PseudoConstant::contributionStatus();
// supressing contribution statuses that are NOT relevant to pledges (CRM-5169)
if ($this->_ppID) {
foreach (array('Cancelled', 'Failed', 'In Progress') as $supress) {
unset($status[CRM_Utils_Array::key($supress, $status)]);
}
}
$this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, false, array('onClick' => "if (this.value != 3) status(); else return false", 'onChange' => "return showHideByValue('contribution_status_id','3','cancelInfo','table-row','select',false);"));
// add various dates
$this->addDate('receive_date', ts('Received'), false, array('formatType' => 'activityDate'));
if ($this->_online) {
$this->assign("hideCalender", true);
}
$element =& $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
if ($this->_online) {
$element->freeze();
}
$this->addDate('receipt_date', ts('Receipt Date'), false, array('formatType' => 'activityDate'));
$this->addDate('cancel_date', ts('Cancelled Date'), false, array('formatType' => 'activityDate'));
$this->add('textarea', 'cancel_reason', ts('Cancellation Reason'), $attributes['cancel_reason']);
$element =& $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors);
if ($this->_online) {
$element->freeze();
}
if (empty($this->_lineItems)) {
require_once 'CRM/Price/BAO/Set.php';
$priceSets = CRM_Price_BAO_Set::getAssoc(false, 'Contribution');
$hasPriceSets = false;
if (!empty($priceSets) && !$this->_ppID) {
$hasPriceSets = true;
$element =& $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, null, array('onchange' => "buildAmount( this.value );"));
if ($this->_online) {
$element->freeze();
}
}
$this->assign('hasPriceSets', $hasPriceSets);
$element =& $this->add('text', 'total_amount', ts('Total Amount'), $attributes['total_amount'], $hasPriceSets ? false : true);
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
if ($this->_online || $this->_ppID) {
$element->freeze();
}
}
$element =& $this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
if ($this->_online) {
$element->freeze();
}
$dataUrl = CRM_Utils_System::url("civicrm/ajax/contactlist", "reset=1&context=softcredit&id={$this->_id}", false, null, false);
$this->assign('dataUrl', $dataUrl);
$this->addElement('text', 'soft_credit_to', ts('Soft Credit To'));
$this->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id'));
if (CRM_Utils_Array::value('pcp_made_through_id', $defaults) && $this->_action & CRM_Core_Action::UPDATE) {
$ele = $this->addElement('select', 'pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::pcPage());
$ele->freeze();
$this->addElement('checkbox', 'pcp_display_in_roll', ts('Honor Roll?'), null, array('onclick' => "return showHideByValue('pcp_display_in_roll','','softCreditInfo','table-row','radio',false);"));
$this->addElement('text', 'pcp_roll_nickname', ts('Nickname'));
$this->addElement('textarea', 'pcp_personal_note', ts('Personal Note'));
}
$js = null;
if (!$this->_mode) {
$js = array('onclick' => "return verify( );");
}
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
$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'))));
$this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
}
示例8: buildQuickForm
//.........这里部分代码省略.........
WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
$recurMembershipTypes = CRM_Core_DAO::executeQuery($sql);
while ($recurMembershipTypes->fetch()) {
$autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew;
foreach (array('id', 'auto_renew', 'duration_unit', 'duration_interval') as $fld) {
$this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->{$fld};
}
}
}
$memTypeJs = array('onChange' => "buildCustomData( 'Membership', this.value ); buildAutoRenew(this.value, null );");
}
}
}
$allowAutoRenew = false;
if ($this->_mode && !empty($recurProcessor)) {
$allowAutoRenew = true;
}
$this->assign('allowAutoRenew', $allowAutoRenew);
$this->assign('autoRenewOptions', json_encode($autoRenew));
$this->assign('recurProcessor', json_encode($recurProcessor));
$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');
$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'));
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?'));
require_once 'CRM/Contribute/PseudoConstant.php';
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$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' => 'activityDate'));
$this->add('select', 'payment_instrument_id', ts('Paid By'), 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'));
}
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);"));
$this->add('textarea', 'receipt_text_signup', ts('Receipt Message'));
if ($this->_mode) {
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true, array('onChange' => "buildAutoRenew( null, this.value );"));
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::buildCreditCard($this, true);
}
// Retrieve the name and email of the contact - this will be the TO for receipt email
if ($this->_contactID) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
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) {
$isRecur = true;
require_once 'CRM/Member/BAO/Membership.php';
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);
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
$this->assign('outBound_option', $mailingInfo['outBound_option']);
parent::buildQuickForm();
}