From: Pratik Joshi Date: Mon, 3 Jun 2013 06:17:10 +0000 (+0530) Subject: CRM-12741 : did event template handing while price set deletion i.e appropriate messa... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c34e4bb47e0204238207f3391bc7ab172ff2e2f1;p=civicrm-core.git CRM-12741 : did event template handing while price set deletion i.e appropriate message display while deleting price set used for event templates so can user is aware of price set / field usage --- diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index 667a942d66..74caa4451f 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -93,6 +93,7 @@ class CRM_Admin_Page_AJAX { $comps = array( 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', + 'EventTemplate' => 'civicrm_event_template' ); $contexts = array(); foreach ($comps as $name => $table) { diff --git a/CRM/Price/BAO/Set.php b/CRM/Price/BAO/Set.php index e7434dc347..ecee3b7b01 100644 --- a/CRM/Price/BAO/Set.php +++ b/CRM/Price/BAO/Set.php @@ -201,7 +201,7 @@ WHERE cpf.price_set_id = %1"; switch ($table) { case 'civicrm_event': $ids = implode(',', $entities); - $queryString = "SELECT ce.id as id, ce.title as title, ce.is_public as isPublic, ce.start_date as startDate, ce.end_date as endDate, civicrm_option_value.label as eventType + $queryString = "SELECT ce.id as id, ce.title as title, ce.is_public as isPublic, ce.start_date as startDate, ce.end_date as endDate, civicrm_option_value.label as eventType, ce.is_template as isTemplate, ce.template_title as templateTitle FROM civicrm_event ce LEFT JOIN civicrm_option_value ON ( ce.event_type_id = civicrm_option_value.value ) @@ -209,16 +209,22 @@ LEFT JOIN civicrm_option_group ON ( civicrm_option_group.id = civicrm_option_value.option_group_id ) WHERE civicrm_option_group.name = 'event_type' AND - ( ce.is_template IS NULL OR ce.is_template = 0) AND ce.id IN ($ids) AND ce.is_active = 1;"; $crmDAO = CRM_Core_DAO::executeQuery($queryString); while ($crmDAO->fetch()) { - $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title; - $usedBy[$table][$crmDAO->id]['eventType'] = $crmDAO->eventType; - $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate; - $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate; - $usedBy[$table][$crmDAO->id]['isPublic'] = $crmDAO->isPublic; + if ($crmDAO->isTemplate) { + $usedBy['civicrm_event_template'][$crmDAO->id]['title'] = $crmDAO->templateTitle; + $usedBy['civicrm_event_template'][$crmDAO->id]['eventType'] = $crmDAO->eventType; + $usedBy['civicrm_event_template'][$crmDAO->id]['isPublic'] = $crmDAO->isPublic; + } + else { + $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title; + $usedBy[$table][$crmDAO->id]['eventType'] = $crmDAO->eventType; + $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate; + $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate; + $usedBy[$table][$crmDAO->id]['isPublic'] = $crmDAO->isPublic; + } } break; diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 4151ed7be7..8870bec4ac 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -248,6 +248,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $comps = array( 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', + 'EventTemplate' => 'civicrm_event_template' ); $priceSetContexts = array(); foreach ($comps as $name => $table) { diff --git a/CRM/Price/Page/Set.php b/CRM/Price/Page/Set.php index 184ffc420e..9940d67c7f 100644 --- a/CRM/Price/Page/Set.php +++ b/CRM/Price/Page/Set.php @@ -181,6 +181,7 @@ class CRM_Price_Page_Set extends CRM_Core_Page { $comps = array( 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', + 'EventTemplate' => 'civicrm_event_template' ); $priceSetContexts = array(); foreach ($comps as $name => $table) { diff --git a/templates/CRM/Price/Page/Field.tpl b/templates/CRM/Price/Page/Field.tpl index e1a4a58348..a285404f47 100644 --- a/templates/CRM/Price/Page/Field.tpl +++ b/templates/CRM/Price/Page/Field.tpl @@ -34,10 +34,10 @@
{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.{/ts} + {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} + {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template} {include file="CRM/Price/Page/table.tpl"} {/if}
diff --git a/templates/CRM/Price/Page/Set.tpl b/templates/CRM/Price/Page/Set.tpl index 88d5d969a8..9366163a3b 100644 --- a/templates/CRM/Price/Page/Set.tpl +++ b/templates/CRM/Price/Page/Set.tpl @@ -39,10 +39,10 @@
{if $action eq 8} - {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.{/ts} + {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} + {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template} {include file="CRM/Price/Page/table.tpl"} {/if}
diff --git a/templates/CRM/Price/Page/table.tpl b/templates/CRM/Price/Page/table.tpl index 74c9538039..c7e451a8a3 100644 --- a/templates/CRM/Price/Page/table.tpl +++ b/templates/CRM/Price/Page/table.tpl @@ -72,4 +72,26 @@ {/foreach} {/if} -{/foreach} +{if $context EQ "EventTemplate"} + {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} + {ts}This price set is used by the event template(s) listed below. Click the event template title to change or remove the price set.{/ts} + {/if} +

+ + + + + + + {foreach from=$usedBy.civicrm_event_template item=eventTemplate key=id} + + + + + + {/foreach} +
{ts}Event Template Name{/ts}{ts}Type{/ts}{ts}Public{/ts}
{$eventTemplate.title}{$eventTemplate.eventType}{if $eventTemplate.isPublic}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
+{/if} +{/foreach} \ No newline at end of file