Address notices, code madness around showing totals on prices
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 31 Aug 2023 22:43:08 +0000 (10:43 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 31 Aug 2023 23:20:39 +0000 (11:20 +1200)
13 files changed:
CRM/Contribute/Form/ContributionBase.php
CRM/Event/Form/Registration.php
CRM/Price/BAO/PriceSet.php
templates/CRM/Contribute/Form/Contribution.tpl
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl
templates/CRM/Event/Form/EventFees.tpl
templates/CRM/Event/Form/ParticipantFeeSelection.tpl
templates/CRM/Event/Form/Registration/AdditionalParticipant.tpl
templates/CRM/Event/Form/Registration/Register.tpl
templates/CRM/Member/Form/Membership.tpl
templates/CRM/Price/Form/Calculate.tpl
templates/CRM/Price/Form/Preview.tpl

index b1972d0060e95dc5e65f1ba3b2067832d2ec24ce..ac9a967edbc33fdbb9426301241761762e2df273 100644 (file)
@@ -359,7 +359,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
       CRM_Core_Error::deprecatedFunctionWarning('forms require a price set ID');
     }
     $this->_priceSet = $this->get('priceSet');
-
+    $this->assign('quickConfig', $this->isQuickConfig());
     if (!$this->_values) {
       // get all the values from the dao object
       $this->_values = [];
@@ -410,7 +410,6 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
       ));
 
       $this->assignPaymentProcessor($isPayLater);
-      $this->assign('quickConfig', $this->isQuickConfig());
       // get price info
       // CRM-5095
       $this->initSet($this);
index 79dfd821ee51c40081b0d4d886237d808c6be94d..7dd46460ffe0faee119681b2846a19084d82759e 100644 (file)
@@ -301,6 +301,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       $priceSetID = $this->getPriceSetID();
       if ($priceSetID) {
         self::initEventFee($this, $this->_eventId, TRUE, $priceSetID);
+        $this->assign('quickConfig', $this->isQuickConfig());
       }
 
       // get the profile ids
@@ -583,15 +584,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       CRM_Core_Error::deprecatedWarning('this should not be reachable');
       return;
     }
-    //check if price set is is_config
-    if (is_numeric($priceSetId)) {
-      if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config') && $form->getVar('_name') != 'Participant') {
-        $form->assign('quickConfig', 1);
-      }
-      else {
-        $form->assign('quickConfig', 0);
-      }
-    }
+
     // get price info
     if ($priceSetId) {
       if ($form->_action & CRM_Core_Action::UPDATE) {
@@ -1716,4 +1709,13 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
     return $this->_priceSetId ?: NULL;
   }
 
+  /**
+   * Is the price set quick config.
+   *
+   * @return bool
+   */
+  public function isQuickConfig(): bool {
+    return $this->getPriceSetID() && CRM_Price_BAO_PriceSet::isQuickConfig($this->getPriceSetID());
+  }
+
 }
