]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/conify/global/config/hard_due_date_values.tt2
LP#1178802: force ceiling dates to be end of day
[Evergreen.git] / Open-ILS / src / templates / conify / global / config / hard_due_date_values.tt2
1 [% WRAPPER base.tt2 %]
2 [% ctx.page_title = l("Hard Due Date Values") %]
3 <script type="text/javascript">
4     dojo.require("openils.CGI");
5     dojo.require("openils.PermaCrud");
6     dojo.require("openils.Util");
7     dojo.require("openils.widget.AutoGrid");
8     dojo.require("dijit.form.TextBox");
9     dojo.require("dojo.date.locale");
10     dojo.require("dojo.date.stamp");
11
12     openils.Util.addOnLoad(
13         function() {
14             var filter = null;
15             var chdd_id = (new openils.CGI()).param("chdd");
16
17             if (chdd_id) {
18                 filter = {"hard_due_date": chdd_id};
19                 var hard_due_date =
20                     (new openils.PermaCrud()).retrieve("chdd", chdd_id);
21
22                 dojo.byId("linked_chdd_name").innerHTML = hard_due_date.name();
23                 dojo.byId("linked_chdd_link").innerHTML = hard_due_date.id();
24                 dojo.byId("linked_chdd_link").onclick = function() {
25                     location.href = oilsBasePath +
26                         "/conify/global/config/hard_due_date?id=" +
27                         hard_due_date.id();
28                 };
29                 openils.Util.show("linked_chdd");
30             }
31
32             chddvGrid.overrideEditWidgets.hard_due_date =
33                 new dijit.form.TextBox({"disabled": true});
34             chddvGrid.overrideEditWidgets.hard_due_date.shove = {
35                 "create": chdd_id
36             };
37
38             function munge_ceiling(chddv) {
39                 var cd = dojo.date.stamp.fromISOString(chddv.ceiling_date());
40                 // set to end of day in client time zone; if we were using
41                 // moment, we could do moment().endOf('day') instead
42                 cd.setHours(23, 59, 59);
43                 chddv.ceiling_date(dojo.date.stamp.toISOString(cd));
44             }
45             chddvGrid.onEditPane = function(pane) {
46                 pane.onSubmit = function(chddv, ops) {
47                     munge_ceiling(chddv);
48                     (new openils.PermaCrud())[pane.mode](chddv, ops);
49                }
50             }
51             chddvGrid.createPaneOnSubmit = function(chddv, ops, pane) {
52                 munge_ceiling(chddv);
53                 (new openils.PermaCrud())[pane.mode](chddv, ops);
54             }
55
56             chddvGrid.loadAll({"order_by": {"chddv": "active_date"}}, filter);
57         }
58     );
59 </script>
60 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
61     <div dojoType="dijit.layout.ContentPane"
62         layoutAlign="top" class="oils-header-panel">
63         <div>[% l('Hard Due Date Values') %]</div>
64         <div>
65             <button
66                 dojoType="dijit.form.Button"
67                 onClick="chddvGrid.showCreateDialog();">[% l('New Hard Due Date Value') %]</button>
68             <button
69                 dojoType="dijit.form.Button"
70                 onClick="chddvGrid.deleteSelected();">[% l('Deleted Selected') %]</button>
71         </div>
72     </div>
73     <div class="hidden" id="linked_chdd">
74         <em>[% l('Showing only hard due date values related to hard due date object') %]</em>
75         <strong id="linked_chdd_name"></strong> (#
76         <a href="javascript:void(0);" id="linked_chdd_link"></a>)
77     </div>
78     <div>
79         <table jsId="chddvGrid"
80             dojoType="openils.widget.AutoGrid"
81             showPaginator="true"
82             query="{name: '*'}"
83             defaultCellWidth="'auto'"
84             fieldOrder="['hard_due_date', 'ceiling_date', 'active_date']"
85             suppressFields="['hard_due_date']"
86             suppressEditFields="['id']"
87             fmClass="chddv"
88             hideSelector="true"
89             editOnEnter="true">
90         </table>
91     </div>
92 </div>
93 [% END %]