protected $_customGroupExtends = array('Case');
+ protected $_caseTypeNameOrderBy = FALSE;
+
/**
*/
public function __construct() {
'default' => 0,
),
),
+ 'order_bys' => array(
+ 'start_date' => array(
+ 'title' => ts('Start Date'),
+ 'default_weight' => 1,
+ ),
+ 'end_date' => array(
+ 'title' => ts('End Date'),
+ ),
+ 'status_id' => array(
+ 'title' => ts('Status'),
+ ),
+ ),
),
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
}
}
}
+
+ if ($orderBys = $this->_params['order_bys']) {
+ foreach ($orderBys as $orderBy) {
+ if ($orderBy['column'] == 'case_type_name') {
+ $select[] = "civireport_case_types.title as case_type_name";
+ $this->_caseTypeNameOrderBy = TRUE;
+ }
+ }
+ }
+
$this->_selectClauses = $select;
$this->_select = 'SELECT ' . implode(', ', $select) . ' ';
if ($this->_activityLastCompleted) {
$this->_from .= " LEFT JOIN civicrm_activity {$this->_aliases['civicrm_activity_last_completed']} ON ( {$this->_aliases['civicrm_activity_last_completed']}.id = ( SELECT max(activity_id) FROM civicrm_case_activity cca, civicrm_activity ca WHERE ca.id = cca.activity_id AND cca.case_id = {$case}.id AND ca.status_id = 2 ) )";
}
+
+ //include case type name
+ if ($this->_caseTypeNameOrderBy) {
+ $this->_from .= "
+ LEFT JOIN civicrm_case_type civireport_case_types
+ ON {$case}.case_type_id = civireport_case_types.id
+ ";
+ }
}
public function where() {
}
public function orderBy() {
- $this->_orderBy = " ORDER BY {$this->_aliases['civicrm_case']}.start_date DESC ";
+ parent::orderBy();
+
+ if ($this->_caseTypeNameOrderBy) {
+ $this->_orderBy = str_replace('case_civireport.case_type_name', 'civireport_case_types.title', $this->_orderBy);
+ }
}
public function caseDetailSpecialColumnProcess() {