Esempio n. 1
0
 /**
  * Copy priceSet when event/contibution page is copied
  *
  * @param string $baoName
  *   BAO name.
  * @param int $id
  *   Old event/contribution page id.
  * @param int $newId
  *   Newly created event/contribution page id.
  */
 public static function copyPriceSet($baoName, $id, $newId)
 {
     $priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
     if ($priceSetId) {
         $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
         if ($isQuickConfig) {
             $copyPriceSet = CRM_Price_BAO_PriceSet::copy($priceSetId);
             CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
         } else {
             $copyPriceSet =& CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSetEntity', array('entity_id' => $id, 'entity_table' => $baoName), array('entity_id' => $newId));
         }
         // copy event discount
         if ($baoName == 'civicrm_event') {
             $discount = CRM_Core_BAO_Discount::getOptionGroup($id, 'civicrm_event');
             foreach ($discount as $discountId => $setId) {
                 $copyPriceSet =& CRM_Price_BAO_PriceSet::copy($setId);
                 CRM_Core_DAO::copyGeneric('CRM_Core_DAO_Discount', array('id' => $discountId), array('entity_id' => $newId, 'price_set_id' => $copyPriceSet->id));
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * This function is to make a copy of a price set, including
  * all the fields in the page
  *
  * @return void
  * @access public
  */
 function copy()
 {
     $id = CRM_Utils_Request::retrieve('sid', 'Positive', $this, TRUE, 0, 'GET');
     CRM_Price_BAO_PriceSet::copy($id);
     CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
 }