Sorting global paybacks by id DESC

This commit is contained in:
Phyks 2013-09-25 19:44:43 +02:00
parent dc8a4fbd95
commit 32cd8a4fe7
2 changed files with 18 additions and 2 deletions

1
TODO
View File

@ -2,7 +2,6 @@ Issues :
========
* Check CSRF everywhere
* Close a global payback
* Sort global paybacks DESC by DATE or id
Improvements :
==============

View File

@ -681,6 +681,14 @@
if(empty($_GET['id'])) {
$global_paybacks = $global_paybacks->load();
if($global_paybacks !== false) {
$sort_keys = array();
foreach($global_paybacks as $key=>$entry) {
$sort_keys[$key] = $entry->getId();
}
array_multisort($sort_keys, SORT_DESC, $global_paybacks);
}
}
else {
$global_paybacks = $global_paybacks->load(array('id'=>(int) $_GET['id']), true);
@ -717,7 +725,7 @@
($cached_files = glob(raintpl::$cache_dir."*.rtpl.php")) or ($cached_files = array());
array_map("unlink", $cached_files);
header('location: index.php');
header('location: see_paybacks.php?id='.(int)$_GET['payback_id']);
exit();
}
@ -736,6 +744,15 @@
$global_paybacks = new GlobalPayback();
$global_paybacks = $global_paybacks->load();
// Sort paybacks by id DESC
if($global_paybacks !== false) {
$sort_keys = array();
foreach($global_paybacks as $key=>$entry) {
$sort_keys[$key] = $entry->getId();
}
array_multisort($sort_keys, SORT_DESC, $global_paybacks);
}
$tpl->assign('list', true);
$tpl->assign('global_paybacks', $global_paybacks);
}