fix missing usage table
authordemeritcowboy <demeritcowboy@hotmail.com>
Thu, 20 Apr 2023 14:24:59 +0000 (10:24 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Mon, 24 Apr 2023 14:53:12 +0000 (10:53 -0400)
CRM/Price/Page/Field.php
templates/CRM/Price/Page/Field.tpl
templates/CRM/Price/Page/Set.tpl
templates/CRM/Price/Page/table.tpl

index c1a70040fdef3375d7f3ef267411d7a65f805086..bfa6feab97b3aaa98dc82e97bb223ef765e62d1c 100644 (file)
@@ -230,12 +230,8 @@ class CRM_Price_Page_Field extends CRM_Core_Page {
     );
 
     if ($this->_sid) {
-      $usedByDefaults = [
-        'civicrm_event' => FALSE,
-        'civicrm_contribution_page' => FALSE,
-      ];
       $usedBy = CRM_Price_BAO_PriceSet::getUsedBy($this->_sid);
-      $this->assign('usedBy', array_intersect_key($usedByDefaults, $usedBy));
+      $this->assign('usedBy', $usedBy);
       $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved');
       $this->assign('isReserved', $this->_isSetReserved);
 
index ff98309a5c1f57c43f78afd288cbc363e26ad1a9..bfe4393eaefb95f9e3832413fbe3c310a402e0fb 100644 (file)
   {include file="CRM/Price/Form/DeleteField.tpl"}
 {elseif $action eq 1024 }
   {include file="CRM/Price/Form/Preview.tpl"}
-{elseif ($usedBy and $action eq 8) or $usedBy.civicrm_event or $usedBy.civicrm_contribution_page}
+{elseif $usedBy}
   <div id="price_set_used_by" class="messages status no-popup">
     {icon icon="fa-info-circle"}{/icon}
     {if $action eq 8}
       {ts 1=$usedPriceSetTitle}Unable to delete the '%1' Price Field - it is currently in use by one or more active events or contribution pages or contributions  or event templates.{/ts}
     {/if}
 
-    {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template}
-      {include file="CRM/Price/Page/table.tpl"}
-    {/if}
+    {include file="CRM/Price/Page/table.tpl"}
   </div>
 {/if}
 
index bdd496f32b8d095efd1766732a4bf9d2ebe74b19..4e4e9e5b96ac768a3745ea42b0e901f414338bd8 100644 (file)
@@ -26,9 +26,7 @@
             {ts 1=$usedPriceSetTitle}Unable to delete the '%1' price set - it is currently in use by one or more active events or contribution pages or contributions or event templates.{/ts}
         {/if}
 
-      {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template}
-            {include file="CRM/Price/Page/table.tpl"}
-        {/if}
+        {include file="CRM/Price/Page/table.tpl"}
     </div>
     {/if}
 
index c7e514886ffe8c3b7030757524484dc6461615dd..922970d63883e0d74b465433ac56feb2a02dac2a 100644 (file)
@@ -7,8 +7,11 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
 *}
+{* The price field can be used somewhere but not necessarily in a page/event. In that case we still want to display some message. *}
+{assign var='showGenericMessage' value=true}
 {foreach from=$contexts item=context}
 {if $context EQ "Event"}
+  {assign var='showGenericMessage' value=false}
     {if $action eq 8}
         {ts}If you no longer want to use this price set, click the event title below, and modify the fees for that event.{/ts}
     {else}
@@ -34,6 +37,7 @@
 </table>
 {/if}
 {if $context EQ "Contribution"}
+  {assign var='showGenericMessage' value=false}
     {if $action eq 8}
         {ts}If you no longer want to use this price set, click the contribution page title below, and modify the Amounts or Membership tab configuration.{/ts}
     {else}
@@ -57,6 +61,7 @@
 </table>
 {/if}
 {if $context EQ "EventTemplate"}
+  {assign var='showGenericMessage' value=false}
   {if $action eq 8}
     {ts}If you no longer want to use this price set, click the event template title below, and modify the fees for that event.{/ts}
   {else}
@@ -79,3 +84,9 @@
 </table>
 {/if}
 {/foreach}
+{if $showGenericMessage}
+  {if $action neq 8}
+    {* We don't have to do anything for delete action because the calling tpl already displays something. *}
+    {ts}This price set is used by at least one contribution, but is not used by any active events or contribution pages or event templates.{/ts}
+  {/if}
+{/if}