*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form {
'pieChart' => 'Pie Chart',
);
- /**
- */
/**
*/
public function __construct() {
'bounce_reason' => array(
'title' => ts('Bounce Reason'),
),
+ 'time_stamp' => array(
+ 'title' => ts('Bounce Date'),
+ ),
+ ),
+ 'filters' => array(
+ 'bounce_reason' => array(
+ 'title' => ts('Bounce Reason'),
+ ),
+ 'time_stamp' => array(
+ 'title' => ts('Bounce Date'),
+ 'operatorType' => CRM_Report_Form::OP_DATE,
+ 'type' => CRM_Utils_Type::T_DATE,
+ ),
),
'order_bys' => array(
- 'bounce_reason' => array('title' => ts('Bounce Reason')),
+ 'bounce_reason' => array(
+ 'title' => ts('Bounce Reason')
+ ),
+ 'time_stamp' => array(
+ 'title' => ts('Bounce Date')
+ ),
),
'grouping' => 'mailing-fields',
);
'no_repeat' => TRUE,
'required' => TRUE,
),
+ 'on_hold' => array(
+ 'title' => ts('On hold'),
+ ),
+ 'hold_date' => array(
+ 'title' => ts('Hold date'),
+ ),
+ 'reset_date' => array(
+ 'title' => ts('Hold reset date'),
+ ),
+ ),
+ 'filters' => array(
+ 'on_hold' => array(
+ 'title' => ts('On hold'),
+ ),
+ 'hold_date' => array(
+ 'title' => ts('Hold date'),
+ 'operatorType' => CRM_Report_Form::OP_DATE,
+ 'type' => CRM_Utils_Type::T_DATE,
+ ),
+ 'reset_date' => array(
+ 'title' => ts('Hold reset date'),
+ 'operatorType' => CRM_Report_Form::OP_DATE,
+ 'type' => CRM_Utils_Type::T_DATE,
+ ),
),
'order_bys' => array(
'email' => array('title' => ts('Email'), 'default_order' => 'ASC'),
}
public function where() {
- parent::where();
- $this->_where .= " AND {$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL";
+
+ $clauses = array();
+
+ // Exclude SMS mailing type
+ $clauses[] = "{$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL";
+
+ // Build date filter clauses
+ foreach ($this->_columns as $tableName => $table) {
+ if (array_key_exists('filters', $table)) {
+ foreach ($table['filters'] as $fieldName => $field) {
+ $clause = NULL;
+ if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
+ $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);
+
+ $clause = $this->dateClause($this->_aliases[$tableName] . '.' . $field['name'], $relative, $from, $to, $field['type']);
+ }
+ else {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+
+ if ($op) {
+ $clause = $this->whereClause($field,
+ $op,
+ CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
+ );
+ }
+
+ }
+
+ if (!empty($clause)) {
+ $clauses[] = $clause;
+ }
+ }
+ }
+ }
+
+ $this->_where = "WHERE " . implode(' AND ', $clauses);
}
public function groupBy() {
* Rows generated by SQL, with an array for each row.
*/
public function alterDisplay(&$rows) {
+
+ $config = CRM_Core_Config::Singleton();
+
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact details for this contact.");
$entryFound = TRUE;
}
+
+ // Handle on_hold boolean display
+ if (array_key_exists('civicrm_email_on_hold', $row)) {
+ $rows[$rowNum]['civicrm_email_on_hold'] = (!empty($row['civicrm_email_on_hold'])) ? 'Yes' : 'No';
+ $entryFound = TRUE;
+ }
+
+ // Convert datetime values to custom date and time format
+ $dateFields = array(
+ 'civicrm_mailing_event_bounce_time_stamp',
+ 'civicrm_email_hold_date',
+ 'civicrm_email_reset_date',
+ );
+
+ foreach($dateFields as $dateField) {
+ if (array_key_exists($dateField, $row)) {
+ if (!empty($rows[$rowNum][$dateField])) {
+ $rows[$rowNum][$dateField] = CRM_Utils_Date::customFormat($row[$dateField], $config->dateformatDatetime);
+ }
+ $entryFound = TRUE;
+ }
+ }
// skip looking further in rows, if first row itself doesn't
// have the column we need