Notice fixes
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 5 Feb 2022 01:32:17 +0000 (14:32 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 5 Feb 2022 01:32:17 +0000 (14:32 +1300)
These primarily affect 'grumpy-mode'

CRM/Contribute/BAO/ContributionRecur.php
CRM/Contribute/BAO/Query.php
CRM/Core/BAO/Query.php
templates/CRM/Contribute/Form/Search/Common.tpl

index 980782b6a071266c7728148df335abb49858c3ce..3a9c504d508fc5584f6c60703e8a63d0ec45dd84 100644 (file)
@@ -830,12 +830,17 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
   }
 
   /**
-   * @param CRM_Core_Form $form
+   * Recurring contribution fields.
+   *
+   * @param CRM_Contribute_Form_Search $form
+   *
+   * @throws \CRM_Core_Exception
    */
-  public static function recurringContribution(&$form) {
-    // Recurring contribution fields
+  public static function recurringContribution($form): void {
+    // This assignment may be overwritten.
+    $form->assign('contribution_recur_pane_open', FALSE);
     foreach (self::getRecurringFields() as $key) {
-      if ($key == 'contribution_recur_payment_made' && !empty($form->_formValues) &&
+      if ($key === 'contribution_recur_payment_made' && !empty($form->_formValues) &&
         !CRM_Utils_System::isNull(CRM_Utils_Array::value($key, $form->_formValues))
       ) {
         $form->assign('contribution_recur_pane_open', TRUE);
index 5a762d3f446bf7b8eaf59b98b275c5dd5a8725d6..8f3ebd68e755f4b3cc6833c625796d615d1f6684 100644 (file)
@@ -1008,6 +1008,9 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         ]
       );
     }
+    else {
+      $form->addOptionalQuickFormElement('contribution_product_id');
+    }
 
     self::addCustomFormFields($form, ['Contribution']);
 
@@ -1027,6 +1030,9 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         FALSE, ['class' => 'crm-select2']
       );
     }
+    else {
+      $form->addOptionalQuickFormElement('contribution_batch_id');
+    }
 
     $form->assign('validCiviContribute', TRUE);
     $form->setDefaults(['contribution_test' => 0]);
index 173273bc5b369abde742de9ae0ff3c102651bea8..843820624335ecae4666b552c7ceaca40230c711 100644 (file)
@@ -23,8 +23,6 @@ class CRM_Core_BAO_Query {
   public static function addCustomFormFields(&$form, $extends) {
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
-      $tplName = lcfirst($extends[0]) . 'GroupTree';
-      $form->assign($tplName, $groupDetails);
       foreach ($groupDetails as $group) {
         foreach ($group['fields'] as $field) {
           $fieldId = $field['id'];
@@ -38,6 +36,8 @@ class CRM_Core_BAO_Query {
         }
       }
     }
+    $tplName = lcfirst($extends[0]) . 'GroupTree';
+    $form->assign($tplName, $groupDetails);
   }
 
   /**
index c585ac38dea73d59792d56a97c6b73b40759d1f2..adbd1130371441176e782325dcf7201011fd3e21 100644 (file)
@@ -25,7 +25,7 @@
     <label>{ts}Currency{/ts}</label> <br />
     {$form.contribution_currency_type.html|crmAddClass:twenty}
   </td>
-  {if !empty($form.contribution_batch_id.html)}
+  {if $form.contribution_batch_id.html}
     <td>
       {$form.contribution_batch_id.label}<br />
       {$form.contribution_batch_id.html}
@@ -58,7 +58,7 @@
 </tr>
 <tr>
   <td>
-    {if !empty($form.contribution_or_softcredits)}
+    {if $form.contribution_or_softcredits}
       {$form.contribution_or_softcredits.label} <br />
       {$form.contribution_or_softcredits.html}<br />
       <div class="float-left" id="contribution_soft_credit_type_wrapper">
     {$form.contribution_source.html|crmAddClass:twenty}
   </td>
   <td>
-    {if !empty($form.contribution_product_id)}
+    {if $form.contribution_product_id}
       {$form.contribution_product_id.label} <br />
       {$form.contribution_product_id.html|crmAddClass:twenty}
     {/if}
@@ -182,7 +182,7 @@ campaignTrClass='' campaignTdClass=''}
   </td>
 </tr>
 
-{if !empty($contributionGroupTree)}
+{if $contributionGroupTree}
 <tr>
   <td colspan="2">
   {include file="CRM/Custom/Form/Search.tpl" groupTree=$contributionGroupTree showHideLinks=false}</td>