Esempio n. 1
0
 /**
  * Takes an associative array and creates a price set object.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
  */
 public static function create(&$params)
 {
     $priceSetBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set();
     $priceSetBAO->copyValues($params);
     if (self::eventPriceSetDomainID()) {
         $priceSetBAO->domain_id = CRM_Core_Config::domainID();
     }
     return $priceSetBAO->save();
 }
Esempio n. 2
0
 /**
  * (Queue Task Callback)
  *
  * Find any participant records and create corresponding line-item
  * records.
  *
  * @param CRM_Queue_TaskContext $ctx
  * @param int $startId
  *   the first/lowest participant ID to convert.
  * @param int $endId
  *   the last/highest participant ID to convert.
  *
  * @return bool
  */
 public static function task_4_2_alpha1_convertParticipants(CRM_Queue_TaskContext $ctx, $startId, $endId)
 {
     $upgrade = new CRM_Upgrade_Form();
     //create lineitems for participant in edge cases using default price set for contribution.
     $query = "\nSELECT    cp.id as participant_id, cp.fee_amount, cp.fee_level,ce.is_monetary,\n          cpse.price_set_id, cpf.id as price_field_id, cpfv.id as price_field_value_id\nFROM      civicrm_participant cp\nLEFT JOIN civicrm_line_item cli ON cli.entity_id=cp.id and cli.entity_table = 'civicrm_participant'\nLEFT JOIN civicrm_event ce ON ce.id=cp.event_id\nLEFT JOIN civicrm_price_set_entity cpse ON cp.event_id = cpse.entity_id and cpse.entity_table = 'civicrm_event'\nLEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpse.price_set_id\nLEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id AND cpfv.label = cp.fee_level\nWHERE     (cp.id BETWEEN %1 AND %2)\nAND       cli.entity_id IS NULL AND cp.fee_amount IS NOT NULL";
     $sqlParams = array(1 => array($startId, 'Integer'), 2 => array($endId, 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
     if ($dao->N) {
         $defaultPriceSetId = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
         $priceSets = current(CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::getSetDetail($defaultPriceSetId));
         $fieldID = key($priceSets['fields']);
     }
     while ($dao->fetch()) {
         $lineParams = array('entity_table' => 'civicrm_participant', 'entity_id' => $dao->participant_id, 'label' => $dao->fee_level ? $dao->fee_level : ts('Default'), 'qty' => 1, 'unit_price' => $dao->fee_amount, 'line_total' => $dao->fee_amount, 'participant_count' => 1);
         if ($dao->is_monetary && $dao->price_field_id) {
             $lineParams += array('price_field_id' => $dao->price_field_id, 'price_field_value_id' => $dao->price_field_value_id);
             $priceSetId = $dao->price_set_id;
         } else {
             $lineParams['price_field_id'] = $fieldID;
             $priceSetId = $defaultPriceSetId;
         }
         CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
     }
     return TRUE;
 }