本文整理汇总了PHP中CRM_Core_PseudoConstant::paymentProcessor方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::paymentProcessor方法的具体用法?PHP CRM_Core_PseudoConstant::paymentProcessor怎么用?PHP CRM_Core_PseudoConstant::paymentProcessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::paymentProcessor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('action', $this->_action);
$this->assign('context', $this->_context);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
CRM_Pledge_Page_Tab::setContext();
if ($this->_action & CRM_Core_Action::UPDATE) {
$this->edit();
// set page title
CRM_Contact_Page_View::setTitle($this->_contactId);
} else {
$pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
$paymentDetails = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId);
$this->assign('rows', $paymentDetails);
$this->assign('pledgeId', $pledgeId);
$this->assign('contactId', $this->_contactId);
// check if we can process credit card contribs
$processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$this->assign('newCredit', TRUE);
} else {
$this->assign('newCredit', FALSE);
}
// check is the user has view/edit signer permission
$permission = 'view';
if (CRM_Core_Permission::check('edit pledges')) {
$permission = 'edit';
}
$this->assign('permission', $permission);
}
return parent::run();
}
示例2: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
require_once 'CRM/Utils/Money.php';
// do u want to allow a free form text field for amount
$this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), null, array('onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );"));
$this->add('text', 'min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8));
$this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$this->add('text', 'max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8));
$this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$default = array();
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
// label
$this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'));
// value
$this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'));
$this->addRule("value[{$i}]", ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
// default
$default[] = $this->createElement('radio', null, null, null, $i);
}
$this->addGroup($default, 'default');
$this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), null, array('onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );"));
$this->addElement('checkbox', 'is_monetary', ts('Execute real-time monetary transactions'));
$paymentProcessor =& CRM_Core_PseudoConstant::paymentProcessor();
if (count($paymentProcessor)) {
$this->assign('paymentProcessor', $paymentProcessor);
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), array('' => ts('- select -')) + $paymentProcessor);
require_once "CRM/Contribute/BAO/ContributionPage.php";
//check if selected payment processor supports recurring payment
if (CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($this->_id)) {
$this->addElement('checkbox', 'is_recur', ts('Recurring contributions'), null, array('onclick' => "return showHideByValue('is_recur',true,'recurFields','table-row','radio',false);"));
require_once 'CRM/Core/OptionGroup.php';
$this->addCheckBox('recur_frequency_unit', ts('Supported recurring units'), CRM_Core_OptionGroup::values('recur_frequency_units', false, false, false, null, 'name'), null, null, null, null, array(' ', ' ', ' ', '<br/>'));
$this->addElement('checkbox', 'is_recur_interval', ts('Support recurring intervals'));
}
// add pay later options
$this->addElement('checkbox', 'is_pay_later', ts('Pay later option'), null, array('onclick' => "payLater(this);"));
$this->addElement('textarea', 'pay_later_text', ts('Pay later label'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_text'), false);
$this->addElement('textarea', 'pay_later_receipt', ts('Pay later instructions'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_receipt'), false);
// add price set fields
require_once 'CRM/Price/BAO/Set.php';
$this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + CRM_Price_BAO_Set::getAssoc(false, 'Contribution'), null, array('onchange' => "showHideAmountBlock( this.value, 'price_set_id' );"));
//CiviPledge fields.
$config =& CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents)) {
$this->assign('civiPledge', true);
require_once 'CRM/Core/OptionGroup.php';
$this->addElement('checkbox', 'is_pledge_active', ts('Pledges'), null, array('onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);"));
$this->addCheckBox('pledge_frequency_unit', ts('Supported pledge frequencies'), CRM_Core_OptionGroup::values("recur_frequency_units", false, false, false, null, 'name'), null, null, null, null, array(' ', ' ', ' ', '<br/>'));
$this->addElement('checkbox', 'is_pledge_interval', ts('Allow frequency intervals'));
$this->addElement('text', 'initial_reminder_day', ts('Send payment reminder'), array('size' => 3));
$this->addElement('text', 'max_reminders', ts('Send up to'), array('size' => 3));
$this->addElement('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3));
}
$this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Amount', 'formRule'), $this);
parent::buildQuickForm();
}
示例3: run
/**
* This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->preProcess();
// check if we can process credit card membership
$processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$this->assign('newCredit', TRUE);
$this->_isPaymentProcessor = TRUE;
} else {
$this->assign('newCredit', FALSE);
$this->_isPaymentProcessor = FALSE;
}
// Only show credit card membership signup if user has CiviContribute permission
if (CRM_Core_Permission::access('CiviContribute')) {
$this->_accessContribution = TRUE;
$this->assign('accessContribution', TRUE);
} else {
$this->_accessContribution = FALSE;
$this->assign('accessContribution', FALSE);
}
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
} elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
$this->setContext();
$this->edit();
} else {
$this->setContext();
$this->browse();
}
return parent::run();
}
示例4: preProcess
public function preProcess()
{
//custom data related code
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', false);
if ($this->_cdType) {
$this->assign('cdType', true);
return CRM_Custom_Form_CustomData::preProcess($this);
}
// action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
// check for edit permission
if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
if ($this->_id) {
$this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id");
}
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
if ($this->_mode) {
$this->assign('membershipMode', $this->_mode);
$this->_paymentProcessor = array('billing_mode' => 1);
$validProcessors = array();
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
foreach ($processors as $ppID => $label) {
require_once 'CRM/Core/BAO/PaymentProcessor.php';
require_once 'CRM/Core/Payment.php';
$paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
continue;
} else {
if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
continue;
} else {
$paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
$error = $paymentObject->checkConfig();
if (empty($error)) {
$validProcessors[$ppID] = $label;
}
$paymentObject = null;
}
}
}
if (empty($validProcessors)) {
CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
} else {
$this->_processors = $validProcessors;
}
// also check for billing information
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
$this->assign('bltID', $this->_bltID);
$this->_fields = array();
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::setCreditCardFields($this);
// this required to show billing block
$this->assign_by_ref('paymentProcessor', $paymentProcessor);
$this->assign('hidePayPalExpress', true);
}
//check whether membership status present or not
if ($this->_action & CRM_Core_Action::ADD) {
CRM_Member_BAO_Membership::statusAvilability($this->_contactID);
}
// when custom data is included in this page
if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
CRM_Custom_Form_Customdata::preProcess($this);
CRM_Custom_Form_Customdata::buildQuickForm($this);
CRM_Custom_Form_Customdata::setDefaultValues($this);
}
// CRM-4395, get the online pending contribution id.
$this->_onlinePendingContributionId = null;
if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
require_once 'CRM/Contribute/BAO/Contribution.php';
$this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
}
$this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
parent::preProcess();
}
示例5: buildMembershipBlock
/**
* Build Membership Block in Contribution Pages.
*
* @param CRM_Core_Form $form
* Form object.
* @param int $pageID
* Unused?.
* @param int $cid
* Contact checked for having a current membership for a particular membership.
* @param bool $formItems
* @param int $selectedMembershipTypeID
* Selected membership id.
* @param bool $thankPage
* Thank you page.
* @param null $isTest
*
* @return bool
* Is this a separate membership payment
*
*/
public static function buildMembershipBlock(&$form, $pageID, $cid, $formItems = FALSE, $selectedMembershipTypeID = NULL, $thankPage = FALSE, $isTest = NULL)
{
$separateMembershipPayment = FALSE;
if ($form->_membershipBlock) {
$form->_currentMemberships = array();
$membershipBlock = $form->_membershipBlock;
$membershipTypeIds = $membershipTypes = $radio = array();
$membershipPriceset = !empty($form->_priceSetId) && $form->_useForMember ? TRUE : FALSE;
$allowAutoRenewMembership = $autoRenewOption = FALSE;
$autoRenewMembershipTypeOptions = array();
$paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
$separateMembershipPayment = CRM_Utils_Array::value('is_separate_payment', $membershipBlock);
if ($membershipPriceset) {
foreach ($form->_priceSet['fields'] as $pField) {
if (empty($pField['options'])) {
continue;
}
foreach ($pField['options'] as $opId => $opValues) {
if (empty($opValues['membership_type_id'])) {
continue;
}
$membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id'];
}
}
} elseif (!empty($membershipBlock['membership_types'])) {
$membershipTypeIds = explode(',', $membershipBlock['membership_types']);
}
if (!empty($membershipTypeIds)) {
//set status message if wrong membershipType is included in membershipBlock
if (isset($form->_mid) && !$membershipPriceset) {
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $form->_mid, 'membership_type_id');
if (!in_array($membershipTypeID, $membershipTypeIds)) {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Invalid Membership'), 'error');
}
}
$membershipTypeValues = self::buildMembershipTypeValues($form, $membershipTypeIds);
$form->_membershipTypeValues = $membershipTypeValues;
$endDate = NULL;
foreach ($membershipTypeIds as $value) {
$memType = $membershipTypeValues[$value];
if ($selectedMembershipTypeID != NULL) {
if ($memType['id'] == $selectedMembershipTypeID) {
$form->assign('minimum_fee', CRM_Utils_Array::value('minimum_fee', $memType));
$form->assign('membership_name', $memType['name']);
if (!$thankPage && $cid) {
$membership = new CRM_Member_DAO_Membership();
$membership->contact_id = $cid;
$membership->membership_type_id = $memType['id'];
if ($membership->find(TRUE)) {
$form->assign('renewal_mode', TRUE);
$memType['current_membership'] = $membership->end_date;
$form->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
}
}
$membershipTypes[] = $memType;
}
} elseif ($memType['is_active']) {
$javascriptMethod = NULL;
$allowAutoRenewOpt = (int) $memType['auto_renew'];
if (is_array($form->_paymentProcessors)) {
foreach ($form->_paymentProcessors as $id => $val) {
if (!$val['is_recur']) {
$allowAutoRenewOpt = 0;
continue;
}
}
}
$javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );");
$autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $allowAutoRenewOpt * CRM_Utils_Array::value($value, CRM_Utils_Array::value('auto_renew', $form->_membershipBlock));
if ($allowAutoRenewOpt) {
$allowAutoRenewMembership = TRUE;
}
//add membership type.
$radio[$memType['id']] = $form->createElement('radio', NULL, NULL, NULL, $memType['id'], $javascriptMethod);
if ($cid) {
$membership = new CRM_Member_DAO_Membership();
$membership->contact_id = $cid;
$membership->membership_type_id = $memType['id'];
//show current membership, skip pending and cancelled membership records,
//because we take first membership record id for renewal
//.........这里部分代码省略.........
示例6: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'name'), TRUE);
$this->addRule('name', ts('A membership type with this name already exists. Please select another name.'), 'objectExists', array('CRM_Member_DAO_MembershipType', $this->_id));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'description'));
$this->add('text', 'minimum_fee', ts('Minimum Fee'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'minimum_fee'));
$this->addRule('minimum_fee', ts('Please enter a monetary value for the Minimum Fee.'), 'money');
$this->addElement('select', 'duration_unit', ts('Duration') . ' ', CRM_Core_SelectValues::unitList('duration'), array('onchange' => 'showHidePeriodSettings()'));
//period type
$this->addElement('select', 'period_type', ts('Period Type'), CRM_Core_SelectValues::periodType(), array('onchange' => 'showHidePeriodSettings()'));
$this->add('text', 'duration_interval', ts('Duration Interval'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'duration_interval'));
$memberOrg =& $this->add('text', 'member_org', ts('Membership Organization'), 'size=30 maxlength=120');
//start day
$this->add('date', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_SelectValues::date(NULL, 'M d'), FALSE);
$msgTemplates = CRM_Core_BAO_MessageTemplates::getMessageTemplates(FALSE);
$hasMsgTemplates = FALSE;
if (!empty($msgTemplates)) {
$hasMsgTemplates = TRUE;
}
//Auto-renew Option
$paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
$isAuthorize = FALSE;
$options = array();
$allowAutoRenewMsg = FALSE;
if (is_array($paymentProcessor) && !empty($paymentProcessor)) {
$isAuthorize = TRUE;
$options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
if ($hasMsgTemplates) {
$allowAutoRenewMsg = TRUE;
$autoRenewReminderMsg = $this->add('select', 'autorenewal_msg_id', ts('Auto-renew Reminder Message'), array('' => ts('- select -')) + $msgTemplates);
}
}
$this->addRadio('auto_renew', ts('Auto-renew Option'), $options, array('onclick' => "setReminder(this.value);"));
$this->assign('authorize', $isAuthorize);
$this->assign('allowAutoRenewMsg', $allowAutoRenewMsg);
//rollover day
$this->add('date', 'fixed_period_rollover_day', ts('Fixed Period Rollover Day'), CRM_Core_SelectValues::date(NULL, 'M d'), FALSE);
// required in form rule
$this->add('hidden', 'action', $this->_action);
$this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
if (is_array($relTypeInd)) {
asort($relTypeInd);
}
$memberRel =& $this->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $relTypeInd);
$memberRel->setMultiple(TRUE);
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::memberVisibility());
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'weight'));
$this->add('checkbox', 'is_active', ts('Enabled?'));
if ($hasMsgTemplates) {
$reminderMsg = $this->add('select', 'renewal_msg_id', ts('Renewal Reminder Message'), array('' => ts('- select -')) + $msgTemplates);
}
$this->assign('hasMsgTemplates', $hasMsgTemplates);
$reminderDay =& $this->add('text', 'renewal_reminder_day', ts('Renewal Reminder Day'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'renewal_reminder_day'));
$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
$searchDone = $this->get('searchDone');
if ($searchRows) {
$checkBoxes = array();
$chekFlag = 0;
foreach ($searchRows as $id => $row) {
$checked = '';
if (!$chekFlag) {
$checked = array('checked' => NULL);
$chekFlag++;
}
$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id, $checked);
}
$this->addGroup($checkBoxes, 'contact_check');
$this->assign('searchRows', $searchRows);
}
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $searchDone);
if ($searchDone) {
$searchBtn = ts('Search Again');
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$searchBtn = ts('Change');
} else {
$searchBtn = ts('Search');
}
$membershipRecords = FALSE;
if ($this->_action & CRM_Core_Action::UPDATE) {
$membershipType = new CRM_Member_BAO_Membership();
$membershipType->membership_type_id = $this->_id;
if ($membershipType->find(TRUE)) {
$membershipRecords = TRUE;
$memberRel->freeze();
}
$memberOrg->freeze();
//.........这里部分代码省略.........
示例7: run
/**
* This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->preProcess();
// check if we can process credit card registration
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$this->assign('newCredit', true);
} else {
$this->assign('newCredit', false);
}
$this->setContext();
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
} else {
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
$this->edit();
} else {
if ($this->_action & CRM_Core_Action::DETACH) {
require_once 'CRM/Pledge/BAO/Payment.php';
require_once 'CRM/Contribute/PseudoConstant.php';
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($this->_id, null, null, array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus()));
$session =& CRM_Core_Session::singleton();
$session->setStatus(ts('Pledge has been Cancelled and all scheduled (not completed) payments have been cancelled.<br />'));
CRM_Utils_System::redirect($session->popUserContext());
} else {
$this->browse();
}
}
}
return parent::run();
}
示例8: postProcess
//.........这里部分代码省略.........
// defaults status is "Pending".
// if update get status.
if ($this->_id) {
$params['pledge_status_id'] = $params['status_id'] = $this->_values['status_id'];
} else {
$params['pledge_status_id'] = $params['status_id'] = array_search('Pending', $paymentStatusTypes);
}
// format amount
$params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues));
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$params['original_installment_amount'] = $params['amount'] / $params['installments'];
$dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date');
foreach ($dates as $d) {
if ($this->_id && !$this->_isPending && !empty($this->_values[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($this->_values[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($this->_values[$d]);
} elseif (!empty($formValues[$d]) && !CRM_Utils_System::isNull($formValues[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($formValues[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($formValues[$d]);
} else {
$params[$d] = 'null';
}
}
if (!empty($formValues['is_acknowledge'])) {
$params['acknowledge_date'] = date('Y-m-d');
}
// assign id only in update mode
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$params['contact_id'] = $this->_contactID;
// format custom data
if (!empty($formValues['hidden_custom'])) {
$params['hidden_custom'] = 1;
$customFields = CRM_Core_BAO_CustomField::getFields('Pledge');
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, 'Pledge');
}
// handle pending pledge.
$params['is_pledge_pending'] = $this->_isPending;
// create pledge record.
$pledge = CRM_Pledge_BAO_Pledge::create($params);
$statusMsg = NULL;
if ($pledge->id) {
// set the status msg.
if ($this->_action & CRM_Core_Action::ADD) {
$statusMsg = ts('Pledge has been recorded and the payment schedule has been created.<br />');
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = ts('Pledge has been updated.<br />');
}
}
// handle Acknowledgment.
if (!empty($formValues['is_acknowledge']) && $pledge->id) {
// calculate scheduled amount.
$params['scheduled_amount'] = round($params['amount'] / $params['installments']);
$params['total_pledge_amount'] = $params['amount'];
// get some required pledge values in params.
$params['id'] = $pledge->id;
$params['acknowledge_date'] = $pledge->acknowledge_date;
$params['is_test'] = $pledge->is_test;
$params['currency'] = $pledge->currency;
// retrieve 'from email id' for acknowledgement
$params['from_email_id'] = $formValues['from_email_address'];
$this->paymentId = NULL;
// send Acknowledgment mail.
CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
if (!isset($this->userEmail)) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
}
$statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
// build the payment urls.
if ($this->paymentId) {
$urlParams = "reset=1&action=add&cid={$this->_contactID}&ppid={$this->paymentId}&context=pledge";
$contribURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
$urlParams .= "&mode=live";
$creditURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
// check if we can process credit card payment.
$processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a> OR <a href='%2'>submit a credit card payment</a>.", array(1 => $contribURL, 2 => $creditURL));
} else {
$statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a>.", array(1 => $contribURL));
}
}
}
CRM_Core_Session::setStatus($statusMsg, ts('Payment Due'), 'info');
$buttonName = $this->controller->getButtonName();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/pledge/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=pledge"));
}
} elseif ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/pledge', "reset=1&action=add&context=pledge&cid={$this->_contactID}"));
}
}
示例9: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
$this->assign('showFeeBlock', false);
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
// get the option value for custom data type
$this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
$this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
if ($this->_mode) {
$this->assign('participantMode', $this->_mode);
$this->_paymentProcessor = array('billing_mode' => 1);
$validProcessors = array();
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
foreach ($processors as $ppID => $label) {
require_once 'CRM/Core/BAO/PaymentProcessor.php';
require_once 'CRM/Core/Payment.php';
$paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
continue;
} else {
if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
continue;
} else {
$paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
$error = $paymentObject->checkConfig();
if (empty($error)) {
$validProcessors[$ppID] = $label;
}
$paymentObject = null;
}
}
}
if (empty($validProcessors)) {
CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
} else {
$this->_processors = $validProcessors;
}
// also check for billing information
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
$this->assign('bltID', $this->_bltID);
$this->_fields = array();
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::setCreditCardFields($this);
// this required to show billing block
$this->assign_by_ref('paymentProcessor', $paymentProcessor);
$this->assign('hidePayPalExpress', true);
}
if ($this->_showFeeBlock) {
$this->assign('showFeeBlock', true);
$this->assign('paid', true);
return CRM_Event_Form_EventFees::preProcess($this);
}
//custom data related code
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', false);
if ($this->_cdType) {
$this->assign('cdType', true);
return CRM_Custom_Form_CustomData::preProcess($this);
}
//check the mode when this form is called either single or as
//search task action
if ($this->_participantId || $this->_contactID || $this->_context == 'standalone') {
$this->_single = true;
$this->assign('urlPath', 'civicrm/contact/view/participant');
if (!$this->_participantId && !$this->_contactID) {
$breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
CRM_Utils_System::appendBreadCrumb($breadCrumbs);
}
} else {
//set the appropriate action
$advanced = null;
$builder = null;
$session =& CRM_Core_Session::singleton();
$advanced = $session->get('isAdvanced');
$builder = $session->get('isSearchBuilder');
$searchType = "basic";
if ($advanced == 1) {
$this->_action = CRM_Core_Action::ADVANCED;
$searchType = "advanced";
} else {
if ($advanced == 2 && ($builder = 1)) {
$this->_action = CRM_Core_Action::PROFILE;
//.........这里部分代码省略.........
示例10: allowBackofficeCreditCard
/**
* Check for presence of type 1 or type 3 enabled processors (means we can do back-office submit credit/debit card trxns)
* @public
*/
static function allowBackofficeCreditCard($template = NULL, $variableName = 'newCredit')
{
$newCredit = FALSE;
$processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$newCredit = TRUE;
}
if ($template) {
$template->assign($variableName, $newCredit);
}
return $newCredit;
}
示例11: preProcess
public function preProcess()
{
// check for edit permission
if (!CRM_Core_Permission::check('edit memberships')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
// action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($this->_id) {
$this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id");
}
$this->assign("endDate", CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "end_date")));
$this->assign("membershipStatus", CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipStatus", CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "status_id"), "name"));
$orgId = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipType", $this->_memType, "member_of_contact_id");
$this->assign("memType", CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipType", $this->_memType, "name"));
$this->assign("orgName", CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $orgId, "display_name"));
//using credit card :: CRM-2759
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
if ($this->_mode) {
$membershipFee = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_MembershipType", $this->_memType, 'minimum_fee');
if (!$membershipFee) {
$statusMsg = ts('Membership Renewal using credit card required Membership fee, since this memebrship type have no fee, you can use normal renew mode');
CRM_Core_Session::setStatus($statusMsg);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership"));
}
$this->assign('membershipMode', $this->_mode);
$this->_paymentProcessor = array('billing_mode' => 1);
$validProcessors = array();
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
foreach ($processors as $ppID => $label) {
require_once 'CRM/Core/BAO/PaymentProcessor.php';
require_once 'CRM/Core/Payment.php';
$paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
continue;
} else {
if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
continue;
} else {
$paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
$error = $paymentObject->checkConfig();
if (empty($error)) {
$validProcessors[$ppID] = $label;
}
$paymentObject = null;
}
}
}
if (empty($validProcessors)) {
CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
} else {
$this->_processors = $validProcessors;
}
// also check for billing information
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
$this->assign('bltID', $this->_bltID);
$this->_fields = array();
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::setCreditCardFields($this);
// this required to show billing block
$this->assign_by_ref('paymentProcessor', $paymentProcessor);
$this->assign('hidePayPalExpress', true);
} else {
$this->assign('membershipMode', false);
}
parent::preProcess();
}
示例12: IN
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
// check if we can process credit card registration
require_once 'CRM/Core/PseudoConstant.php';
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$this->_isPaymentProcessor = true;
} else {
$this->_isPaymentProcessor = false;
}
// Only show credit card membership signup and renewal if user has CiviContribute permission
if (CRM_Core_Permission::access('CiviContribute')) {
$this->_accessContribution = true;
} else {
$this->_accessContribution = false;
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_memberClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view, edit, delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit memberships')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviMember')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
$row[$property] = $result->{$property};
}
if ($row['member_is_test']) {
$row['membership_type'] = $row['membership_type'] . " (test)";
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->membership_id;
if (!isset($result->owner_membership_id)) {
$row['action'] = CRM_Core_Action::formLink(self::links('all', $this->_isPaymentProcessor, $this->_accessContribution), $mask, array('id' => $result->membership_id, 'cid' => $result->contact_id, 'cxt' => $this->_context));
} else {
$row['action'] = CRM_Core_Action::formLink(self::links('view'), $mask, array('id' => $result->membership_id, 'cid' => $result->contact_id, 'cxt' => $this->_context));
}
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
$rows[] = $row;
}
return $rows;
}
示例13: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
require_once 'CRM/Member/BAO/MembershipType.php';
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes();
if (!empty($membershipTypes)) {
$this->addElement('checkbox', 'is_active', ts('Membership Section Enabled?'), null, array('onclick' => "memberBlock(this);"));
$this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title'));
$this->addWysiwyg('new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text'));
$this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title'));
$this->addWysiwyg('renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text'));
$this->addElement('checkbox', 'is_required', ts('Require Membership Signup'));
$this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee'));
$this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment'));
$paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(false, false, 'is_recur = 1');
$paymentProcessorId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'payment_processor_id');
$isRecur = false;
$membership = array();
$membershipDefault = array();
foreach ($membershipTypes as $k => $v) {
$membership[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
$membershipDefault[] = HTML_QuickForm::createElement('radio', null, null, null, $k);
if (is_array($paymentProcessor) && CRM_Utils_Array::value($paymentProcessorId, $paymentProcessor)) {
$isRecur = true;
$autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
$autoRenewOptions = array();
if ($autoRenew) {
$autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required'));
$this->addElement('select', "auto_renew_{$k}", ts('Auto-renew'), $autoRenewOptions);
$this->_renewOption[$k] = $autoRenew;
}
} else {
$isRecur = false;
}
}
$this->assign('is_recur', $isRecur);
$this->assign('auto_renew', $this->_renewOption);
$this->addGroup($membership, 'membership_type', ts('Membership Types'));
$this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'));
$this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id);
}
$session = CRM_Core_Session::singleton();
$single = $session->get('singleForm');
if ($single) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
} else {
parent::buildQuickForm();
}
//$session->set('single', false );
}
示例14: uninstall
/**
* undocumented function
*
* @return void
**/
public function uninstall()
{
if (!array_key_exists($this->ext->key, $this->paymentProcessorTypes)) {
CRM_Core_Error::fatal('This payment processor type is not registered.');
}
require_once 'CRM/Core/PseudoConstant.php';
$paymentProcessors = CRM_Core_PseudoConstant::paymentProcessor(TRUE);
require_once "CRM/Core/DAO/PaymentProcessor.php";
foreach ($paymentProcessors as $id => $name) {
$dao = new CRM_Core_DAO_PaymentProcessor();
$dao->id = $id;
$dao->find();
while ($dao->fetch()) {
if ($dao->payment_processor_type == $this->ext->name) {
CRM_Core_Error::fatal('Cannot uninstall this extension - there is at least one payment processor using payment processor type provided by it.');
}
}
}
require_once "CRM/Core/BAO/PaymentProcessorType.php";
CRM_Core_BAO_PaymentProcessorType::del($this->paymentProcessorTypes[$this->ext->key]);
}
示例15: run
/**
* This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->preProcess();
// check if we can process credit card registration
$processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
if (count($processors) > 0) {
$this->assign('newCredit', true);
} else {
$this->assign('newCredit', false);
}
// Only show credit card registration button if user has CiviContribute permission
if (CRM_Core_Permission::access('CiviContribute')) {
$this->assign('accessContribution', true);
} else {
$this->assign('accessContribution', false);
}
$this->setContext();
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
} else {
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
$this->edit();
} else {
$this->browse();
}
}
return parent::run();
}