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


PHP CRM_Core_BAO_FinancialTrxn::createPremiumTrxn方法代码示例

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


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

示例1: createPremiumTrxn

 /**
  * create financial transaction for premium
  *
  * @access public
  * @static
  */
 static function createPremiumTrxn($params)
 {
     if ((empty($params['financial_type_id']) || empty($params['contributionId'])) && empty($params['oldPremium'])) {
         return;
     }
     if (!empty($params['cost'])) {
         $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         $financialAccountType = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id']);
         $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND label IN ('Premiums Inventory Account is', 'Cost of Sales Account is')");
         $toFinancialAccount = !empty($params['isDeleted']) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is';
         $fromFinancialAccount = !empty($params['isDeleted']) ? 'Cost of Sales Account is' : 'Premiums Inventory Account is';
         $accountRelationship = array_flip($accountRelationship);
         $financialtrxn = array('to_financial_account_id' => $financialAccountType[$accountRelationship[$toFinancialAccount]], 'from_financial_account_id' => $financialAccountType[$accountRelationship[$fromFinancialAccount]], 'trxn_date' => date('YmdHis'), 'total_amount' => CRM_Utils_Array::value('cost', $params) ? $params['cost'] : 0, 'currency' => CRM_Utils_Array::value('currency', $params), 'status_id' => array_search('Completed', $contributionStatuses));
         $trxnEntityTable['entity_table'] = 'civicrm_contribution';
         $trxnEntityTable['entity_id'] = $params['contributionId'];
         CRM_Core_BAO_FinancialTrxn::create($financialtrxn, $trxnEntityTable);
     }
     if (!empty($params['oldPremium'])) {
         $premiumParams = array('id' => $params['oldPremium']['product_id']);
         $productDetails = array();
         CRM_Contribute_BAO_ManagePremiums::retrieve($premiumParams, $productDetails);
         $params = array('cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $params['oldPremium']['contribution_id'], 'isDeleted' => TRUE);
         CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($params);
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:31,代码来源:FinancialTrxn.php

示例2: processPremium

 /**
  * Process the Premium Information.
  *
  * @param array $params
  * @param int $contributionID
  * @param int $premiumID
  * @param array $options
  */
 public static function processPremium($params, $contributionID, $premiumID = NULL, $options = array())
 {
     $selectedProductID = $params['product_name'][0];
     $selectedProductOptionID = CRM_Utils_Array::value(1, $params['product_name']);
     $dao = new CRM_Contribute_DAO_ContributionProduct();
     $dao->contribution_id = $contributionID;
     $dao->product_id = $selectedProductID;
     $dao->fulfilled_date = CRM_Utils_Date::processDate($params['fulfilled_date'], NULL, TRUE);
     $isDeleted = FALSE;
     //CRM-11106
     $premiumParams = array('id' => $selectedProductID);
     $productDetails = array();
     CRM_Contribute_BAO_ManagePremiums::retrieve($premiumParams, $productDetails);
     $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails);
     if (!empty($options[$selectedProductID])) {
         $dao->product_option = $options[$selectedProductID][$selectedProductOptionID];
     }
     if ($premiumID) {
         $ContributionProduct = new CRM_Contribute_DAO_ContributionProduct();
         $ContributionProduct->id = $premiumID;
         $ContributionProduct->find(TRUE);
         if ($ContributionProduct->product_id == $selectedProductID) {
             $dao->id = $premiumID;
         } else {
             $ContributionProduct->delete();
             $isDeleted = TRUE;
         }
     }
     $dao->save();
     //CRM-11106
     if ($premiumID == NULL || $isDeleted) {
         $premiumParams = array('cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $contributionID);
         if ($isDeleted) {
             $premiumParams['oldPremium']['product_id'] = $ContributionProduct->product_id;
             $premiumParams['oldPremium']['contribution_id'] = $ContributionProduct->contribution_id;
         }
         CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($premiumParams);
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:47,代码来源:AdditionalInfo.php

示例3: postProcessPremium

 /**
  * Process the form.
  *
  * @param array $premiumParams
  * @param CRM_Contribute_BAO_Contribution $contribution
  */
 protected function postProcessPremium($premiumParams, $contribution)
 {
     $hour = $minute = $second = 0;
     // assigning Premium information to receipt tpl
     $selectProduct = CRM_Utils_Array::value('selectProduct', $premiumParams);
     if ($selectProduct && $selectProduct != 'no_thanks') {
         $startDate = $endDate = "";
         $this->assign('selectPremium', TRUE);
         $productDAO = new CRM_Contribute_DAO_Product();
         $productDAO->id = $selectProduct;
         $productDAO->find(TRUE);
         $this->assign('product_name', $productDAO->name);
         $this->assign('price', $productDAO->price);
         $this->assign('sku', $productDAO->sku);
         $this->assign('option', CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams));
         $periodType = $productDAO->period_type;
         if ($periodType) {
             $fixed_period_start_day = $productDAO->fixed_period_start_day;
             $duration_unit = $productDAO->duration_unit;
             $duration_interval = $productDAO->duration_interval;
             if ($periodType == 'rolling') {
                 $startDate = date('Y-m-d');
             } elseif ($periodType == 'fixed') {
                 if ($fixed_period_start_day) {
                     $date = explode('-', date('Y-m-d'));
                     $month = substr($fixed_period_start_day, 0, strlen($fixed_period_start_day) - 2);
                     $day = substr($fixed_period_start_day, -2) . "<br/>";
                     $year = $date[0];
                     $startDate = $year . '-' . $month . '-' . $day;
                 } else {
                     $startDate = date('Y-m-d');
                 }
             }
             $date = explode('-', $startDate);
             $year = $date[0];
             $month = $date[1];
             $day = $date[2];
             switch ($duration_unit) {
                 case 'year':
                     $year = $year + $duration_interval;
                     break;
                 case 'month':
                     $month = $month + $duration_interval;
                     break;
                 case 'day':
                     $day = $day + $duration_interval;
                     break;
                 case 'week':
                     $day = $day + $duration_interval * 7;
             }
             $endDate = date('Y-m-d H:i:s', mktime($hour, $minute, $second, $month, $day, $year));
             $this->assign('start_date', $startDate);
             $this->assign('end_date', $endDate);
         }
         $dao = new CRM_Contribute_DAO_Premium();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $this->_id;
         $dao->find(TRUE);
         $this->assign('contact_phone', $dao->premiums_contact_phone);
         $this->assign('contact_email', $dao->premiums_contact_email);
         //create Premium record
         $params = array('product_id' => $premiumParams['selectProduct'], 'contribution_id' => $contribution->id, 'product_option' => CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams), 'quantity' => 1, 'start_date' => CRM_Utils_Date::customFormat($startDate, '%Y%m%d'), 'end_date' => CRM_Utils_Date::customFormat($endDate, '%Y%m%d'));
         if (!empty($premiumParams['selectProduct'])) {
             $daoPremiumsProduct = new CRM_Contribute_DAO_PremiumsProduct();
             $daoPremiumsProduct->product_id = $premiumParams['selectProduct'];
             $daoPremiumsProduct->premiums_id = $dao->id;
             $daoPremiumsProduct->find(TRUE);
             $params['financial_type_id'] = $daoPremiumsProduct->financial_type_id;
         }
         //Fixed For CRM-3901
         $daoContrProd = new CRM_Contribute_DAO_ContributionProduct();
         $daoContrProd->contribution_id = $contribution->id;
         if ($daoContrProd->find(TRUE)) {
             $params['id'] = $daoContrProd->id;
         }
         CRM_Contribute_BAO_Contribution::addPremium($params);
         if ($productDAO->cost && !empty($params['financial_type_id'])) {
             $trxnParams = array('cost' => $productDAO->cost, 'currency' => $productDAO->currency, 'financial_type_id' => $params['financial_type_id'], 'contributionId' => $contribution->id);
             CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($trxnParams);
         }
     } elseif ($selectProduct == 'no_thanks') {
         //Fixed For CRM-3901
         $daoContrProd = new CRM_Contribute_DAO_ContributionProduct();
         $daoContrProd->contribution_id = $contribution->id;
         if ($daoContrProd->find(TRUE)) {
             $daoContrProd->delete();
         }
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:95,代码来源:Confirm.php

示例4: processPremium

 /**
  * Function to process the Premium Information
  *
  * @access public
  *
  * @return None
  */
 static function processPremium(&$params, $contributionID, $premiumID = NULL, &$options = NULL)
 {
     $dao = new CRM_Contribute_DAO_ContributionProduct();
     $dao->contribution_id = $contributionID;
     $dao->product_id = $params['product_name'][0];
     $dao->fulfilled_date = CRM_Utils_Date::processDate($params['fulfilled_date'], NULL, TRUE);
     $isDeleted = False;
     //CRM-11106
     $premiumParams = array('id' => $params['product_name'][0]);
     $productDetails = array();
     CRM_Contribute_BAO_ManagePremiums::retrieve($premiumParams, $productDetails);
     $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails);
     if (CRM_Utils_Array::value($params['product_name'][0], $options)) {
         $dao->product_option = $options[$params['product_name'][0]][$params['product_name'][1]];
     }
     if ($premiumID) {
         $premoumDAO = new CRM_Contribute_DAO_ContributionProduct();
         $premoumDAO->id = $premiumID;
         $premoumDAO->find(TRUE);
         if ($premoumDAO->product_id == $params['product_name'][0]) {
             $dao->id = $premiumID;
             $premium = $dao->save();
         } else {
             $premoumDAO->delete();
             $isDeleted = TRUE;
             $premium = $dao->save();
         }
     } else {
         $premium = $dao->save();
     }
     //CRM-11106
     if ($premiumID == NULL || $isDeleted) {
         $params = array('cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $contributionID);
         if ($isDeleted) {
             $params['oldPremium']['product_id'] = $premoumDAO->product_id;
             $params['oldPremium']['contribution_id'] = $premoumDAO->contribution_id;
         }
         CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($params);
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:47,代码来源:AdditionalInfo.php


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