* Calendar/Categrory report: Add sort option for the report

This commit is contained in:
Hadi Nategh 2017-01-06 16:15:34 +01:00
parent 3e4d1acfa2
commit e8b2838616
2 changed files with 21 additions and 2 deletions

View File

@ -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);

View File

@ -60,6 +60,13 @@ Egroupware
<description value="Date range"/>
<date id="start" label="Start"/>
<date id="end" label="End"/>
<hbox>
<description value="sort by" label="%s:"/>
<vbox>
<radio id="sort_key" label="Last name" options="n_family"/>
<radio id="sort_key" label="First name" options="n_given"/>
</vbox>
</hbox>
<button id="button[report]" label="Report" onclick="app.calendar.category_report_submit" background_image="1" image="template"/>
</hbox>
</template>