/**
  * Creates or updates a participant payment record.
  *
  * @param array $params
  *   of values to initialize the record with.
  * @param array $ids
  *   with one values of id for this participantPayment record (for update).
  *
  * @return object
  *   the partcipant payment record
  */
 public static function create(&$params, &$ids)
 {
     if (isset($ids['id'])) {
         CRM_Utils_Hook::pre('edit', 'ParticipantPayment', $ids['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'ParticipantPayment', NULL, $params);
     }
     $participantPayment = new CRM_Event_BAO_ParticipantPayment();
     $participantPayment->copyValues($params);
     if (isset($ids['id'])) {
         $participantPayment->id = CRM_Utils_Array::value('id', $ids);
     } else {
         $participantPayment->find(TRUE);
     }
     $participantPayment->save();
     if (isset($ids['id'])) {
         CRM_Utils_Hook::post('edit', 'ParticipantPayment', $ids['id'], $participantPayment);
     } else {
         CRM_Utils_Hook::post('create', 'ParticipantPayment', NULL, $participantPayment);
     }
     //generally if people are creating participant_payments via the api they won't be setting the line item correctly - we can't help them if they are doing complex transactions
     // but if they have a single line item for the contribution we can assume it should refer to the participant line
     $lineItemCount = CRM_Core_DAO::singleValueQuery("select count(*) FROM civicrm_line_item WHERE contribution_id = %1", array(1 => array($participantPayment->contribution_id, 'Integer')));
     if ($lineItemCount == 1) {
         $sql = "UPDATE civicrm_line_item li\n      SET entity_table = 'civicrm_participant', entity_id = %1\n      WHERE contribution_id = %2 AND entity_table = 'civicrm_contribution'";
         CRM_Core_DAO::executeQuery($sql, array(1 => array($participantPayment->participant_id, 'Integer'), 2 => array($participantPayment->contribution_id, 'Integer')));
     }
     return $participantPayment;
 }
 static function &create(&$params, &$ids)
 {
     $paymentParticipant = new CRM_Event_BAO_ParticipantPayment();
     $paymentParticipant->copyValues($params);
     if (isset($ids['id'])) {
         $paymentParticipant->id = CRM_Utils_Array::value('id', $ids);
     } else {
         $paymentParticipant->find(true);
     }
     $paymentParticipant->save();
     return $paymentParticipant;
 }
Esempio n. 3
0
 /**
  * Creates or updates a participant payment record
  *
  * @param $params array of values to initialize the record with
  * @param $ids    array with one values of id for this participantPayment record (for update)
  *
  * @return object the partcipant payment record
  * @static
  */
 static function &create(&$params, &$ids)
 {
     if (isset($ids['id'])) {
         CRM_Utils_Hook::pre('edit', 'ParticipantPayment', $ids['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'ParticipantPayment', NULL, $params);
     }
     $participantPayment = new CRM_Event_BAO_ParticipantPayment();
     $participantPayment->copyValues($params);
     if (isset($ids['id'])) {
         $participantPayment->id = CRM_Utils_Array::value('id', $ids);
     } else {
         $participantPayment->find(TRUE);
     }
     $participantPayment->save();
     if (isset($ids['id'])) {
         CRM_Utils_Hook::post('edit', 'ParticipantPayment', $ids['id'], $participantPayment);
     } else {
         CRM_Utils_Hook::post('create', 'ParticipantPayment', NULL, $participantPayment);
     }
     return $participantPayment;
 }