本文整理匯總了PHP中CRM_Contribute_DAO_Product類的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_DAO_Product類的具體用法?PHP CRM_Contribute_DAO_Product怎麽用?PHP CRM_Contribute_DAO_Product使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CRM_Contribute_DAO_Product類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setDefaultValues
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$defaults = array();
if ($this->_pid) {
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->id = $this->_pid;
$dao->find(TRUE);
$defaults['product_id'] = $dao->product_id;
$defaults['financial_type_id'] = $dao->financial_type_id;
$defaults['weight'] = $dao->weight;
} else {
$dao = new CRM_Contribute_DAO_Product();
$dao->id = key($this->_products);
$dao->find(TRUE);
$defaults['financial_type_id'] = $dao->financial_type_id;
}
if (!isset($defaults['weight']) || !$defaults['weight']) {
$pageID = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$dao = new CRM_Contribute_DAO_Premium();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $pageID;
$dao->find(TRUE);
$premiumID = $dao->id;
$sql = 'SELECT max( weight ) as max_weight FROM civicrm_premiums_product WHERE premiums_id = %1';
$params = array(1 => array($premiumID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$dao->fetch();
$defaults['weight'] = $dao->max_weight + 1;
}
return $defaults;
}
示例2: browse
/**
* Browse all custom data groups.
*
*
* @return void
* @access public
* @static
*/
function browse()
{
// get all custom groups sorted by weight
$premiums = array();
$dao = new CRM_Contribute_DAO_Product();
$dao->orderBy('name');
$dao->find();
while ($dao->fetch()) {
$premiums[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $premiums[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$premiums[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
}
$this->assign('rows', $premiums);
}
示例3: formRule
//.........這裏部分代碼省略.........
}
}
}
if (!empty($lifeMember)) {
foreach ($priceFieldIDS as $priceFieldId) {
if (($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) && in_array($membershipOrgDetails[$id], $unallowedOrgs)) {
$errors['_qf_default'] = ts('You already have a lifetime membership and cannot select a membership with a shorter term.');
break;
}
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$priceFieldIDS['id'] = $fields['priceSetId'];
$self->set('memberPriceFieldIDS', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
foreach ($count as $id => $occurrence) {
if ($occurrence > 1) {
$errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
}
}
}
if (empty($priceFieldMemTypes) && $self->_membershipBlock['is_required'] == 1) {
$errors['_qf_default'] = ts('Please select at least one membership option.');
}
}
CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
if ($fields['amount'] < 0) {
$errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
}
$amount = $fields['amount'];
}
if (isset($fields['selectProduct']) && $fields['selectProduct'] != 'no_thanks') {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $fields['selectProduct'];
$productDAO->find(TRUE);
$min_amount = $productDAO->min_contribution;
if ($amount < $min_amount) {
$errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount)));
CRM_Core_Session::setStatus($errors['selectProduct']);
}
}
//CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor_id', $fields) == 0) {
$errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
}
// validate PCP fields - if not anonymous, we need a nick name value
if ($self->_pcpId && !empty($fields['pcp_display_in_roll']) && CRM_Utils_Array::value('pcp_is_anonymous', $fields) == 0 && CRM_Utils_Array::value('pcp_roll_nickname', $fields) == '') {
$errors['pcp_roll_nickname'] = ts('Please enter a name to include in the Honor Roll, or select \'contribute anonymously\'.');
}
// return if this is express mode
$config = CRM_Core_Config::singleton();
if ($self->_paymentProcessor && $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
if (!empty($fields[$self->_expressButtonName . '_x']) || !empty($fields[$self->_expressButtonName . '_y']) || CRM_Utils_Array::value($self->_expressButtonName, $fields)) {
return $errors;
}
}
//validate the pledge fields.
if (!empty($self->_values['pledge_block_id'])) {
//validation for pledge payment.
if (!empty($self->_values['pledge_id'])) {
if (empty($fields['pledge_amount'])) {
$errors['pledge_amount'] = ts('At least one payment option needs to be checked.');
}
} elseif (!empty($fields['is_pledge'])) {
示例4: _assignMessageVariablesToTemplate
/**
* Apply variables for message to smarty template - this function is part of analysing what is in the huge
* function & breaking it down into manageable chunks. Eventually it will be refactored into something else
* Note we send directly from this function in some cases because it is only partly refactored
* Don't call this function directly as the signature will change
*
* @param $values
* @param $input
* @param CRM_Core_SMARTY $template
* @param bool $recur
* @param bool $returnMessageText
*
* @return mixed
*/
public function _assignMessageVariablesToTemplate(&$values, $input, &$template, $recur = FALSE, $returnMessageText = TRUE)
{
$template->assign('first_name', $this->_relatedObjects['contact']->first_name);
$template->assign('last_name', $this->_relatedObjects['contact']->last_name);
$template->assign('displayName', $this->_relatedObjects['contact']->display_name);
if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) {
$template->assign('useForMember', TRUE);
}
//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
if (isset($softRecord['soft_credit'])) {
//if id of contribution page is present
if (!empty($values['id'])) {
$values['honor'] = array('honor_profile_values' => array(), 'honor_profile_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'uf_group_id', 'entity_id'), 'honor_id' => $softRecord['soft_credit'][1]['contact_id']);
$softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type');
$template->assign('soft_credit_type', $softRecord['soft_credit'][1]['soft_credit_type_label']);
$template->assign('honor_block_is_active', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'is_active', 'entity_id'));
} else {
//offline contribution
$softCreditTypes = $softCredits = array();
foreach ($softRecord['soft_credit'] as $key => $softCredit) {
$softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
$softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']));
}
$template->assign('softCreditTypes', $softCreditTypes);
$template->assign('softCredits', $softCredits);
}
}
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $this->id;
if ($dao->find(TRUE)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $premiumId;
$productDAO->find(TRUE);
$template->assign('selectPremium', TRUE);
$template->assign('product_name', $productDAO->name);
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
$template->assign('title', CRM_Utils_Array::value('title', $values));
$amount = CRM_Utils_Array::value('total_amount', $input, CRM_Utils_Array::value('amount', $input), NULL);
if (empty($amount) && isset($this->total_amount)) {
$amount = $this->total_amount;
}
$template->assign('amount', $amount);
// add the new contribution values
if (strtolower($this->_component) == 'contribute') {
//PCP Info
$softDAO = new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $this->id;
if ($softDAO->find(TRUE)) {
$template->assign('pcpBlock', TRUE);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
$pcpDAO = new CRM_PCP_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(TRUE)) {
$template->assign('title', $pcpDAO->title);
}
}
}
if ($this->financial_type_id) {
$values['financial_type_id'] = $this->financial_type_id;
}
$template->assign('trxn_id', $this->trxn_id);
$template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date));
$template->assign('contributeMode', 'notify');
$template->assign('action', $this->is_test ? 1024 : 1);
$template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
$template->assign('is_monetary', 1);
$template->assign('is_recur', (bool) $recur);
$template->assign('currency', $this->currency);
$template->assign('address', CRM_Utils_Address::format($input));
if (!empty($values['customGroup'])) {
$template->assign('customGroup', $values['customGroup']);
}
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$viewRoles = array();
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
//.........這裏部分代碼省略.........
示例5: browse
/**
* Browse all custom data groups.
*
*
* @return void
*/
public function browse()
{
// get all custom groups sorted by weight
$premiums = array();
$dao = new CRM_Contribute_DAO_Product();
$dao->orderBy('name');
$dao->find();
while ($dao->fetch()) {
$premiums[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $premiums[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$premiums[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'premium.manage.row', 'Premium', $dao->id);
//Financial Type
if (!empty($dao->financial_type_id)) {
require_once 'CRM/Core/DAO.php';
$premiums[$dao->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name');
}
}
$this->assign('rows', $premiums);
}
示例6: getPremiumProductInfo
/**
* Retrieve premium product and their options.
*
* @return array
* product and option arrays
*/
public static function getPremiumProductInfo()
{
if (!self::$productInfo) {
$products = $options = array();
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
$dao->find();
while ($dao->fetch()) {
$products[$dao->id] = $dao->name . " ( " . $dao->sku . " )";
$opts = explode(',', $dao->options);
foreach ($opts as $k => $v) {
$ops[$k] = trim($v);
}
if ($ops[0] != '') {
$options[$dao->id] = $opts;
}
}
self::$productInfo = array($products, $options);
}
return self::$productInfo;
}
示例7: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
$cancelledStatus = TRUE;
$status = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Cancelled', $status)) {
$cancelledStatus = FALSE;
}
$this->assign('cancelledStatus', $cancelledStatus);
if (!empty($values['contribution_page_id'])) {
$contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
$values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
}
// get recieved into i.e to_financial_account_id from last trxn
$financialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC');
$values['to_financial_account'] = '';
if (!empty($financialTrxnId['financialTrxnId'])) {
$values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
if ($values['to_financial_account_id']) {
$values['to_financial_account'] = CRM_Contribute_PseudoConstant::financialAccount($values['to_financial_account_id']);
}
$values['payment_processor_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'payment_processor_id');
if ($values['payment_processor_id']) {
$values['payment_processor_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
}
}
if (!empty($values['contribution_recur_id'])) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values['recur_installments'] = $dao->installments;
$values['recur_frequency_unit'] = $dao->frequency_unit;
$values['recur_frequency_interval'] = $dao->frequency_interval;
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, CRM_Utils_Array::value('financial_type_id', $values));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->find(TRUE);
$this->assign('premium', $productDAO->name);
$this->assign('option', $dao->product_option);
$this->assign('fulfilled', $dao->fulfilled_date);
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote(CRM_Utils_Array::value('id', $values), 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (!empty($values['address_id'])) {
$addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['billing_address'] = $addressDetails[0]['display'];
}
//assign soft credit record if exists.
$SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
if (!empty($SCRecords['soft_credit'])) {
$this->assign('softContributions', $SCRecords['soft_credit']);
unset($SCRecords['soft_credit']);
}
//assign pcp record if exists
foreach ($SCRecords as $name => $value) {
$this->assign($name, $value);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
if (!empty($lineItem)) {
$lineItems[] = $lineItem;
}
}
$this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
$values['totalAmount'] = $values['total_amount'];
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
//.........這裏部分代碼省略.........
示例8: processContribution
/**
* Process the contribution
*
* @return void
* @access public
*/
static function processContribution(&$form, $params, $result, $contactID, $contributionType, $deductibleMode = TRUE, $pending = FALSE, $online = TRUE)
{
$transaction = new CRM_Core_Transaction();
$className = get_class($form);
$honorCId = $recurringContributionID = NULL;
if ($online && $form->get('honor_block_is_active')) {
$honorCId = $form->createHonorContact();
}
// add these values for the recurringContrib function ,CRM-10188
$params['contribution_type_id'] = $contributionType->id;
$params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $form->_values);
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $contributionType, $online);
if (!$online && isset($params['honor_contact_id'])) {
$honorCId = $params['honor_contact_id'];
}
$config = CRM_Core_Config::singleton();
if (!$online && isset($params['non_deductible_amount'])) {
$nonDeductibleAmount = $params['non_deductible_amount'];
} else {
$nonDeductibleAmount = $params['amount'];
}
if ($online && $contributionType->is_deductible && $deductibleMode) {
$selectProduct = CRM_Utils_Array::value('selectProduct', $params);
if ($selectProduct && $selectProduct != 'no_thanks') {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $selectProduct;
$productDAO->find(TRUE);
if ($params['amount'] < $productDAO->price) {
$nonDeductibleAmount = $params['amount'];
} else {
$nonDeductibleAmount = $productDAO->price;
}
} else {
$nonDeductibleAmount = '0.00';
}
}
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
$receiptDate = $now;
}
//get the contrib page id.
$campaignId = $contributionPageId = NULL;
if ($online) {
$contributionPageId = $form->_id;
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
if (!array_key_exists('campaign_id', $params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
} else {
//also for offline we do support - CRM-7290
$contributionPageId = CRM_Utils_Array::value('contribution_page_id', $params);
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
}
// first create the contribution record
$contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $contributionType->id, 'contribution_page_id' => $contributionPageId, 'receive_date' => CRM_Utils_Array::value('receive_date', $params) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || CRM_Utils_Array::value('source', $params) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, 'campaign_id' => $campaignId);
if (!$online && isset($params['thankyou_date'])) {
$contribParams['thankyou_date'] = $params['thankyou_date'];
}
if (!$online || $form->_values['is_monetary']) {
if (!CRM_Utils_Array::value('is_pay_later', $params)) {
$contribParams['payment_instrument_id'] = 1;
}
}
if (!$pending && $result) {
$contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $result), 'payment_processor' => CRM_Utils_Array::value('payment_processor', $result));
}
if (isset($honorCId)) {
$contribParams['honor_contact_id'] = $honorCId;
$contribParams['honor_type_id'] = $params['honor_type_id'];
}
if ($recurringContributionID) {
$contribParams['contribution_recur_id'] = $recurringContributionID;
}
$contribParams['contribution_status_id'] = $pending ? 2 : 1;
$contribParams['is_test'] = 0;
if ($form->_mode == 'test') {
$contribParams['is_test'] = 1;
}
$ids = array();
if (isset($contribParams['invoice_id'])) {
$contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
if (isset($contribID)) {
$ids['contribution'] = $contribID;
$contribParams['id'] = $contribID;
}
}
//create an contribution address
if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params) && CRM_Utils_Array::value('is_monetary', $form->_values)) {
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
// CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
$contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
$contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
//.........這裏部分代碼省略.........
示例9: sendMail
//.........這裏部分代碼省略.........
$addressParams = array('id' => $contribution->address_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, false, 'id');
$addressDetails = array_values($addressDetails);
$values['address'] = $addressDetails[0]['display'];
}
}
$template =& CRM_Core_Smarty::singleton();
// CRM_Core_Error::debug('tpl',$template);
//assign honor infomation to receiptmessage
if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
$honorDefault = array();
$honorIds = array();
$honorIds['contribution'] = $contribution->id;
$idParams = array('id' => $honarID, 'contact_id' => $honarID);
require_once "CRM/Contact/BAO/Contact.php";
CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
require_once "CRM/Core/PseudoConstant.php";
$honorType = CRM_Core_PseudoConstant::honor();
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$template->assign('honor_block_is_active', 1);
$template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
$template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
$template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
$template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
$template->assign('honor_type', $honorType[$contribution->honor_type_id]);
}
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $contribution->id;
if ($dao->find(true)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
require_once 'CRM/Contribute/DAO/Product.php';
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $premiumId;
$productDAO->find(true);
$template->assign('selectPremium', true);
$template->assign('product_name', $productDAO->name);
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
// add the new contribution values
if ($input['component'] == 'contribute') {
$template->assign('title', $values['title']);
$template->assign('amount', $input['amount']);
//PCP Info
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
$softDAO = new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $contribution->id;
if ($softDAO->find(true)) {
$template->assign('pcpBlock', true);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
require_once 'CRM/Contribute/DAO/PCP.php';
$pcpDAO = new CRM_Contribute_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(true)) {
$template->assign('title', $pcpDAO->title);
}
}
} else {
$template->assign('title', $values['event']['title']);
$template->assign('totalAmount', $input['amount']);
}
示例10: array
function &exportableFields()
{
if (!self::$_exportableFields) {
if (!self::$_exportableFields) {
self::$_exportableFields = array();
}
require_once 'CRM/Core/OptionValue.php';
require_once 'CRM/Contribute/DAO/Product.php';
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
require_once 'CRM/Contribute/DAO/ContributionType.php';
$impFields = CRM_Contribute_DAO_Contribution::import();
$expFieldProduct = CRM_Contribute_DAO_Product::export();
$expFieldsContrib = CRM_Contribute_DAO_ContributionProduct::export();
$typeField = CRM_Contribute_DAO_ContributionType::export();
$optionField = CRM_Core_OptionValue::getFields($mode = 'contribute');
$fields = array_merge($impFields, $typeField);
$fields = array_merge($fields, $expFieldProduct);
$fields = array_merge($fields, $expFieldsContrib);
$fields = array_merge($fields, $optionField);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
self::$_exportableFields = $fields;
}
return self::$_exportableFields;
}
示例11: formRule
/**
* global form rule
*
* @param array $fields the input form values
* @param array $files the uploaded files if any
* @param array $options additional user data
*
* @return true if no errors, else array of errors
* @access public
* @static
*/
static function formRule($fields, $files, $self)
{
$errors = array();
$amount = self::computeAmount($fields, $self);
//check for atleast one pricefields should be selected
if (CRM_Utils_Array::value('priceSetId', $fields)) {
$priceField = new CRM_Price_DAO_Field();
$priceField->price_set_id = $fields['priceSetId'];
$priceField->find();
$check = array();
while ($priceField->fetch()) {
if (!empty($fields["price_{$priceField->id}"])) {
$check[] = $priceField->id;
}
}
if (empty($check)) {
if ($self->_useForMember == 1) {
$errors['_qf_default'] = ts('Select at least one option from Membership Type(s).');
} else {
$errors['_qf_default'] = ts('Select at least one option from Contribution(s).');
}
}
require_once 'CRM/Price/BAO/Set.php';
if ($self->_useForMember == 1 && !empty($check)) {
$priceFieldIDS = array();
$priceFieldMemTypes = array();
foreach ($self->_priceSet['fields'] as $priceId => $value) {
if (!empty($fields['price_' . $priceId])) {
if (is_array($fields['price_' . $priceId])) {
foreach ($fields['price_' . $priceId] as $priceFldVal => $isSet) {
if ($isSet) {
$priceFieldIDS[] = $priceFldVal;
}
}
} else {
$priceFieldIDS[] = $fields['price_' . $priceId];
}
if (CRM_Utils_Array::value('options', $value)) {
foreach ($value['options'] as $val) {
if (CRM_Utils_Array::value('membership_type_id', $val)) {
$priceFieldMemTypes[] = $val['membership_type_id'];
}
}
}
}
}
$ids = implode(',', $priceFieldIDS);
$priceFieldIDS['id'] = $fields['priceSetId'];
$self->set('memberPriceFieldIDS', $priceFieldIDS);
$count = CRM_Price_BAO_Set::getMembershipCount($ids);
foreach ($count as $id => $occurance) {
if ($occurance > 1) {
$errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
}
}
if (empty($priceFieldMemTypes)) {
$errors['_qf_default'] = ts('Please select at least one membership option.');
}
}
CRM_Price_BAO_Set::processAmount($self->_values['fee'], $fields, $lineItem);
if ($fields['amount'] < 0) {
$errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
}
$amount = $fields['amount'];
}
if (isset($fields['selectProduct']) && $fields['selectProduct'] != 'no_thanks' && $self->_values['amount_block_is_active']) {
require_once 'CRM/Contribute/DAO/Product.php';
require_once 'CRM/Utils/Money.php';
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $fields['selectProduct'];
$productDAO->find(true);
$min_amount = $productDAO->min_contribution;
if ($amount < $min_amount) {
$errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount)));
}
}
if ($self->_values['honor_block_is_active'] && CRM_Utils_Array::value('honor_type_id', $fields)) {
// make sure there is a first name and last name if email is not there
if (!CRM_Utils_Array::value('honor_email', $fields)) {
if (!CRM_Utils_Array::value('honor_first_name', $fields) || !CRM_Utils_Array::value('honor_last_name', $fields)) {
$errors['honor_last_name'] = ts('In Honor Of - First Name and Last Name, OR an Email Address is required.');
}
}
}
if (isset($fields['is_recur']) && $fields['is_recur']) {
if ($fields['frequency_interval'] <= 0) {
$errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).');
}
if ($fields['frequency_unit'] == '0') {
//.........這裏部分代碼省略.........
示例12: buildPremiumPreviewBlock
/**
* Function to build Premium B im Contribution Pages
*
* @param int $pageId
* @static
*/
function buildPremiumPreviewBlock($form, $productID, $premiumProductID = null)
{
require_once 'CRM/Contribute/DAO/Product.php';
if ($premiumProductID) {
require_once 'CRM/Contribute/DAO/PremiumsProduct.php';
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->id = $premiumProductID;
$dao->find(true);
$productID = $dao->product_id;
}
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->is_active = 1;
if ($productDAO->find(true)) {
CRM_Core_DAO::storeValues($productDAO, $products[$productDAO->id]);
}
$radio[$productDAO->id] = $form->createElement('radio', null, null, null, $productDAO->id, null);
$options = $temp = array();
$temp = explode(',', $productDAO->options);
foreach ($temp as $value) {
$options[$value] = $value;
}
if ($temp[0] != '') {
$form->add('select', 'options_' . $productDAO->id, null, $options);
}
$form->addGroup($radio, 'selectProduct', null);
$form->assign('showRadio', true);
$form->assign('showSelectOptions', true);
$form->assign('products', $products);
$form->assign('preview', true);
}
示例13: formRule
//.........這裏部分代碼省略.........
}
}
}
if (!empty($lifeMember)) {
foreach ($priceFieldIDS as $priceFieldId) {
if (($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) && in_array($membershipOrgDetails[$id], $unallowedOrgs)) {
$errors['_qf_default'] = ts('You already have a lifetime membership and cannot select a membership with a shorter term.');
break;
}
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$priceFieldIDS['id'] = $fields['priceSetId'];
$self->set('memberPriceFieldIDS', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
foreach ($count as $id => $occurance) {
if ($occurance > 1) {
$errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
}
}
}
if (empty($priceFieldMemTypes)) {
$errors['_qf_default'] = ts('Please select at least one membership option.');
}
}
CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
if ($fields['amount'] < 0) {
$errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
}
$amount = $fields['amount'];
}
if (isset($fields['selectProduct']) && $fields['selectProduct'] != 'no_thanks') {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $fields['selectProduct'];
$productDAO->find(TRUE);
$min_amount = $productDAO->min_contribution;
if ($amount < $min_amount) {
$errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount)));
CRM_Core_Session::setStatus($errors['selectProduct']);
}
}
if (!empty($fields['is_recur'])) {
if ($fields['frequency_interval'] <= 0) {
$errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).');
}
if ($fields['frequency_unit'] == '0') {
$errors['frequency_unit'] = ts('Please select a period (e.g. months, years ...) for how often you want to make this recurring contribution (EXAMPLE: Every 3 MONTHS).');
}
}
if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor', $fields) == 0) {
$errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
}
if (!empty($fields['is_for_organization']) && !property_exists($self, 'organizationName')) {
if (empty($fields['onbehalf']['organization_name'])) {
if (!empty($fields['org_option']) && !$fields['onbehalfof_id']) {
$errors['organization_id'] = ts('Please select an organization or enter a new one.');
} elseif (empty($fields['org_option'])) {
$errors['onbehalf']['organization_name'] = ts('Please enter the organization name.');
}
}
foreach ($fields['onbehalf'] as $key => $value) {
if (strstr($key, 'email')) {
$emailLocType = explode('-', $key);
}
}
示例14: calculateNonDeductibleAmount
/**
* Calculate non deductible amount.
*
* CRM-11956
* if non_deductible_amount exists i.e. Additional Details field set was opened [and staff typed something] -
* if non_deductible_amount does NOT exist - then calculate it depending on:
* $financialType->is_deductible and whether there is a product (premium).
*
* @param $params
* @param $formValues
*
* @return array
*/
protected function calculateNonDeductibleAmount($params, $formValues)
{
if (!empty($params['non_deductible_amount'])) {
return $params['non_deductible_amount'];
}
$priceSetId = CRM_Utils_Array::value('price_set_id', $params);
// return non-deductible amount if it is set at the price field option level
if ($priceSetId && !empty($params['line_item'])) {
$nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $params['line_item']);
if (!empty($nonDeductibleAmount)) {
return $nonDeductibleAmount;
}
}
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $params['financial_type_id'];
$financialType->find(TRUE);
if ($financialType->is_deductible) {
if (isset($formValues['product_name'][0])) {
$selectProduct = $formValues['product_name'][0];
}
// if there is a product - compare the value to the contribution amount
if (isset($selectProduct)) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $selectProduct;
$productDAO->find(TRUE);
// product value exceeds contribution amount
if ($params['total_amount'] < $productDAO->price) {
return $params['total_amount'];
} else {
return $productDAO->price;
}
} else {
return '0.00';
}
} else {
return $params['total_amount'];
}
return 0;
}
示例15: del
/**
* Function to delete premium Types
*
* @param int $productID
* @static
*/
static function del($productID)
{
//check dependencies
$premiumsProduct = new CRM_Contribute_DAO_PremiumsProduct();
$premiumsProduct->product_id = $productID;
if ($premiumsProduct->find(TRUE)) {
$session = CRM_Core_Session::singleton();
$message .= ts('This Premium is being linked to <a href=\'%1\'>Online Contribution page</a>. Please remove it in order to delete this Premium.', array(1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')));
CRM_Core_Session::setStatus($message);
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute/managePremiums', 'reset=1&action=browse'));
}
//delete from contribution Type table
$premium = new CRM_Contribute_DAO_Product();
$premium->id = $productID;
$premium->delete();
}