From 5a4a15e5d5537f13b2e1aa0e29578b7a10145270 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 22 Sep 2015 13:00:11 +0530 Subject: [PATCH] additional fix for same price option labels --- CRM/Price/BAO/PriceFieldValue.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 07fd6ef49f..f321397a74 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -301,19 +301,18 @@ WHERE cpse.id IS NOT NULL {$where}"; while ($lineItem->fetch()) { $lineItem->label = $newLabel; $lineItem->save(); - } - - // update amount and fee level in civicrm_contribution and civicrm_participant - $prevLabel = CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -'; - $newLabel = CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -'; - $params = array(1 => array($prevLabel, 'String'), 2 => array($newLabel, 'String')); - $query = CRM_Core_DAO::executeQuery("SELECT `id` as `contributionId` FROM `civicrm_contribution` WHERE `amount_level` LIKE '%{$prevLabel}%'"); - while ($query->fetch()) { - CRM_Core_DAO::executeQuery("UPDATE `civicrm_contribution` SET `amount_level` = REPLACE(amount_level, %1, %2) WHERE id = {$query->contributionId}", $params); - $participantIds = CRM_Event_BAO_Participant::getParticipantIds($query->contributionId); - foreach ($participantIds as $key => $id) { - if (!empty($id)) { - CRM_Core_DAO::executeQuery("UPDATE `civicrm_participant` SET `fee_level` = REPLACE(fee_level, %1, %2) WHERE id = {$id}", $params); + // update amount and fee level in civicrm_contribution and civicrm_participant + $params = array( + 1 => array(CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -', 'String'), + 2 => array(CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -', 'String'), + ); + if (!empty($lineItem->contribution_id)) { + CRM_Core_DAO::executeQuery("UPDATE `civicrm_contribution` SET `amount_level` = REPLACE(amount_level, %1, %2) WHERE id = {$lineItem->contribution_id}", $params); + $participantIds = CRM_Event_BAO_Participant::getParticipantIds($lineItem->contribution_id); + foreach ($participantIds as $key => $id) { + if (!empty($id)) { + CRM_Core_DAO::executeQuery("UPDATE `civicrm_participant` SET `fee_level` = REPLACE(fee_level, %1, %2) WHERE id = {$id}", $params); + } } } } -- 2.25.1