Merge pull request #14249 from yashodha/959_dev
[civicrm-core.git] / CRM / Contribute / Form / Task / Status.php
index f32c9e489da32357946411de7c639f2e9d4e1d33..bc291dc167b35b69b858d193e7b3f584c14628f9 100644 (file)
@@ -40,7 +40,7 @@ class CRM_Contribute_Form_Task_Status extends CRM_Contribute_Form_Task {
    * Are we operating in "single mode", i.e. updating the task of only
    * one specific contribution?
    *
-   * @var boolean
+   * @var bool
    */
   public $_single = FALSE;
 
@@ -55,7 +55,7 @@ class CRM_Contribute_Form_Task_Status extends CRM_Contribute_Form_Task {
     );
 
     if ($id) {
-      $this->_contributionIds = array($id);
+      $this->_contributionIds = [$id];
       $this->_componentClause = " civicrm_contribution.id IN ( $id ) ";
       $this->_single = TRUE;
       $this->assign('totalSelectedContributions', 1);
@@ -115,11 +115,11 @@ AND    co.id IN ( $contribIDs )";
     );
 
     // build a row for each contribution id
-    $this->_rows = array();
+    $this->_rows = [];
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution');
-    $defaults = array();
-    $now = date("m/d/Y");
-    $paidByOptions = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument();
+    $defaults = [];
+    $now = date("Y-m-d");
+    $paidByOptions = ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument();
 
     while ($dao->fetch()) {
       $row['contact_id'] = $dao->contact_id;
@@ -131,7 +131,7 @@ AND    co.id IN ( $contribIDs )";
       $this->addRule("trxn_id_{$row['contribution_id']}",
         ts('This Transaction ID already exists in the database. Include the account number for checks.'),
         'objectExists',
-        array('CRM_Contribute_DAO_Contribution', $dao->contribution_id, 'trxn_id')
+        ['CRM_Contribute_DAO_Contribution', $dao->contribution_id, 'trxn_id']
       );
 
       $row['fee_amount'] = &$this->add('text', "fee_amount_{$row['contribution_id']}", ts('Fee Amount'),
@@ -140,9 +140,7 @@ AND    co.id IN ( $contribIDs )";
       $this->addRule("fee_amount_{$row['contribution_id']}", ts('Please enter a valid amount.'), 'money');
       $defaults["fee_amount_{$row['contribution_id']}"] = 0.0;
 
-      $row['trxn_date'] = $this->addDate("trxn_date_{$row['contribution_id']}", FALSE,
-        ts('Receipt Date'), array('formatType' => 'activityDate')
-      );
+      $row['trxn_date'] = $this->add('datepicker', "trxn_date_{$row['contribution_id']}", ts('Transaction Date'), [], FALSE, ['time' => FALSE]);
       $defaults["trxn_date_{$row['contribution_id']}"] = $now;
 
       $this->add("text", "check_number_{$row['contribution_id']}", ts('Check Number'));
@@ -156,20 +154,19 @@ AND    co.id IN ( $contribIDs )";
 
     $this->assign_by_ref('rows', $this->_rows);
     $this->setDefaults($defaults);
-    $this->addButtons(array(
-        array(
-          'type' => 'next',
-          'name' => ts('Update Pending Status'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'back',
-          'name' => ts('Cancel'),
-        ),
-      )
-    );
-
-    $this->addFormRule(array('CRM_Contribute_Form_Task_Status', 'formRule'));
+    $this->addButtons([
+      [
+        'type' => 'next',
+        'name' => ts('Update Pending Status'),
+        'isDefault' => TRUE,
+      ],
+      [
+        'type' => 'back',
+        'name' => ts('Cancel'),
+      ],
+    ]);
+
+    $this->addFormRule(['CRM_Contribute_Form_Task_Status', 'formRule']);
   }
 
   /**
@@ -182,7 +179,7 @@ AND    co.id IN ( $contribIDs )";
    *   list of errors to be posted back to the form
    */
   public static function formRule($fields) {
-    $seen = $errors = array();
+    $seen = $errors = [];
     foreach ($fields as $name => $value) {
       if (strpos($name, 'trxn_id_') !== FALSE) {
         if ($fields[$name]) {
@@ -239,7 +236,7 @@ AND    co.id IN ( $contribIDs )";
 
     // for each contribution id, we just call the baseIPN stuff
     foreach ($form->_rows as $row) {
-      $input = $ids = $objects = array();
+      $input = $ids = $objects = [];
       $input['component'] = $details[$row['contribution_id']]['component'];
 
       $ids['contact'] = $row['contact_id'];
@@ -294,7 +291,7 @@ AND    co.id IN ( $contribIDs )";
       else {
         $input['trxn_id'] = $contribution->invoice_id;
       }
-      $input['trxn_date'] = CRM_Utils_Date::processDate($params["trxn_date_{$row['contribution_id']}"], date('H:i:s'));
+      $input['trxn_date'] = $params["trxn_date_{$row['contribution_id']}"] . ' ' . date('H:i:s');
 
       // @todo calling baseIPN like this is a pattern in it's last gasps. Call contribute.completetransaction api.
       $baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
@@ -325,7 +322,7 @@ LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id
 LEFT JOIN civicrm_participant         p  ON pp.participant_id  = p.id
 WHERE     c.id IN ( $contributionIDs )";
 
-    $rows = array();
+    $rows = [];
     $dao = CRM_Core_DAO::executeQuery($query,
       CRM_Core_DAO::$_nullArray
     );
@@ -335,7 +332,7 @@ WHERE     c.id IN ( $contributionIDs )";
       $rows[$dao->contribution_id]['contact'] = $dao->contact_id;
       if ($dao->membership_id) {
         if (!array_key_exists('membership', $rows[$dao->contribution_id])) {
-          $rows[$dao->contribution_id]['membership'] = array();
+          $rows[$dao->contribution_id]['membership'] = [];
         }
         $rows[$dao->contribution_id]['membership'][] = $dao->membership_id;
       }