Skip to content

Commit

Permalink
fix missing usage table
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Apr 20, 2023
1 parent 1cf6a02 commit b2f6d53
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 1 addition & 5 deletions CRM/Price/Page/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,8 @@ public function run() {
);

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);

Expand Down
6 changes: 2 additions & 4 deletions templates/CRM/Price/Page/Field.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
{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}

Expand Down
4 changes: 1 addition & 3 deletions templates/CRM/Price/Page/Set.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
6 changes: 6 additions & 0 deletions templates/CRM/Price/Page/table.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<th scope="col">{ts}Date(s){/ts}</th>
</thead>

{if array_key_exists('civicrm_event', $usedBy)}
{foreach from=$usedBy.civicrm_event item=event key=id}
<tr>
<td><a href="{crmURL p="civicrm/event/manage/fee" q="action=update&reset=1&id=`$id`"}" title="{ts}Change or remove the price set used for this event.{/ts}">{$event.title}</a></td>
Expand All @@ -31,6 +32,7 @@
<td>{$event.startDate|crmDate}{if $event.endDate}&nbsp;to&nbsp;{$event.endDate|crmDate}{/if}</td>
</tr>
{/foreach}
{/if}
</table>
{/if}
{if $context EQ "Contribution"}
Expand All @@ -47,13 +49,15 @@
<th scope="col">{ts}Date(s){/ts}</th>
</thead>

{if array_key_exists('civicrm_contribution_page', $usedBy)}
{foreach from=$usedBy.civicrm_contribution_page item=contributionPage key=id}
<tr>
<td><a href="{crmURL p="civicrm/admin/contribute/settings" q="action=update&reset=1&id=`$id`"}" title="{ts}Change or remove the price set used for this contribution page.{/ts}">{$contributionPage.title}</a></td>
<td>{$contributionPage.type}</td>
<td>{$contributionPage.startDate|truncate:10:''|crmDate}{if $contributionPage.endDate}&nbsp;to&nbsp;{$contributionPage.endDate|truncate:10:''|crmDate}{/if}</td>
</tr>
{/foreach}
{/if}
</table>
{/if}
{if $context EQ "EventTemplate"}
Expand All @@ -69,13 +73,15 @@
<th scope="col">{ts}Type{/ts}</th>
<th scope="col">{ts}Public{/ts}</th>
</thead>
{if array_key_exists('civicrm_event_template', $usedBy)}
{foreach from=$usedBy.civicrm_event_template item=eventTemplate key=id}
<tr>
<td><a href="{crmURL p="civicrm/event/manage/fee" q="action=update&reset=1&id=`$id`"}" title="{ts}Change or remove the price set used for this event template.{/ts}">{$eventTemplate.title}</a></td>
<td>{$eventTemplate.eventType}</td>
<td>{if $eventTemplate.isPublic}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}</td>
</tr>
{/foreach}
{/if}
</table>
{/if}
{/foreach}

0 comments on commit b2f6d53

Please sign in to comment.