index f7ca2008191416098c557dbacb20e0afcc435f33..874fcd208547351c79f571fa97f20217e8291fcf 100644 (file)
@@ -548,12 +548,7 @@ WHERE  id = %1";
    */
   public static function initSet(&$form, $entityTable = 'civicrm_event', $doNotIncludeExpiredFields = FALSE, $priceSetId = NULL) {
     CRM_Core_Error::deprecatedFunctionWarning('no alternative');
-    //check if price set is is_config
-    if (is_numeric($priceSetId)) {
-      if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config') && $form->getVar('_name') != 'Participant') {
-        $form->assign('quickConfig', 1);
-      }
-    }
+
     // get price info
     if ($priceSetId) {
       if ($form->_action & CRM_Core_Action::UPDATE) {
@@ -809,7 +804,6 @@ WHERE  id = %1";
     $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
     $form->_priceSet = $priceSet[$priceSetId] ?? NULL;
     $validPriceFieldIds = array_keys($form->_priceSet['fields']);
-    $form->assign('quickConfig', (int) CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config'));
 
     // Mark which field should have the auto-renew checkbox, if any. CRM-18305
     if (!empty($form->_membershipTypeValues) && is_array($form->_membershipTypeValues)) {
index 9b0c1a46c306adfe0790f703b7401757994cefc2..ba1d06d1c2c1dfce092f3a43697c444b4541bef9 100644 (file)
@@ -10,7 +10,7 @@
 {* this template is used for adding/editing/deleting contributions and pledge payments *}
 
 {if $priceSetId}
-  {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Contribution"}
+  {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Contribution" hideTotal=false}
 {elseif !empty($showAdditionalInfo) and !empty($formType)}
   {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
 {else}
index c847f4ea8ea041e9825f969bce7beab7345d79c4..5a6d17fe8e5862e12ac3182258cb4128c0a31dd4 100644 (file)
@@ -95,7 +95,7 @@
       {/if}
     {else}
       <div id="priceset-div">
-        {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
+        {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution" hideTotal=$quickConfig}
       </div>
     {/if}
 
index 4c83e629cd0a9b35224f2b4d0e1f38cdafc060da..acc4cf203b9db9723c05e31c41802b11808c7382 100644 (file)
@@ -47,7 +47,7 @@
           {/if}
         {/foreach}
       {/if}
-      {include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}
+      {include file="CRM/Price/Form/PriceSet.tpl" extends="Membership" hideTotal=$quickConfig}
     </fieldset>
   </div>
   {literal}
index 23f4403dd577ea80e7f47e0d7301f60427abae74..b74911069a2d0d2a81a009dfc533d0a527ab07be 100644 (file)
@@ -40,7 +40,7 @@
           <fieldset id="priceset" class="crm-group priceset-group">
             <tr class="crm-event-eventfees-form-block-price_set_amount">
             <td class="label" style="padding-top: 10px;">{$form.amount.label}</td>
-            <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event"}</td>
+            <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" hideTotal=false}</td>
           </fieldset>
         {else}
           {assign var=isRecordPayment value=0 }
index 78f6608748f063e7aba8e89f23518e6f232dd0a8..1e25ca065ee0755a098f4a33bccc9750ff6770ad 100644 (file)
@@ -114,7 +114,7 @@ CRM.$(function($) {
       <table class='form-layout'>
         <tr class="crm-event-eventfees-form-block-price_set_amount">
           <td class="label" style="padding-top: 10px;">{$form.amount.label}</td>
-          <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" noCalcValueDisplay=0 context="participant"}</table></td>
+          <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" hideTotal=false context="participant"}</table></td>
         </tr>
      {if $paymentInfo}
        <tr><td></td><td>
@@ -126,7 +126,7 @@ CRM.$(function($) {
          </div>
          <div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div class='content'><strong id='balance-fee'></strong></div>
           </div>
-       {include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol noCalcValueDisplay=1 displayOveride='true'}
+       {include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol hideTotal=1 displayOveride='true'}
        {/if}
       </table>
     </fieldset>
index 1c00dbfcc6b4f91a687ff4418b8074188908c2a9..6f6aa21f897e4f824f3b259d369a4c2fd1d0b63e 100644 (file)
@@ -36,7 +36,7 @@
 <div class="crm-event-id-{$event.id} crm-block crm-event-additionalparticipant-form-block">
 {if $priceSet}
      <fieldset id="priceset" class="crm-public-form-item crm-group priceset-group"><legend>{$event.fee_label}</legend>
-        {include file="CRM/Price/Form/PriceSet.tpl" extends="Event"}
+        {include file="CRM/Price/Form/PriceSet.tpl" extends="Event" hideTotal=false}
     </fieldset>
 {else}
     {if $paidEvent}
index 660bdd0f662af4bedfee554d6fab57485891610f..f7d20a492fa572d4370897cf1914c1057276d270 100644 (file)
@@ -81,7 +81,7 @@
     {if $priceSet}
       {if ! $quickConfig}<fieldset id="priceset" class="crm-public-form-item crm-group priceset-group">
         <legend>{$event.fee_label}</legend>{/if}
-      {include file="CRM/Price/Form/PriceSet.tpl" extends="Event"}
+      {include file="CRM/Price/Form/PriceSet.tpl" extends="Event" hideTotal=$quickConfig}
       {include file="CRM/Price/Form/ParticipantCount.tpl"}
       {if ! $quickConfig}</fieldset>{/if}
     {/if}
index 8d0a88343e186c033f1b91c4a3a20bcdef84bc71..2abbe4ecde2c30af874b8ee3841a2d5ee14331a8 100644 (file)
@@ -19,7 +19,7 @@
 {/if}
 <div class="spacer"></div>
 {if $priceSetId}
-  {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Membership"}
+  {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Membership"  hideTotal=false}
   {literal}
   <script type="text/javascript">
   CRM.$(function($) {
@@ -89,7 +89,7 @@
               <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
               <span id='selectPriceSet'>{$form.price_set_id.html}</span>
               {if $buildPriceSet && $priceSet}
-                <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}</div>
+                <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership" hideTotal=false}</div>
                 {else}
                 <div id="priceset" class="hiddenElement"></div>
               {/if}
index 170334b499be0d678f6ebd6271873e9d03d16eb9..438f9739e156c5d2dac664efc5ff299d1407444b 100644 (file)
@@ -8,8 +8,6 @@
  +--------------------------------------------------------------------+
 *}
 
-{assign var='hideTotal' value=$quickConfig+$noCalcValueDisplay}
-
 <div id="pricesetTotal" class="crm-section section-pricesetTotal">
   <div id="pricelabel" class="label {if $hideTotal}hiddenElement{/if}">
     {if ($extends eq 'Contribution') || ($extends eq 'Membership')}
index c3d04f0be4393d0083c888f44309d8189c12f874..b2af813f8d475007cc9b3427e838094ba8d5f101 100644 (file)
@@ -20,7 +20,7 @@
     {foreach from=$groupTree item=priceSet key=group_id}
       <fieldset>
         {if $preview_type eq 'group'}<legend>{$setTitle}</legend>{/if}
-        {include file="CRM/Price/Form/PriceSet.tpl"}
+        {include file="CRM/Price/Form/PriceSet.tpl" hideTotal=false}
       </fieldset>
     {/foreach}
   {/strip}