当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Price_BAO_Set::removeFrom方法代码示例

本文整理汇总了PHP中CRM_Price_BAO_Set::removeFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::removeFrom方法的具体用法?PHP CRM_Price_BAO_Set::removeFrom怎么用?PHP CRM_Price_BAO_Set::removeFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Price_BAO_Set的用法示例。


在下文中一共展示了CRM_Price_BAO_Set::removeFrom方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteContribution

 /**                                                           
  * Delete the indirect records associated with this contribution first
  * 
  * @return $results no of deleted Contribution on success, false otherwise
  * @access public 
  * @static 
  */
 static function deleteContribution($id)
 {
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $results = null;
     //delete activity record
     require_once "CRM/Activity/BAO/Activity.php";
     $params = array('source_record_id' => $id, 'activity_type_id' => 6);
     // activity type id for contribution
     CRM_Activity_BAO_Activity::deleteActivity($params);
     //delete billing address if exists for this contribution.
     self::deleteAddress($id);
     //update pledge and pledge payment, CRM-3961
     require_once 'CRM/Pledge/BAO/Payment.php';
     CRM_Pledge_BAO_Payment::resetPledgePayment($id);
     // remove entry from civicrm_price_set_entity, CRM-5095
     require_once 'CRM/Price/BAO/Set.php';
     if (CRM_Price_BAO_Set::getFor('civicrm_contribution', $id)) {
         CRM_Price_BAO_Set::removeFrom('civicrm_contribution', $id);
     }
     // cleanup line items.
     require_once 'CRM/Price/BAO/Field.php';
     require_once 'CRM/Event/BAO/ParticipantPayment.php';
     $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
     // delete any related entity_financial_trxn and financial_trxn records.
     require_once 'CRM/Core/BAO/FinancialTrxn.php';
     CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id, 'civicrm_contribution');
     if ($participantId) {
         require_once 'CRM/Price/BAO/LineItem.php';
         CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
     } else {
         require_once 'CRM/Price/BAO/LineItem.php';
         CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
     }
     $dao = new CRM_Contribute_DAO_Contribution();
     $dao->id = $id;
     $results = $dao->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
     // delete the recently created Contribution
     require_once 'CRM/Utils/Recent.php';
     $contributionRecent = array('id' => $id, 'type' => 'Contribution');
     CRM_Utils_Recent::del($contributionRecent);
     return $results;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:54,代码来源:Contribution.php

示例2: postProcess


