Merge pull request #13689 from eileenmcnaughton/no_record_payment
[civicrm-core.git] / CRM / Contribute / Form / ManagePremiums.php
index 1176098f2c54d95a0b6bc341d16fa5ab36858363..bbb5543e20f049081e9e5f8915f196f48d449f64 100644 (file)
@@ -49,7 +49,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
   public function setDefaultValues() {
     $defaults = parent::setDefaultValues();
     if ($this->_id) {
-      $params = array('id' => $this->_id);
+      $params = ['id' => $this->_id];
       CRM_Contribute_BAO_Product::retrieve($params, $tempDefaults);
       if (isset($tempDefaults['image']) && isset($tempDefaults['thumbnail'])) {
         $defaults['imageUrl'] = $tempDefaults['image'];
@@ -91,10 +91,10 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
 
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE);
-    $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array(
-        'CRM_Contribute_DAO_Product',
-        $this->_id,
-      ));
+    $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', [
+      'CRM_Contribute_DAO_Product',
+      $this->_id,
+    ]);
     $this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku'));
 
     $this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60');
@@ -123,25 +123,25 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
 
     $this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60');
 
-    $this->add('select', 'period_type', ts('Period Type'), array(
-        '' => '- select -',
-        'rolling' => 'Rolling',
-        'fixed' => 'Fixed',
-      ));
+    $this->add('select', 'period_type', ts('Period Type'), [
+      '' => '- select -',
+      'rolling' => 'Rolling',
+      'fixed' => 'Fixed',
+    ]);
 
     $this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day'));
 
-    $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
+    $this->add('Select', 'duration_unit', ts('Duration Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits());
 
     $this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval'));
 
-    $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
+    $this->add('Select', 'frequency_unit', ts('Frequency Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits());
 
     $this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval'));
 
     //Financial Type CRM-11106
     $financialType = CRM_Contribute_PseudoConstant::financialType();
-    $premiumFinancialType = array();
+    $premiumFinancialType = [];
     CRM_Core_PseudoConstant::populate(
       $premiumFinancialType,
       'CRM_Financial_DAO_EntityFinancialAccount',
@@ -151,7 +151,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
       'account_relationship = 8'
     );
 
-    $costFinancialType = array();
+    $costFinancialType = [];
     CRM_Core_PseudoConstant::populate(
       $costFinancialType,
       'CRM_Financial_DAO_EntityFinancialAccount',
@@ -173,25 +173,24 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
       'select',
       'financial_type_id',
       ts('Financial Type'),
-      array('' => ts('- select -')) + $financialType
+      ['' => ts('- select -')] + $financialType
     );
 
     $this->add('checkbox', 'is_active', ts('Enabled?'));
 
-    $this->addFormRule(array('CRM_Contribute_Form_ManagePremiums', 'formRule'));
-
-    $this->addButtons(array(
-        array(
-          'type' => 'upload',
-          'name' => ts('Save'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel'),
-        ),
-      )
-    );
+    $this->addFormRule(['CRM_Contribute_Form_ManagePremiums', 'formRule']);
+
+    $this->addButtons([
+      [
+        'type' => 'upload',
+        'name' => ts('Save'),
+        'isDefault' => TRUE,
+      ],
+      [
+        'type' => 'cancel',
+        'name' => ts('Cancel'),
+      ],
+    ]);
     $this->assign('productId', $this->_id);
   }
 
@@ -275,7 +274,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
         CRM_Contribute_BAO_Product::del($this->_id);
       }
       catch (CRM_Core_Exception $e) {
-        $message = ts("This Premium is linked to an <a href='%1'>Online Contribution page</a>. Please remove it before deleting this Premium.", array(1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')));
+        $message = ts("This Premium is linked to an <a href='%1'>Online Contribution page</a>. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]);
         CRM_Core_Session::setStatus($message, ts('Cannot delete Premium'), 'error');
         CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute/managePremiums', 'reset=1&action=browse'));
         return;
@@ -289,7 +288,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
     $params = $this->controller->exportValues($this->_name);
 
     // Clean the the money fields
-    $moneyFields = array('cost', 'price', 'min_contribution');
+    $moneyFields = ['cost', 'price', 'min_contribution'];
     foreach ($moneyFields as $field) {
       $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
     }
@@ -305,7 +304,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
     $premium = CRM_Contribute_BAO_Product::create($params);
 
     CRM_Core_Session::setStatus(
-      ts("The Premium '%1' has been saved.", array(1 => $premium->name)),
+      ts("The Premium '%1' has been saved.", [1 => $premium->name]),
       ts('Saved'), 'success');
   }
 
@@ -316,14 +315,14 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
    * @param array $params
    */
   protected function _processImages(&$params) {
-    $defaults = array(
+    $defaults = [
       'imageOption' => 'noImage',
-      'uploadFile' => array('name' => ''),
+      'uploadFile' => ['name' => ''],
       'image' => '',
       'thumbnail' => '',
       'imageUrl' => '',
       'thumbnailUrl' => '',
-    );
+    ];
     $params = array_merge($defaults, $params);
 
     // User is uploading an image