added journal pagination
This commit is contained in:
parent
dc68d0fd69
commit
7a08a78b8c
6 changed files with 40 additions and 1 deletions
|
@ -23,6 +23,7 @@ getJournalR :: Handler Html
|
||||||
getJournalR = do
|
getJournalR = do
|
||||||
master <- getYesod
|
master <- getYesod
|
||||||
rawEntries <- runDB $ selectList [] [Desc TransactionId]
|
rawEntries <- runDB $ selectList [] [Desc TransactionId]
|
||||||
|
next <- runDB $ selectList [] [Desc TransactionId, OffsetBy 30]
|
||||||
entries <- return $ L.reverse $ L.take 30 rawEntries
|
entries <- return $ L.reverse $ L.take 30 rawEntries
|
||||||
total <- return $ L.sum $ I.map (transactionAmount . entityVal) rawEntries
|
total <- return $ L.sum $ I.map (transactionAmount . entityVal) rawEntries
|
||||||
timeLimit <- case L.null entries of
|
timeLimit <- case L.null entries of
|
||||||
|
@ -41,3 +42,20 @@ merge (t:ts) [] = (Left $ entityVal t) : merge ts []
|
||||||
merge (t:ts) (c:cs)
|
merge (t:ts) (c:cs)
|
||||||
| transactionTime (entityVal t) < cashCheckTime (entityVal c) = (Left $ entityVal t) : merge ts (c:cs)
|
| transactionTime (entityVal t) < cashCheckTime (entityVal c) = (Left $ entityVal t) : merge ts (c:cs)
|
||||||
| transactionTime (entityVal t) > cashCheckTime (entityVal c) = (Right $ entityVal c) : merge (t:ts) cs
|
| transactionTime (entityVal t) > cashCheckTime (entityVal c) = (Right $ entityVal c) : merge (t:ts) cs
|
||||||
|
|
||||||
|
getJournalPageR :: Int -> Handler Html
|
||||||
|
getJournalPageR p = do
|
||||||
|
master <- getYesod
|
||||||
|
rawEntries <- runDB $ selectList [] [Desc TransactionId, OffsetBy (p * 30)]
|
||||||
|
next <- runDB $ selectList [] [Desc TransactionId, OffsetBy ((p + 1) * 30)]
|
||||||
|
entries <- return $ L.reverse $ L.take 30 rawEntries
|
||||||
|
lTimeLimit <- case L.null entries of
|
||||||
|
False -> return $ transactionTime $ entityVal $ L.head $ entries
|
||||||
|
True -> liftIO getCurrentTime
|
||||||
|
uTimeLimit <- case L.null entries of
|
||||||
|
False -> return $ transactionTime $ entityVal $ L.last $ entries
|
||||||
|
True -> liftIO getCurrentTime
|
||||||
|
cashChecks <- runDB $ selectList [CashCheckTime >=. lTimeLimit, CashCheckTime <. uTimeLimit] [Asc CashCheckId]
|
||||||
|
list <- return $ merge entries cashChecks
|
||||||
|
defaultLayout $ do
|
||||||
|
$(widgetFile "journalPage")
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
/user/#UserId/buy/#BeverageId BuyR GET POST
|
/user/#UserId/buy/#BeverageId BuyR GET POST
|
||||||
!/user/cash/buy/#BeverageId BuyCashR GET POST
|
!/user/cash/buy/#BeverageId BuyCashR GET POST
|
||||||
/journal JournalR GET
|
/journal JournalR GET
|
||||||
|
/journal/#Int JournalPageR GET
|
||||||
/payout PayoutR GET POST
|
/payout PayoutR GET POST
|
||||||
/summary SummaryR GET
|
/summary SummaryR GET
|
||||||
/summary.json SummaryJsonR GET
|
/summary.json SummaryJsonR GET
|
||||||
|
|
|
@ -113,3 +113,5 @@ TransferTo: Guthaben transferieren an
|
||||||
NegativeTransfer: Keine negativen Beträge transferieren
|
NegativeTransfer: Keine negativen Beträge transferieren
|
||||||
TransferComplete: Transfer abgeschlossen
|
TransferComplete: Transfer abgeschlossen
|
||||||
TransferError: Fehler beim Transfer
|
TransferError: Fehler beim Transfer
|
||||||
|
PreviousPage: vorherige Seite
|
||||||
|
NextPage: nächste Seite
|
||||||
|
|
|
@ -113,3 +113,5 @@ TransferTo: Transfer credit to
|
||||||
NegativeTransfer: Please do not transfer negative amounts
|
NegativeTransfer: Please do not transfer negative amounts
|
||||||
TransferComplete: Transfer complete
|
TransferComplete: Transfer complete
|
||||||
TransferError: Transfer error
|
TransferError: Transfer error
|
||||||
|
PreviousPage: previous page
|
||||||
|
NextPage: next page
|
||||||
|
|
|
@ -19,6 +19,18 @@
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
display: inline-block;
|
||||||
|
/*float: left;*/
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
display: inline-block;
|
||||||
|
/*float: right;*/
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
article#func.article {
|
article#func.article {
|
||||||
background-color: #fff7bd;
|
background-color: #fff7bd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ $if not $ L.null entries
|
||||||
<td>#{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master}
|
<td>#{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master}
|
||||||
<p>
|
<p>
|
||||||
_{MsgCashStock}: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}
|
_{MsgCashStock}: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}
|
||||||
|
$if not $ L.null next
|
||||||
|
<div>
|
||||||
|
<div .right>
|
||||||
|
<a href="@{JournalPageR 1}">_{MsgNextPage}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in a new issue