From 06bf27794048e13ce49c6e83a90090724a680a07 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 6 Jan 2017 16:15:34 +0100 Subject: [PATCH] * Calendar/Categrory report: Add sort option for the report --- .../inc/class.calendar_category_report.inc.php | 16 ++++++++++++++-- calendar/templates/default/category_report.xet | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/calendar/inc/class.calendar_category_report.inc.php b/calendar/inc/class.calendar_category_report.inc.php index a7ce0a980b..d18a5db22b 100644 --- a/calendar/inc/class.calendar_category_report.inc.php +++ b/calendar/inc/class.calendar_category_report.inc.php @@ -347,7 +347,7 @@ class calendar_category_report extends calendar_ui{ // ] // $result = array_replace_recursive($days_output, $min_days_output); - $csv_header = array (); + $raw_csv = $csv_header = array (); // create csv header foreach ($categories as $cat_id) @@ -384,8 +384,20 @@ class calendar_category_report extends calendar_ui{ // last name $n_family = array('n_family' => Api\Accounts::id2name($user_id, 'account_lastname')) ? array('n_family' => Api\Accounts::id2name($user_id, 'account_lastname')) : array(); + $raw_csv[] = $n_family + $n_given+ $cats_row; + } + // comparision function for usort + function compareByFamily ($key='n_family') { + return function ($a, $b) use ($key){ + return strcasecmp($a[$key], $b[$key]); + }; + } + usort($raw_csv, compareByFamily($content['sort_key'])); + + foreach ($raw_csv as &$row) + { // printout each row into file - fputcsv($fp, array_values($n_family + $n_given+ $cats_row)); + fputcsv($fp, array_values($row)); } // echo out csv file fpassthru($fp); diff --git a/calendar/templates/default/category_report.xet b/calendar/templates/default/category_report.xet index 649dba0fcc..7b3707e9da 100644 --- a/calendar/templates/default/category_report.xet +++ b/calendar/templates/default/category_report.xet @@ -60,6 +60,13 @@ Egroupware + + + + + + +