Esempio n. 1
0
 /**
  * @param string $fieldName
  * @param $field
  * @param $defaults
  *
  * @return bool
  */
 public static function dateParam($fieldName, &$field, &$defaults)
 {
     // type = 12 (datetime) is not recognized by Utils_Type::escape() method,
     // and therefore the below hack
     $type = 4;
     $from = self::getTypedValue("{$fieldName}_from", $type);
     $to = self::getTypedValue("{$fieldName}_to", $type);
     $relative = CRM_Utils_Array::value("{$fieldName}_relative", $_GET);
     if ($relative) {
         list($from, $to) = CRM_Report_Form::getFromTo($relative, NULL, NULL);
         $from = substr($from, 0, 8);
         $to = substr($to, 0, 8);
     }
     if (!($from || $to)) {
         return FALSE;
     }
     if ($from !== NULL) {
         $dateFrom = CRM_Utils_Date::setDateDefaults($from);
         if ($dateFrom !== NULL && !empty($dateFrom[0])) {
             $defaults["{$fieldName}_from"] = $dateFrom[0];
         }
     }
     if ($to !== NULL) {
         $dateTo = CRM_Utils_Date::setDateDefaults($to);
         if ($dateTo !== NULL && !empty($dateTo[0])) {
             $defaults["{$fieldName}_to"] = $dateTo[0];
         }
     }
 }
Esempio n. 2
0
 static function dateParam($fieldName, &$field, &$defaults)
 {
     // type = 12 (datetime) is not recognized by Utils_Type::escape() method,
     // and therefore the below hack
     $type = 4;
     $from = self::getTypedValue("{$fieldName}_from", $type);
     $to = self::getTypedValue("{$fieldName}_to", $type);
     $relative = CRM_Utils_Array::value("{$fieldName}_relative", $_GET);
     if ($relative) {
         list($from, $to) = CRM_Report_Form::getFromTo($relative, null, null);
     }
     if (!($from || $to)) {
         return false;
     } else {
         if ($from || $to || $relative) {
             // unset other criteria
             self::unsetFilters($defaults);
         }
     }
     $defaults["{$fieldName}_from"] = CRM_Utils_Date::unformat($from, '');
     $defaults["{$fieldName}_to"] = CRM_Utils_Date::unformat($to, '');
 }
 function beginPostProcess()
 {
     parent::beginPostProcess();
     $this->_ranges = array('interval_0' => array());
     $dateFields = array('receive_date' => '', 'comparison_date' => 'comparison_', 'report_date' => 'report_date');
     $earliestDate = date('Y-m-d');
     $latestDate = date('Y-m-d', strtotime('50 years ago'));
     foreach ($dateFields as $fieldName => $prefix) {
         $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
         $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
         $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
         $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
         $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
         list($from, $to) = CRM_Report_Form::getFromTo($relative, $from, $to, $fromTime, $toTime);
         $this->_ranges['interval_0'][$prefix . 'from_date'] = DATE('Y-m-d', strtotime($from));
         $this->_ranges['interval_0'][$prefix . 'to_date'] = DATE('Y-m-d', strtotime($to));
         if (strtotime($from) < strtotime($earliestDate)) {
             $earliestDate = date('m/d/Y', strtotime($from));
         }
         if (strtotime($to) > strtotime($latestDate)) {
             $latestDate = date('m/d/Y', strtotime($to));
         }
     }
     // now we will re-set the receive date range to reflect the largest
     // & smallest dates we are interested in
     $this->_params['report_date_from'] = $earliestDate;
     $this->_params['report_date_to'] = $latestDate;
     $this->_params['report_date_relative'] = '0';
     $this->_columns['civicrm_contribution']['filters']['report_date'] = $this->_columns['civicrm_contribution']['filters']['receive_date'];
     $this->_columns['civicrm_contribution']['filters']['report_date']['title'] = 'Report Date Range';
     $this->_columns['civicrm_contribution']['filters']['report_date']['pseudofield'] = FALSE;
     $this->_statuses = array($this->_params['behaviour_type_value']);
 }