module Handler.Item where import Import itemsPerPage :: Int itemsPerPage = 100 getItemR :: Int64 -> Handler Html getItemR transactionTypeId = getItemPagedR transactionTypeId 0 getItemPagedR :: Int64 -> Int -> Handler Html getItemPagedR tid page = loginOrDo (\(uid,user) -> do items <- runDB $ selectList [TransactionTypeId ==. tid] [Desc TransactionDateTime, LimitTo itemsPerPage, OffsetBy (itemsPerPage*page)] total <- runDB $ count [TransactionTypeId ==. tid] let offset = itemsPerPage * page loginLayout user $ [whamlet|
$if page > 0
#{itemsPerPage} Transactions (starting at #{offset}) $else
#{itemsPerPage} Transactions
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} |] )