forked from extern/egroupware
* Calendar/Categrory report: Add sort option for the report
This commit is contained in:
parent
4d74df2b87
commit
06bf277940
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user