re-work coupons to allow multiple coupon types
[bse.git] / site / templates / admin / coupons / list.tmpl
1 <:wrap admin/base.tmpl title => "Shop: Coupon List", bodyid => "coupon_list":>
2 <h1>Shop: Coupon List</h1>
3 <p>| <a href="<:= cfg.admin_url("menu") :>">Admin Menu</a> |
4 <:.if request.user_can("bse_shop_coupon_add") -:>
5 <a href="<:= cfg.admin_url2("shopadmin", "coupon_addform") :>">Add a coupon</a> |
6 <:.end if-:>
7 </p>
8
9 <:.call "messages"-:>
10 <form action="<:= cfg.admin_url("shopadmin") :>">
11 <:.set object = 0 -:>
12 <:.set errors = {} -:>
13 <fieldset>
14   <legend>Filter/sort</legend>
15   <:.call "inlinefield",
16     "name":"all",
17     "field":{
18               "description": "Show all",
19               "htmltype": "checkbox",
20               "default": coupons_all
21             } -:>
22   <:.call "inlinefield",
23      "name":"sort",
24      "field":{
25                "description": "Sort",
26                "htmltype": "select",
27                "default": coupons_sort,
28                "select":
29                  {
30                    "values":
31                      [
32                        { "id": "expiry", "desc":"By Expiry date" },
33                        { "id": "release", "desc":"By Release date" },
34                        { "id": "code", "desc":"By code" }
35                      ],
36                    "id":"id",
37                    "label":"desc"
38                  }
39              } -:>
40   <:.call "inlinefield",
41      "name": "scode",
42      "field": {
43                 "description": "Search code",
44                 "units": "(=code to search for exact code, otherwise prefix)",
45                 "maxlength": 40,
46                 "size": 20
47               } -:>
48 </fieldset>
49 <p class="buttons"><input type="submit" name="a_coupon_list" value="Sort/Filtter"></p>
50 </form>
51
52 <table>
53   <tr>
54     <th class="col_id">Id</th>
55     <th class="col_code">Code</th>
56     <th class="col_description">Description</th>
57     <th class="col_release">Release</th>
58     <th class="col_expiry">Expires</th>
59     <th class="col_discount">Discount</th>
60     <th class="col_tiers">Tiers</th>
61     <th class="col_campaign">Campaign</th>
62     <th class="col_actions"></th>
63   </tr>
64
65 <:.if coupons.size -:>
66   <:.for coupon in coupons -:>
67     <:.set classes = [ loop.even ? "even" : "odd"  ] -:>
68     <:.if coupon.is_expired -:>
69        <:% classes.push("expired") -:>
70     <:.elsif coupon.is_released -:>
71        <:% classes.push("released") -:>
72     <:.end if -:>
73     <:.set tier_names = [] -:>
74     <:.if coupon.untiered -:>
75       <:% tier_names.push("(untiered)") -:>
76     <:.end if :>
77     <:.for tier in [ coupon.tier_objects ] -:>
78       <:% tier_names.push(tier.description) -:>
79     <:.end for -:>
80   <tr class="<:= classes.join(" ") :>">
81     <td class="col_id"><a href="<:= cfg.admin_url2("shopadmin", "details", { "id": coupon.id }) :>"><:= coupon.id :></a></td>
82     <td class="col_code"><:= coupon.code :></td>
83     <td class="col_description"><:= coupon.description :></td>
84     <td class="col_release"><:= bse.date("%d/%m/%Y", coupon.release) :></td>
85     <td class="col_expiry"><:= bse.date("%d/%m/%Y", coupon.expiry) :></td>
86     <td class="col_discount"><:= coupon.describe :></td>
87     <td class="col_tiers"><:= tier_names.size ? tier_names.join(", ") : "(none)" :></td>
88     <td class="col_campaign"><:= coupon.campaign :></td>
89     <td class="col_actions">
90       <:.if request.user_can("bse_shop_coupon_edit") -:>
91         <a href="<:= cfg.admin_url2("shopadmin", "coupon_edit", { "id": coupon.id }) :>">Edit</a>
92       <:.end if -:>
93       <:.if request.user_can("bse_shop_coupon_delete") and coupon.is_removable -:>
94         <a href="<:= cfg.admin_url2("shopadmin", "coupon_deleteform", { "id": coupon.id }) :>">Delete</a>
95       <:.end if -:>
96     </td>
97   </tr>
98   <:.end for -:>
99 <:.else -:>
100   <tr class="nothing">
101     <td colspan="8">No coupons are currently defined</td>
102   </tr>
103 <:.end if -:>
104 </table>