Merge pull request #5731 from mallezie/groupcontact-addfield
[civicrm-core.git] / CRM / Campaign / Form / Survey / Results.php
index a9ccbaa5932abe7b831bd3230ece5bf1d690cf3b..10f4349ebf3e0a0f2ca6da3061f41507821b190e 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -44,9 +44,9 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
   protected $_reportTitle;
 
   /* values
-     *
-     * @var array
-     */
+   *
+   * @var array
+   */
   public $_values;
 
   const NUM_OPTION = 11;
@@ -77,9 +77,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
    * Set default values for the form. Note that in edit/view mode
    * the default values are retrieved from the database
    *
-   * @param null
-   *
-   * @return array    array of default values
+   * @return array
+   *   array of default values
    */
   public function setDefaultValues() {
     $defaults = $this->_values;
@@ -97,9 +96,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
   }
 
   /**
-   * Build the form object
-   *
-   * @param null
+   * Build the form object.
    *
    * @return void
    */
@@ -198,16 +195,21 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
     }
 
     $this->addFormRule(array(
-        'CRM_Campaign_Form_Survey_Results',
-        'formRule',
-      ), $this);
+      'CRM_Campaign_Form_Survey_Results',
+      'formRule',
+    ), $this);
 
     parent::buildQuickForm();
   }
 
   /**
-   * Global validation rules for the form
+   * Global validation rules for the form.
+   *
+   * @param $fields
+   * @param $files
+   * @param $form
    *
+   * @return array|bool
    */
   public static function formRule($fields, $files, $form) {
     $errors = array();
@@ -342,9 +344,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
   }
 
   /**
-   * Process the form
-   *
-   * @param null
+   * Process the form.
    *
    * @return void
    */
@@ -415,23 +415,21 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
     if (!$this->_reportId && $survey->id && !empty($params['create_report'])) {
       $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
       $activityStatus = array_flip($activityStatus);
-      $this->_params =
-        array(
-          'name' => "survey_{$survey->id}",
-          'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'],
-          'status_id_op' => 'eq',
-          'status_id_value' => $activityStatus['Scheduled'], // reserved status
-          'survey_id_value' => array($survey->id),
-          'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'),
-        );
+      $this->_params = array(
+        'name' => "survey_{$survey->id}",
+        'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'],
+        'status_id_op' => 'eq',
+        'status_id_value' => $activityStatus['Scheduled'], // reserved status
+        'survey_id_value' => array($survey->id),
+        'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'),
+      );
       //Default value of order by
-      $this->_params['order_bys'] =
-        array(
-          1 => array(
-            'column' => 'sort_name',
-            'order' => 'ASC',
-          ),
-        );
+      $this->_params['order_bys'] = array(
+        1 => array(
+          'column' => 'sort_name',
+          'order' => 'ASC',
+        ),
+      );
       // for WalkList or default
       $displayFields = array(
         'id',
@@ -445,25 +443,24 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
       if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') ==
         $this->_values['activity_type_id']
       ) {
-        $this->_params['order_bys'] =
-          array(
-            1 => array(
-              'column' => 'street_name',
-              'order' => 'ASC',
-            ),
-            2 => array(
-              'column' => 'street_number_odd_even',
-              'order' => 'ASC',
-            ),
-            3 => array(
-              'column' => 'street_number',
-              'order' => 'ASC',
-            ),
-            4 => array(
-              'column' => 'sort_name',
-              'order' => 'ASC',
-            ),
-          );
+        $this->_params['order_bys'] = array(
+          1 => array(
+            'column' => 'street_name',
+            'order' => 'ASC',
+          ),
+          2 => array(
+            'column' => 'street_number_odd_even',
+            'order' => 'ASC',
+          ),
+          3 => array(
+            'column' => 'street_number',
+            'order' => 'ASC',
+          ),
+          4 => array(
+            'column' => 'sort_name',
+            'order' => 'ASC',
+          ),
+        );
       }
       elseif (CRM_Core_OptionGroup::getValue('activity_type', 'PhoneBank') ==
         $this->_values['activity_type_id']
@@ -486,11 +483,11 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
 
       $query = "SELECT MAX(id) FROM civicrm_report_instance WHERE name = %1";
       $reportID = CRM_Core_DAO::singleValueQuery($query, array(
-          1 => array(
-            "survey_{$survey->id}",
-            'String',
-          ),
-        ));
+        1 => array(
+          "survey_{$survey->id}",
+          'String',
+        ),
+      ));
       if ($reportID) {
         $url = CRM_Utils_System::url("civicrm/report/instance/{$reportID}", 'reset=1');
         $status = ts("A Survey Detail Report <a href='%1'>%2</a> has been created.",
@@ -508,4 +505,5 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
 
     parent::endPostProcess();
   }
+
 }