added journal pagination
forgot template file
This commit is contained in:
parent
dc68d0fd69
commit
522da12175
7 changed files with 77 additions and 1 deletions
|
@ -23,6 +23,7 @@ getJournalR :: Handler Html
|
|||
getJournalR = do
|
||||
master <- getYesod
|
||||
rawEntries <- runDB $ selectList [] [Desc TransactionId]
|
||||
next <- runDB $ selectList [] [Desc TransactionId, OffsetBy 30]
|
||||
entries <- return $ L.reverse $ L.take 30 rawEntries
|
||||
total <- return $ L.sum $ I.map (transactionAmount . entityVal) rawEntries
|
||||
timeLimit <- case L.null entries of
|
||||
|
@ -41,3 +42,20 @@ merge (t:ts) [] = (Left $ entityVal t) : merge ts []
|
|||
merge (t: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
|
||||
|
||||
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/cash/buy/#BeverageId BuyCashR GET POST
|
||||
/journal JournalR GET
|
||||
/journal/#Int JournalPageR GET
|
||||
/payout PayoutR GET POST
|
||||
/summary SummaryR GET
|
||||
/summary.json SummaryJsonR GET
|
||||
|
|
|
@ -113,3 +113,5 @@ TransferTo: Guthaben transferieren an
|
|||
NegativeTransfer: Keine negativen Beträge transferieren
|
||||
TransferComplete: Transfer abgeschlossen
|
||||
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
|
||||
TransferComplete: Transfer complete
|
||||
TransferError: Transfer error
|
||||
PreviousPage: previous page
|
||||
NextPage: next page
|
||||
|
|
|
@ -19,6 +19,18 @@
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
.left {
|
||||
display: inline-block;
|
||||
/*float: left;*/
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.right {
|
||||
display: inline-block;
|
||||
/*float: right;*/
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
article#func.article {
|
||||
background-color: #fff7bd;
|
||||
}
|
||||
|
@ -262,4 +274,4 @@ input[type] {
|
|||
}
|
||||
#barcodeContent {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@ $if not $ L.null entries
|
|||
<td>#{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master}
|
||||
<p>
|
||||
_{MsgCashStock}: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}
|
||||
$if not $ L.null next
|
||||
<div>
|
||||
<div .right>
|
||||
<a href="@{JournalPageR 1}">_{MsgNextPage}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
|
|
37
templates/journalPage.hamlet
Normal file
37
templates/journalPage.hamlet
Normal file
|
@ -0,0 +1,37 @@
|
|||
$doctype 5
|
||||
|
||||
<h3>Journal
|
||||
|
||||
$if not $ L.null entries
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>_{MsgTime}
|
||||
<th>_{MsgDescription}
|
||||
<th>_{MsgValueIn $ appCurrency $ appSettings master}
|
||||
$forall (eTransCash) <- list
|
||||
$case eTransCash
|
||||
$of Left trans
|
||||
<tr>
|
||||
<td>#{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime trans}
|
||||
<td>#{transactionDescription trans}
|
||||
<td>#{formatIntCurrency (transactionAmount trans)} #{appCurrency $ appSettings master}
|
||||
$of Right cash
|
||||
<tr #check>
|
||||
<td colspan="2">
|
||||
_{MsgCashCheckOf $ formatTime defaultTimeLocale "%A %F %H:%M" $ cashCheckTime cash}:
|
||||
<td>#{formatIntCurrency (cashCheckBalance cash)} #{appCurrency $ appSettings master}
|
||||
|
||||
<div>
|
||||
<div .left>
|
||||
$case (p <= 1)
|
||||
$of True
|
||||
<a href="@{JournalR}">_{MsgPreviousPage}
|
||||
$of False
|
||||
<a href="@{JournalPageR (p - 1)}">_{MsgPreviousPage}
|
||||
$if not $ L.null next
|
||||
<div .right>
|
||||
<a href="@{JournalPageR (p + 1)}">_{MsgNextPage}
|
||||
|
||||
$else
|
||||
<p>_{MsgNothingToShow}
|
Loading…
Reference in a new issue