CRM-12741 : did event template handing while price set deletion i.e appropriate messa...
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 3 Jun 2013 06:17:10 +0000 (11:47 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 3 Jun 2013 06:17:10 +0000 (11:47 +0530)
CRM/Admin/Page/AJAX.php
CRM/Price/BAO/Set.php
CRM/Price/Page/Field.php
CRM/Price/Page/Set.php
templates/CRM/Price/Page/Field.tpl
templates/CRM/Price/Page/Set.tpl
templates/CRM/Price/Page/table.tpl

index 667a942d667c0a40d67935d0dd575e81aed18ea9..74caa4451feeda7a8cdeaf66c308eb23c8eae507 100644 (file)
@@ -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) {
index e7434dc3472dfe8e489d44d980ab6bb6f2502082..ecee3b7b017771b462fe2541b3994a2223b95561 100644 (file)
@@ -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;
 
index 4151ed7be7d87bb7a688049a0e3e2f7b22eb8817..8870bec4acdbb6769d7a1bf3e6e1536ca09f3498 100644 (file)
@@ -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) {
index 184ffc420e2c8477c22228c3224fe241e414c9ec..9940d67c7fd75ecce1d3c9af850314d970d72825 100644 (file)
@@ -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) {
index e1a4a583484c726c0908d79d78ab3c52bc9ad9fa..a285404f47b77ec036e54d822e4e14202d39dfca 100644 (file)
     <div id="price_set_used_by" class="messages status no-popup">
       <div class="icon inform-icon"></div>
         {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}
     </div>
index 88d5d969a8c155160cc0ebd99e530ae1a9d0b73c..9366163a3b54f36bd7a0473015f1402a973211d9 100644 (file)
     <div id="price_set_used_by" class="messages status no-popup">
        <div class="icon inform-icon"></div>
         {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}
     </div>
index 74c95380392831522e30d75aaabd46f0644f3a65..c7e451a8a3007355715ca98bace1daffd0fd804a 100644 (file)
       {/foreach}
 </table>
 {/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}
+  <br /><br />
+<table class="report">
+  <thead class="sticky">
+    <th scope="col">{ts}Event Template Name{/ts}</th>
+    <th scope="col">{ts}Type{/ts}</th>
+    <th scope="col">{ts}Public{/ts}</th>
+  </thead>
+  {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}
+</table>
+{/if}
+{/foreach}
\ No newline at end of file