module Handler.Item where import Import itemsPerPage :: Int itemsPerPage = 100 getItemR :: Int64 -> Handler Html getItemR transactionTypeId = getItemPagedR transactionTypeId 1 getItemPagedR :: Int64 -> Int -> Handler Html getItemPagedR tid page | page < 1 = getItemPagedR tid 1 | otherwise = loginOrDo (\(uid,user) -> do items <- runDB $ selectList [TransactionTypeId ==. tid] [Desc TransactionDateTime, LimitTo itemsPerPage, OffsetBy (itemsPerPage*(page-1))] total <- runDB $ count [TransactionTypeId ==. tid] let offset = itemsPerPage * page let maxPages = total `div` itemsPerPage let paginatePages = [1..maxPages+1] loginLayout user $ [whamlet|
Time | P/C | B/S | Item | ## | ISK/Item | ISK total | ISK profit | % | Time | Client | Station | ? | $forall Entity _ t <- items | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#{showDateTime $ transactionDateTime $ t} $if transactionTransForCorp t | C $else | P $if transactionTransIsSell t | S $else | B | #{transactionTypeName t} | #{transactionQuantity t} | #{prettyISK $ transactionPriceCents t} | #{prettyISK $ transactionQuantity t * transactionPriceCents t} $maybe profit <- transRealProfit t $if (&&) (transactionTransIsSell t) (profit > 0) | #{prettyISK $ profit} $elseif (&&) (transactionTransIsSell t) (profit < 0) | #{prettyISK $ profit} $elseif not (transactionTransIsSell t) | #{prettyISK $ profit} $else | #{prettyISK $ profit} | #{profitPercent profit t}% $nothing | - | $maybe secs <- transactionSecondsToSell t #{showSecsToSell secs} $nothing | #{transactionClientName t} | #{transactionStationName t} |