//.........这里部分代码省略.........
     if (CRM_Utils_Array::value('payment_processor_id', $params) == CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PaymentProcessor', 'AuthNet', 'id', 'payment_processor_type')) {
         CRM_Core_Session::setStatus(ts(' Please note that the Authorize.net payment processor only allows recurring contributions and auto-renew memberships with payment intervals from 7-365 days or 1-12 months (i.e. not greater than 1 year).'));
     }
     // check for price set.
     $priceSetID = CRM_Utils_Array::value('price_set_id', $params);
     // get required fields.
     $fields = array('id' => $this->_id, 'is_recur' => false, 'min_amount' => "null", 'max_amount' => "null", 'is_monetary' => false, 'is_pay_later' => false, 'is_recur_interval' => false, 'recur_frequency_unit' => "null", 'default_amount_id' => "null", 'is_allow_other_amount' => false, 'amount_block_is_active' => false);
     $resetFields = array();
     if ($priceSetID) {
         $resetFields = array('min_amount', 'max_amount', 'is_allow_other_amount');
     }
     if (!CRM_Utils_Array::value('is_recur', $params)) {
         $resetFields = array_merge($resetFields, array('is_recur_interval', 'recur_frequency_unit'));
     }
     foreach ($fields as $field => $defaultVal) {
         $val = CRM_Utils_Array::value($field, $params, $defaultVal);
         if (in_array($field, $resetFields)) {
             $val = $defaultVal;
         }
         if (in_array($field, array('min_amount', 'max_amount'))) {
             $val = CRM_Utils_Rule::cleanMoney($val);
         }
         $params[$field] = $val;
     }
     if ($params['is_recur']) {
         require_once 'CRM/Core/BAO/CustomOption.php';
         $params['recur_frequency_unit'] = implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params['recur_frequency_unit']));
         $params['is_recur_interval'] = CRM_Utils_Array::value('is_recur_interval', $params, false);
     }
     require_once 'CRM/Contribute/BAO/ContributionPage.php';
     $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params);
     $contributionPageID = $contributionPage->id;
     // prepare for data cleanup.
     $deleteAmountBlk = $deletePledgeBlk = $deletePriceSet = false;
     if ($this->_priceSetID) {
         $deletePriceSet = true;
     }
     if ($this->_pledgeBlockID) {
         $deletePledgeBlk = true;
     }
     if (!empty($this->_amountBlock)) {
         $deleteAmountBlk = true;
     }
     if ($contributionPageID) {
         require_once 'CRM/Price/BAO/Set.php';
         require_once 'CRM/Core/OptionGroup.php';
         require_once 'CRM/Pledge/BAO/PledgeBlock.php';
         if (CRM_Utils_Array::value('amount_block_is_active', $params)) {
             // handle price set.
             if ($priceSetID) {
                 // add/update price set.
                 $deletePriceSet = false;
                 CRM_Price_BAO_Set::addTo('civicrm_contribution_page', $contributionPageID, $priceSetID);
             } else {
                 // process contribution amount block
                 $deleteAmountBlk = false;
                 $labels = CRM_Utils_Array::value('label', $params);
                 $values = CRM_Utils_Array::value('value', $params);
                 $default = CRM_Utils_Array::value('default', $params);
                 $options = array();
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (isset($values[$i]) && strlen(trim($values[$i])) > 0) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 CRM_Core_OptionGroup::createAssoc("civicrm_contribution_page.amount.{$contributionPageID}", $options, $params['default_amount_id']);
                 if ($params['default_amount_id']) {
                     CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageID, 'default_amount_id', $params['default_amount_id']);
                 }
                 if (CRM_Utils_Array::value('is_pledge_active', $params)) {
                     $deletePledgeBlk = false;
                     $pledgeBlockParams = array('entity_id' => $contributionPageID, 'entity_table' => ts('civicrm_contribution_page'));
                     if ($this->_pledgeBlockID) {
                         $pledgeBlockParams['id'] = $this->_pledgeBlockID;
                     }
                     $pledgeBlock = array('pledge_frequency_unit', 'max_reminders', 'initial_reminder_day', 'additional_reminder_day');
                     foreach ($pledgeBlock as $key) {
                         $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params);
                     }
                     $pledgeBlockParams['is_pledge_interval'] = CRM_Utils_Array::value('is_pledge_interval', $params, false);
                     // create pledge block.
                     require_once 'CRM/Pledge/BAO/PledgeBlock.php';
                     CRM_Pledge_BAO_PledgeBlock::create($pledgeBlockParams);
                 }
             }
         }
         // delete pledge block.
         if ($deletePledgeBlk) {
             CRM_Pledge_BAO_PledgeBlock::deletePledgeBlock($this->_pledgeBlockID);
         }
         // delete previous price set.
         if ($deletePriceSet) {
             CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $contributionPageID);
         }
         // delete amount block.
         if ($deleteAmountBlk) {
             CRM_Core_OptionGroup::deleteAssoc("civicrm_contribution_page.amount.{$contributionPageID}");
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Amount.php

示例3: del

 /**
  * Function to delete the event
  *
  * @param int $id  event id
  *
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return null;
     }
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(null, null, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     $dependencies = array('CRM_Core_DAO_OptionGroup' => array('name' => 'civicrm_event.amount.' . $id), 'CRM_Core_DAO_UFJoin' => array('entity_id' => $id, 'entity_table' => 'civicrm_event'));
     require_once 'CRM/Core/BAO/OptionGroup.php';
     foreach ($dependencies as $daoName => $values) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php";
         eval('$dao = new ' . $daoName . '( );');
         if ($daoName == 'CRM_Core_DAO_OptionGroup') {
             $dao->name = $values['name'];
             $dao->find();
             while ($dao->fetch()) {
                 CRM_Core_BAO_OptionGroup::del($dao->id);
             }
         } else {
             foreach ($values as $fieldName => $fieldValue) {
                 $dao->{$fieldName} = $fieldValue;
             }
             $dao->find();
             while ($dao->fetch()) {
                 $dao->delete();
             }
         }
     }
     require_once 'CRM/Core/OptionGroup.php';
     CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$id}.discount.%", "LIKE");
     // price set cleanup, CRM-5527
     require_once 'CRM/Price/BAO/Set.php';
     CRM_Price_BAO_Set::removeFrom('civicrm_event', $id);
     require_once 'CRM/Event/DAO/Event.php';
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(true)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return null;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:64,代码来源:Event.php

示例4: postProcess

 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     // first delete the join entries associated with this contribution page
     require_once 'CRM/Core/DAO/UFJoin.php';
     $dao = new CRM_Core_DAO_UFJoin();
     $params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
     $dao->copyValues($params);
     $dao->delete();
     require_once 'CRM/Core/OptionGroup.php';
     $groupName = "civicrm_contribution_page.amount.{$this->_id}";
     CRM_Core_OptionGroup::deleteAssoc($groupName);
     //next delete the membership block fields
     require_once 'CRM/Member/DAO/MembershipBlock.php';
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->delete();
     //next delete the pcp block fields
     require_once 'CRM/Contribute/DAO/PCPBlock.php';
     $dao = new CRM_Contribute_DAO_PCPBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->delete();
     // need to delete premiums. CRM-4586
     require_once 'CRM/Contribute/BAO/Premium.php';
     CRM_Contribute_BAO_Premium::deletePremium($this->_id);
     // price set cleanup, CRM-5527
     require_once 'CRM/Price/BAO/Set.php';
     CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id);
     // finally delete the contribution page
     require_once 'CRM/Contribute/DAO/ContributionPage.php';
     $dao = new CRM_Contribute_DAO_ContributionPage();
     $dao->id = $this->_id;
     $dao->delete();
     $transaction->commit();
     CRM_Core_Session::setStatus(ts('The contribution page \'%1\' has been deleted.', array(1 => $this->_title)));
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:45,代码来源:Delete.php

示例5: del

 /**
  * Function to delete the event
  *
  * @param int $id  event id
  *
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return NULL;
     }
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     // price set cleanup, CRM-5527
     CRM_Price_BAO_Set::removeFrom('civicrm_event', $id);
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(TRUE)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return NULL;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:37,代码来源:Event.php

示例6: postProcess


//.........这里部分代码省略.........
                         $fieldParams['price_set_id'] = $priceSetId;
                         $fieldParams['is_active'] = 1;
                         $fieldParams['weight'] = 2;
                         if (CRM_Utils_Array::value('is_allow_other_amount', $params)) {
                             $fieldParams['is_required'] = 0;
                         } else {
                             $fieldParams['is_required'] = 1;
                         }
                         $fieldParams['html_type'] = 'Radio';
                         $fieldParams['option_label'] = $params['label'];
                         $fieldParams['option_amount'] = $params['value'];
                         foreach ($options as $value) {
                             $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                         }
                         $fieldParams['default_option'] = $params['default'];
                         $priceField = CRM_Price_BAO_Field::create($fieldParams);
                     }
                     if (CRM_Utils_Array::value('is_allow_other_amount', $params) && !CRM_Utils_Array::value('price_field_other', $params)) {
                         $editedFieldParams = array('price_set_id' => $priceSetId, 'name' => 'other_amount');
                         $editedResults = array();
                         CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
                         if (!($priceFieldID = CRM_Utils_Array::value('id', $editedResults))) {
                             $fieldParams = array('name' => 'other_amount', 'label' => 'Other Amount', 'price_set_id' => $priceSetId, 'html_type' => 'Text', 'is_display_amounts' => 0, 'weight' => 3);
                             $fieldParams['option_weight'][1] = 1;
                             $fieldParams['option_amount'][1] = 1;
                             if (!$noContriAmount) {
                                 $fieldParams['is_required'] = 1;
                                 $fieldParams['option_label'][1] = 'Contribution Amount';
                             } else {
                                 $fieldParams['is_required'] = 0;
                                 $fieldParams['option_label'][1] = 'Other Amount';
                             }
                             $priceField = CRM_Price_BAO_Field::create($fieldParams);
                         } else {
                             if (!CRM_Utils_Array::value('is_active', $editedResults)) {
                                 CRM_Price_BAO_Field::setIsActive($priceFieldID, '1');
                             }
                         }
                     } elseif (!CRM_Utils_Array::value('is_allow_other_amount', $params) && CRM_Utils_Array::value('price_field_other', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_other'], '0');
                     } elseif ($priceFieldID = CRM_Utils_Array::value('price_field_other', $params)) {
                         $priceFieldValueID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $priceFieldID, 'id', 'price_field_id');
                         if (!$noContriAmount) {
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_Field', $priceFieldID, 'is_required', 1);
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_FieldValue', $priceFieldValueID, 'label', 'Contribution Amount');
                         } else {
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_Field', $priceFieldID, 'is_required', 0);
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_FieldValue', $priceFieldValueID, 'label', 'Other Amount');
                         }
                     }
                 }
                 if (CRM_Utils_Array::value('is_pledge_active', $params)) {
                     $deletePledgeBlk = FALSE;
                     $pledgeBlockParams = array('entity_id' => $contributionPageID, 'entity_table' => ts('civicrm_contribution_page'));
                     if ($this->_pledgeBlockID) {
                         $pledgeBlockParams['id'] = $this->_pledgeBlockID;
                     }
                     $pledgeBlock = array('pledge_frequency_unit', 'max_reminders', 'initial_reminder_day', 'additional_reminder_day');
                     foreach ($pledgeBlock as $key) {
                         $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params);
                     }
                     $pledgeBlockParams['is_pledge_interval'] = CRM_Utils_Array::value('is_pledge_interval', $params, FALSE);
                     // create pledge block.
                     CRM_Pledge_BAO_PledgeBlock::create($pledgeBlockParams);
                 }
             }
         } else {
             if (CRM_Utils_Array::value('price_field_id', $params) || CRM_Utils_Array::value('price_field_other', $params)) {
                 $usedPriceSetId = CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $this->_id, 3);
                 if ($usedPriceSetId) {
                     if (CRM_Utils_Array::value('price_field_id', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_id'], '0');
                     }
                     if (CRM_Utils_Array::value('price_field_other', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_other'], '0');
                     }
                 } else {
                     $deleteAmountBlk = TRUE;
                     $deletePriceSet = TRUE;
                 }
             }
         }
         // delete pledge block.
         if ($deletePledgeBlk) {
             CRM_Pledge_BAO_PledgeBlock::deletePledgeBlock($this->_pledgeBlockID);
         }
         // delete previous price set.
         if ($deletePriceSet) {
             CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $contributionPageID);
         }
         if ($deleteAmountBlk) {
             $priceField = CRM_Utils_Array::value('price_field_id', $params) ? $params['price_field_id'] : CRM_Utils_Array::value('price_field_other', $params);
             if ($priceField) {
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $priceField, 'price_set_id');
                 CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
             }
         }
     }
     parent::endPostProcess();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Amount.php

示例7: postProcess

 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $params = $this->exportValues();
     $this->set('discountSection', 0);
     if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
         $this->buildAmountLabel();
         $this->set('discountSection', 1);
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', '#isDiscount'));
         return;
     }
     $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
     if ($this->_id) {
         require_once 'CRM/Price/BAO/Set.php';
         // delete all the prior label values or discounts in the custom options table
         // and delete a price set if one exists
         if (!CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
             require_once 'CRM/Core/OptionGroup.php';
             CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}");
             CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}.discount.%", "LIKE");
         }
     }
     if ($params['is_monetary']) {
         if ($params['price_set_id']) {
             CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
         } else {
             // if there are label / values, create custom options for them
             $labels = CRM_Utils_Array::value('label', $params);
             $values = CRM_Utils_Array::value('value', $params);
             $default = CRM_Utils_Array::value('default', $params);
             $options = array();
             if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 if (!empty($options)) {
                     $params['default_fee_id'] = null;
                     CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}", $options, $params['default_fee_id']);
                 }
             }
             if (CRM_Utils_Array::value('is_discount', $params) == 1) {
                 // if there are discounted set of label / values,
                 // create custom options for them
                 $labels = CRM_Utils_Array::value('discounted_label', $params);
                 $values = CRM_Utils_Array::value('discounted_value', $params);
                 $default = CRM_Utils_Array::value('discounted_default', $params);
                 if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                     for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
                         $discountOptions = array();
                         for ($i = 1; $i < self::NUM_OPTION; $i++) {
                             if (!empty($labels[$i]) && CRM_Utils_Array::value($j, $values[$i])) {
                                 $discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                             }
                         }
                         if (!empty($discountOptions)) {
                             $params['default_discount_fee_id'] = null;
                             $discountOptionsGroupId = CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}.discount.{$params['discount_name'][$j]}", $discountOptions, $params['default_discount_fee_id'], $params['discount_name'][$j]);
                             $discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'option_group_id' => $discountOptionsGroupId, 'start_date' => CRM_Utils_Date::format($params["discount_start_date"][$j]), 'end_date' => CRM_Utils_Date::format($params["discount_end_date"][$j]));
                             require_once 'CRM/Core/BAO/Discount.php';
                             CRM_Core_BAO_Discount::add($discountParams);
                         }
                     }
                 }
             }
         }
     } else {
         $params['contribution_type_id'] = '';
     }
     //update events table
     require_once 'CRM/Event/BAO/Event.php';
     $params['id'] = $this->_id;
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:82,代码来源:Fee.php

示例8: postProcess

 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $eventTitle = '';
     $params = $this->exportValues();
     $this->set('discountSection', 0);
     if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
         $this->buildAmountLabel();
         $this->set('discountSection', 2);
         return;
     }
     if (array_key_exists('payment_processor', $params) && !CRM_Utils_System::isNull($params['payment_processor'])) {
         $params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['payment_processor']));
     } else {
         $params['payment_processor'] = 'null';
     }
     $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
     if ($this->_id) {
         // delete all the prior label values or discounts in the custom options table
         // and delete a price set if one exists
         if (CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
             CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
         }
     }
     if ($params['is_monetary']) {
         if (CRM_Utils_Array::value('price_set_id', $params)) {
             CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
             if (CRM_Utils_Array::value('price_field_id', $params)) {
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $params['price_field_id'], 'price_set_id');
                 CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
             }
         } else {
             // if there are label / values, create custom options for them
             $labels = CRM_Utils_Array::value('label', $params);
             $values = CRM_Utils_Array::value('value', $params);
             $default = CRM_Utils_Array::value('default', $params);
             $options = array();
             if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 if (!empty($options)) {
                     $params['default_fee_id'] = NULL;
                     if (!CRM_Utils_Array::value('price_set_id', $params)) {
                         if (!CRM_Utils_Array::value('price_field_id', $params)) {
                             $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
                             if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle, 'id', 'title')) {
                                 $setParams['name'] = $setParams['title'] = $eventTitle;
                             } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle . '_' . $this->_id, 'id', 'title')) {
                                 $setParams['name'] = $setParams['title'] = $eventTitle . '_' . $this->_id;
                             } else {
                                 $timeSec = explode(".", microtime(true));
                                 $setParams['name'] = $setParams['title'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                             }
                             $setParams['is_quick_config'] = 1;
                             $setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
                             $priceSet = CRM_Price_BAO_Set::create($setParams);
                             $fieldParams['name'] = $fieldParams['label'] = $params['fee_label'];
                             $fieldParams['price_set_id'] = $priceSet->id;
                         } else {
                             foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
                                 if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
                                     CRM_Price_BAO_FieldValue::setIsActive($fieldValueID, '0');
                                     unset($params['price_field_value'][$arrayID]);
                                 }
                             }
                             $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
                             $fieldParams['option_id'] = $params['price_field_value'];
                             $priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
                         }
                         $fieldParams['html_type'] = 'Radio';
                         CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $priceSet->id);
                         $fieldParams['option_label'] = $params['label'];
                         $fieldParams['option_amount'] = $params['value'];
                         foreach ($options as $value) {
                             $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                         }
                         $fieldParams['default_option'] = $params['default'];
                         $priceField = CRM_Price_BAO_Field::create($fieldParams);
                     }
                 }
             }
             $discountPriceSets = CRM_Utils_Array::value('discount_price_set', $this->_defaultValues) ? $this->_defaultValues['discount_price_set'] : array();
             $discountFieldIDs = CRM_Utils_Array::value('discount_option_id', $this->_defaultValues) ? $this->_defaultValues['discount_option_id'] : array();
             if (CRM_Utils_Array::value('is_discount', $params) == 1) {
                 // if there are discounted set of label / values,
                 // create custom options for them
                 $labels = CRM_Utils_Array::value('discounted_label', $params);
                 $values = CRM_Utils_Array::value('discounted_value', $params);
                 $default = CRM_Utils_Array::value('discounted_default', $params);
                 if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                     for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Fee.php

示例9: deleteContribution

 /**
  * Delete the indirect records associated with this contribution first
  *
  * @return $results no of deleted Contribution on success, false otherwise
  * @access public
  * @static
  */
 static function deleteContribution($id)
 {
     CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
     $transaction = new CRM_Core_Transaction();
     $results = NULL;
     //delete activity record
     $params = array('source_record_id' => $id, 'activity_type_id' => 6);
     CRM_Activity_BAO_Activity::deleteActivity($params);
     //delete billing address if exists for this contribution.
     self::deleteAddress($id);
     //update pledge and pledge payment, CRM-3961
     CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
     // remove entry from civicrm_price_set_entity, CRM-5095
     if (CRM_Price_BAO_Set::getFor('civicrm_contribution', $id)) {
         CRM_Price_BAO_Set::removeFrom('civicrm_contribution', $id);
     }
     // cleanup line items.
     $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
     // delete any related entity_financial_trxn and financial_trxn records.
     CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id, 'civicrm_contribution');
     if ($participantId) {
         CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
     } else {
         CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
     }
     //delete note.
     $note = CRM_Core_BAO_Note::getNote($id, 'civicrm_contribution');
     $noteId = key($note);
     if ($noteId) {
         CRM_Core_BAO_Note::del($noteId, FALSE);
     }
     $dao = new CRM_Contribute_DAO_Contribution();
     $dao->id = $id;
     $results = $dao->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
     // delete the recently created Contribution
     $contributionRecent = array('id' => $id, 'type' => 'Contribution');
     CRM_Utils_Recent::del($contributionRecent);
     return $results;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:48,代码来源:Contribution.php

示例10: postProcess


//.........这里部分代码省略.........
                 } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $pageTitle . '_' . $this->_id, 'id', 'name')) {
                     $setParams['name'] = $pageTitle . '_' . $this->_id;
                 } else {
                     $timeSec = explode(".", microtime(true));
                     $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                 }
                 $setParams['is_quick_config'] = 1;
                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
                 $setParams['contribution_type_id'] = CRM_Utils_Array::value('contribution_type_id', $this->_values);
                 $priceSet = CRM_Price_BAO_Set::create($setParams);
                 $priceSetID = $priceSet->id;
                 $fieldParams['price_set_id'] = $priceSet->id;
             } elseif ($usedPriceSetId) {
                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
                 $setParams['contribution_type_id'] = CRM_Utils_Array::value('contribution_type_id', $this->_values);
                 $setParams['id'] = $usedPriceSetId;
                 $priceSet = CRM_Price_BAO_Set::create($setParams);
                 $priceSetID = $priceSet->id;
                 $fieldParams['price_set_id'] = $priceSet->id;
             } else {
                 $fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params);
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
             }
             $editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount');
             $editedResults = array();
             CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
             if (!CRM_Utils_Array::value('id', $editedResults)) {
                 $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
                 $fieldParams['label'] = CRM_Utils_Array::value('new_title', $params) ? $params['new_title'] : 'Membership Amount';
                 if (!CRM_Utils_Array::value('mem_price_field_id', $params)) {
                     CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_Field', 0, 1, array('price_set_id' => $priceSetID));
                 }
                 $fieldParams['weight'] = 1;
             } else {
                 $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
             }
             $fieldParams['is_active'] = 1;
             $fieldParams['html_type'] = 'Radio';
             $fieldParams['is_required'] = CRM_Utils_Array::value('is_required', $params) ? 1 : 0;
             $fieldParams['is_display_amounts'] = CRM_Utils_Array::value('display_min_fee', $params) ? 1 : 0;
             $rowCount = 1;
             $options = array();
             if (CRM_Utils_Array::value('id', $fieldParams)) {
                 CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_FieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
             }
             foreach ($membershipTypes as $memType => $memAutoRenew) {
                 if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
                     $fieldParams['option_id'][$rowCount] = $priceFieldID;
                     unset($options[$priceFieldID]);
                 }
                 $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
                 $fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
                 $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
                 $fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
                 $fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
                 $fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params);
                 $fieldParams['membership_type_id'][$rowCount] = $memType;
                 // [$rowCount] = $membetype[''];
                 $rowCount++;
             }
             foreach ($options as $priceFieldID => $memType) {
                 CRM_Price_BAO_FieldValue::setIsActive($priceFieldID, '0');
             }
             $priceField = CRM_Price_BAO_Field::create($fieldParams);
         } elseif (!$priceSetID) {
             $deletePriceSet = 1;
         }
         $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
         $params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
         if ($priceSetID) {
             $params['membership_types'] = 'null';
             $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
             $params['membership_types'] = serialize($membershipTypes);
             $params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
             $params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
         }
         $params['entity_table'] = 'civicrm_contribution_page';
         $params['entity_id'] = $this->_id;
         $dao = new CRM_Member_DAO_MembershipBlock();
         $dao->copyValues($params);
         $dao->save();
         if ($priceSetID && $params['is_active']) {
             CRM_Price_BAO_Set::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
         }
         if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
             if ($this->_memPriceSetId) {
                 $pFIDs = array();
                 $conditionParams = array('price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount');
                 CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_Field', $conditionParams, $pFIDs);
                 if (!CRM_Utils_Array::value('id', $pFIDs)) {
                     CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id);
                     CRM_Price_BAO_Set::setIsQuickConfig($this->_memPriceSetId, '0');
                 } else {
                     CRM_Price_BAO_Field::setIsActive($params['mem_price_field_id'], '0');
                 }
             }
         }
     }
     parent::endPostProcess();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:MembershipBlock.php

示例11: postProcess

 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $transaction = new CRM_Core_Transaction();
     // first delete the join entries associated with this contribution page
     $dao = new CRM_Core_DAO_UFJoin();
     $params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
     $dao->copyValues($params);
     $dao->delete();
     //next delete the membership block fields
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->delete();
     //next delete the pcp block fields
     $dao = new CRM_PCP_DAO_PCPBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->delete();
     // need to delete premiums. CRM-4586
     CRM_Contribute_BAO_Premium::deletePremium($this->_id);
     // price set cleanup, CRM-5527
     CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id);
     // finally delete the contribution page
     $dao = new CRM_Contribute_DAO_ContributionPage();
     $dao->id = $this->_id;
     $dao->delete();
     $transaction->commit();
     CRM_Core_Session::setStatus(ts('The contribution page \'%1\' has been deleted.', array(1 => $this->_title)));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:Delete.php


注:本文中的CRM_Price_BAO_Set::removeFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。