|
1 | 1 | [% escape_title( 'Purchase list', list.name ); |
2 | 2 |
|
3 | | -title = title _ ' on ' _ display_date(list.date, {short=>1}); |
4 | | -html_title = html_title _ ' on ' _ display_date(list.date, {html=>1}); |
| 3 | +title = title _ ' for ' _ display_date(list.date, {short=>1}); |
| 4 | +html_title = html_title _ ' for ' _ display_date(list.date, {html=>1}); |
5 | 5 | %] |
6 | 6 |
|
7 | 7 | [% FOREACH section IN sections %] |
8 | | -<h3>[% section.name || "No shop section" | html %]</h3> |
9 | | - |
10 | | -<table class="purchase-items"> |
11 | | - <thead> |
12 | | - <tr> |
13 | | - <th>Amount</th> |
14 | | - <th>Article</th> |
15 | | - <th>Dishes</th> |
16 | | - <th>Comment</th> |
17 | | - <th>Convert to …</th> |
18 | | - </tr> |
19 | | - </thead> |
20 | | - [% FOREACH item IN section.items %] |
21 | | - <tr> |
22 | | - <td> |
23 | | - <form name="total" class="inline" method="post" action="[% item.update_offset_url %]"> |
24 | | - [% IF item.offset %] |
25 | | - <label for="item_value">ca.</label> |
26 | | - [% END %] |
27 | | - <input type="number" min="0" step="any" class="editable-content" id="total" name="total" value="[% item.value + item.offset %]"> |
28 | | - <input type="submit" class="hidden" value="submit" title="Submit new value for item"> |
29 | | - </form> |
30 | | - [% ' ' IF item.unit.space; |
31 | | - display_unit( item.unit, {html=>1} ) %] |
32 | | - </td> |
33 | | - <td>[% item.article.name | html %]</td> |
34 | | - <td class="small-font"><ul> |
35 | | - [% FOREACH ingredient IN item.ingredients %] |
36 | | - <li> |
37 | | - [% display_value_unit( ingredient.value, ingredient.unit, {html=>1} ) %] |
38 | | - – |
39 | | - [% ingredient.dish.meal.date.strftime('%a, %F') %] |
40 | | - [% ingredient.dish.meal.name | html %]: |
41 | | - [% ingredient.dish.name | html %] |
42 | | - [% IF ingredient.comment; '('; ingredient.comment | html; ')'; END %] |
43 | | - [% IF ingredient.remove_url %] |
44 | | - <form class="inline" method="post" action="[% ingredient.remove_url %]"><input type="submit" value="Remove"></form> |
45 | | - [% END %] |
46 | | - </li> |
47 | | - [% END %] |
48 | | - [% IF item.offset %] |
49 | | - <li>[% display_value_unit( item.offset, ingredient.unit, {html=>1, force_sign=>1} ) %] – <em>rounding difference</em> |
50 | | - <form name="remove-offset" class="inline" method="post" action="[% item.update_offset_url %]"> |
51 | | - <input type="hidden" name="offset" value="0"> |
52 | | - <input type="submit" value="Remove"> |
53 | | - </form> |
54 | | - </li> |
55 | | - [% END %] |
56 | | - </ul></td> |
57 | | - <td>[% item.comment %]</td> |
58 | | - <td> |
59 | | - [% FOREACH unit IN item.convertible_into; |
60 | | - IF item.convert_url %] |
61 | | - <form class="inline" method="post" action="[% item.convert_url %]"> |
62 | | - <input type="hidden" name="unit" value="[% unit.id %]"> |
63 | | - <input type="submit" value="[% unit.short_name | html %]" title="[% unit.long_name | html %]"> |
64 | | - </form> |
65 | | - [% END; |
66 | | - END %] |
67 | | - </td> |
68 | | - <tr> |
69 | | - [% END %] |
70 | | -</table> |
| 8 | +<div class="row my-3"> |
| 9 | + <div class="col-12 mb-2"> |
| 10 | + <h3 class="text-success">[% section.name || "No shop section" | html FILTER ucfirst %]</h3> |
| 11 | + </div> |
| 12 | + |
| 13 | + <div class="col-12 mb-2 table-responsive"> |
| 14 | + <table id="pl-editor" class="table align-middle"> |
| 15 | + <colgroup> |
| 16 | + <col style="width:25%"> |
| 17 | + <col style="width:10%"> |
| 18 | + <col style="width:5%"> |
| 19 | + <col style="width:15%"> |
| 20 | + <col style="width:10%"> |
| 21 | + <col style="width:10%"> |
| 22 | + <col class="btn-icon-1"> |
| 23 | + <col> |
| 24 | + </colgroup> |
| 25 | + <thead> |
| 26 | + <tr> |
| 27 | + <th>Amount</th> |
| 28 | + <th>Article</th> |
| 29 | + <th colspan="5">Dishes</th> |
| 30 | + <th>Comment</th> |
| 31 | + </tr> |
| 32 | + </thead> |
| 33 | + <tbody> |
| 34 | + [% FOREACH item IN section.items %] |
| 35 | + <tr> |
| 36 | + [% rowspan = item.ingredients.size; |
| 37 | + IF item.offset; |
| 38 | + rowspan = rowspan + 1; |
| 39 | + END; |
| 40 | + %] |
| 41 | + <td rowspan="[% rowspan %]"> |
| 42 | + <datalist id="values-[% loop.count %]"> |
| 43 | + <option value="[% item.value + item.offset %]"> |
| 44 | + <option value="[% item.next_higher_value %]"> |
| 45 | + <option value="[% item.next_lower_value%]"> |
| 46 | + </datalist> |
| 47 | + <form id="total-[% loop.count %]" name="total" method="post" action="[% item.update_offset_url %]"></form> |
| 48 | + <form id="units-[% loop.count %]" method="post" action="[% item.convert_url %]"></form> |
| 49 | + <div class="d-flex justify-content-between"> |
| 50 | + <div class="input-group flex-nowrap"> |
| 51 | + [% IF item.offset %]<span class="input-group-text px-1">ca.</span>[% END %] |
| 52 | + <input id="total" class="form-control" form="total-[% loop.count %]" type="number" min="0" step="any" name="total" list="values-[% loop.count %]" value="[% item.value + item.offset %]"> |
| 53 | + <span class="input-group-text">[% display_unit( item.unit, {html=>1} ) %]</span> |
| 54 | + </div> |
| 55 | + <button class="btn btn-outline-primary ms-1 material-icons" form="total-[% loop.count %]" type="submit" title="Update amount">sync</button> |
| 56 | + </div> |
| 57 | + [% IF item.convert_url %] |
| 58 | + <div class="d-flex flex-wrap border rounded my-1 w-100"> |
| 59 | + [% idx = loop.count; |
| 60 | + FOREACH unit IN item.convertible_into %] |
| 61 | + <button class="btn btn-outline-secondary btn-sm m-1" form="units-[% idx %]" type="submit" name="unit" value="[% unit.id %]">[% unit.short_name | html %]</button> |
| 62 | + [% END; |
| 63 | + END %] |
| 64 | + </div> |
| 65 | + </td> |
| 66 | + <td rowspan="[% rowspan %]">[% item.article.name | html %]</td> |
| 67 | + |
| 68 | + [% FOREACH ingredient IN item.ingredients %] |
| 69 | + [% IF loop.index == 0 %] |
| 70 | + [% INCLUDE purchase_list/snippet_dish.tt %] |
| 71 | + </tr> |
| 72 | + |
| 73 | + [% ELSE %] |
| 74 | + <tr> |
| 75 | + [% INCLUDE purchase_list/snippet_dish.tt %] |
| 76 | + </tr> |
| 77 | + [% END; |
| 78 | + END; |
| 79 | + |
| 80 | + IF item.offset %] |
| 81 | + <tr> |
| 82 | + <td colspan="4" class="text-end"> |
| 83 | + <small>[% display_value_unit( item.offset, ingredient.unit, {html=>1, force_sign=>1} ) %] – <em>rounding difference</em></small> |
| 84 | + </td> |
| 85 | + <td> |
| 86 | + <form name="remove-offset" method="post" action="[% item.update_offset_url %]"> |
| 87 | + <button type="submit" class="btn btn-danger btn-sm btn-quad mb-1 material-icons" title="Reset rounding" name="offset" value="0">undo</button> |
| 88 | + </form> |
| 89 | + </td> |
| 90 | + <td></td> |
| 91 | + </tr> |
| 92 | + [% END; |
| 93 | + |
| 94 | + END %] |
| 95 | + </tbody> |
| 96 | + </table> |
| 97 | + |
| 98 | + </div> |
| 99 | +</div> |
71 | 100 | [% END %] |
72 | | - |
73 | | -<style> |
74 | | -table.purchase-items { |
75 | | - width: 100%; /* there are several tables with many columns and they should have identical width */ |
76 | | -} |
77 | | -</style> |
|
0 commit comments