]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/conify/global/config/hard_due_date.tt2
LP#1178802: force ceiling dates to be end of day
[Evergreen.git] / Open-ILS / src / templates / conify / global / config / hard_due_date.tt2
1 [% WRAPPER base.tt2 %]
2 [% ctx.page_title = l("Hard Due Dates") %]
3 <script type="text/javascript">
4     dojo.require("openils.CGI");
5     dojo.require("openils.Util");
6     dojo.require("openils.widget.AutoGrid");
7     dojo.require("dojo.date.locale");
8     dojo.require("dojo.date.stamp");
9
10
11     function get_chdd_name(rowIndex, item) {
12         if (!item) return null;
13         else return {
14             "id": this.grid.store.getValue(item, "id"),
15             "name": this.grid.store.getValue(item, "name")
16         };
17     }
18
19     function format_chdd_name(blob) {
20         if (blob) {
21             return "<a href='" + oilsBasePath +
22                 "/conify/global/config/hard_due_date_values?chdd=" +
23                 blob.id + "'>" + blob.name + "</a>";
24         } else {
25             return "";
26         }
27     }
28
29     openils.Util.addOnLoad(
30         function() {
31             var cgi = new openils.CGI();
32             var filter = null;
33             var id = cgi.param("id");
34             var name = cgi.param("name");
35             if (id) {
36                 filter = {"id": id};
37                 openils.Util.show("one_only");
38             } else if (name) {
39                 filter = {"name": name};
40                 openils.Util.show("one_only");
41             }
42             chddGrid.loadAll({"order_by": {"chdd": "name"}}, filter);
43
44             function munge_ceiling(chdd) {
45                 var cd = dojo.date.stamp.fromISOString(chdd.ceiling_date());
46                 // set to end of day in client time zone; if we were using
47                 // moment, we could do moment().endOf('day') instead
48                 cd.setHours(23, 59, 59);
49                 chdd.ceiling_date(dojo.date.stamp.toISOString(cd));
50             }
51             chddGrid.onEditPane = function(pane) {
52                 pane.onSubmit = function(chdd, ops) {
53                     munge_ceiling(chdd);
54                     (new openils.PermaCrud())[pane.mode](chdd, ops);
55                }
56             }
57             chddGrid.createPaneOnSubmit = function(chdd, ops, pane) {
58                 munge_ceiling(chdd);
59                 (new openils.PermaCrud())[pane.mode](chdd, ops);
60             }
61         }
62     );
63 </script>
64 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
65     <div dojoType="dijit.layout.ContentPane"
66         layoutAlign="top" class="oils-header-panel">
67         <div>Hard Due Dates</div>
68         <div>
69             <button
70                 dojoType="dijit.form.Button"
71                 onClick="chddGrid.showCreateDialog();">New Hard Due Date</button>
72             <button
73                 dojoType="dijit.form.Button"
74                 onClick="chddGrid.deleteSelected();">Deleted Selected</button>
75         </div>
76     </div>
77     <div id="one_only" class="hidden">
78         <em>Showing only one hard due date.</em> [
79             <a href="./hard_due_date">Show them all</a>
80         ]
81     </div>
82     <div>
83         <table jsId="chddGrid"
84             dojoType="openils.widget.AutoGrid"
85             showPaginator="true"
86             query="{name: '*'}"
87             defaultCellWidth="'auto'"
88             fieldOrder="['name', 'owner', 'ceiling_date', 'forceto']"
89             fmClass="chdd"
90             hideSelector="false"
91             editOnEnter="true">
92             <thead>
93                 <tr>
94                     <th field="name" get="get_chdd_name"
95                         formatter="format_chdd_name"></th>
96                 </tr>
97             </thead>
98         </table>
99     </div>
100 </div>
101 [% END %]