summaryrefslogtreecommitdiff
path: root/templates/inventoryListing.hamlet
blob: 8eee3e76c27d5908dd63993eb8fe7d6bacc1feab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<div .table>
  <div .tr .sepBelow>
    <div .itemH>
    <div .th>Item
    <div .th>Type
    <div .th>Bought
    <div .th>Expires
    <div .th>Opened
    <div .th>Status
    <div .th>Actions
  $if isJust (preview insertForm =<< formState)
    $with Just InsertForm{..} <- formState
      <form .tr .sepBelow action=@{InventoryListingR} method=post enctype=#{fsInsertEncoding}>
        <div .td>
        ^{fsInsertForm}
        <div .td>
          <button type=submit>
            Insert
  $forall WithType (Entity itemId Item{..}) itemType <- stock
    $if Just itemId == (preview updateId =<< formState)
      $with Just UpdateForm{..} <- formState
         <form .tr .color action=@{UpdateItemR fsUpdateId}##{toPathPiece fsUpdateId} method=post enctype=#{fsUpdateEncoding} ##{toPathPiece fsUpdateId}>
           <div .itemId>#{humanId itemId}
           ^{fsUpdateForm}
           <div .td>
             <button type=submit>
               Save Changes
    $else
      <div .tr .color ##{toPathPiece itemId}>
        <div .itemId>#{humanId itemId}
        <div .kind>#{itemKind}
        <div .type>#{itemType}
        <div .td .day>
          $case itemBought
            $of DateUnknown
              <hr>
            $of DateKnown d
              #{dayFormat d}
            $of DateNever
        <div .td .day>
          $case itemExpires
            $of DateNever
              <hr>
            $of DateKnown d
              <span :d < today:.expired :d < addDays 7 today:.expireWeek :d < addGregorianMonthsRollOver 1 today:.expireMonth>#{dayFormat d}
            $of DateUnknown
        <div .td .day>
          $case itemOpened
            $of DateKnown d
              #{dayFormat d}
            $of DateUnknown
              Yes
            $of DateNever
        <div .td>
          <ul .status>
            $if itemRunningLow
              <li>Running low
        <div .td>
          <div .table .actions>
            <div .tr>
              $if isNever itemOpened
                <form method=post action=@{OpenItemR itemId}>
                  <button type=submit>
                    Open
              $else
                <div .td>&nbsp;
              <form method=get action=@{UpdateItemR itemId}##{toPathPiece itemId} .td>
                <button type=submit>
                  Edit
            <div .tr>
              $if not itemRunningLow
                <form method=post action=@{LowItemR itemId} .td>
                  <button type=submit>
                    Running low
              $else
                <div .td>&nbsp;
              <form method=post action=@{DeleteItemR itemId} .td>
                <button type=submit>
                  Delete