LP1873286: Fix Bad End Tags
[working/Evergreen.git] / Open-ILS / src / templates / actor / user / message.tt2
1 [% WRAPPER base.tt2 %]
2 [% ctx.page_title = l('Patron Messages') %]
3 [% usr_id = ctx.page_args.0 %]
4 <script type="text/javascript">
5     dojo.require('dojox.grid.DataGrid');
6     dojo.require('openils.widget.AutoGrid');
7     dojo.require('dojox.grid.cells.dijit');
8     dojo.require('dojo.data.ItemFileWriteStore');
9     dojo.require('dijit.form.CurrencyTextBox');
10     dojo.require('dijit.Dialog');
11     dojo.require('dojox.widget.PlaceholderMenuItem');
12     dojo.require('fieldmapper.OrgUtils');
13     dojo.require('dijit.form.FilteringSelect');
14     dojo.require('openils.PermaCrud');
15     dojo.require('openils.widget.OrgUnitFilteringSelect');
16
17     var thingContextOrg;
18     var thingList;
19
20     /** really need to put this in a shared location... */
21     function getOrgInfo(rowIndex, item) {
22         if(!item) return '';
23         var orgId = this.grid.store.getValue(item, this.field);
24         return fieldmapper.aou.findOrgUnit(orgId).shortname();
25     }
26
27     function thingInit() {
28
29         thingGrid.disableSelectorForRow = function(rowIdx) {
30             var item = thingGrid.getItem(rowIdx);
31             return (thingGrid.store.getValue(item, 'id') < 0);
32         }
33
34         buildGrid();
35         var connect = function() {
36             dojo.connect(thingContextOrgSelect, 'onChange',
37                         function() {
38                             thingContextOrg = this.getValue();
39                             thingGrid.resetStore();
40                             buildGrid();
41                         }
42                         );
43         };
44         // go ahead and let staff see everything
45         new openils.User().buildPermOrgSelector('STAFF_LOGIN', thingContextOrgSelect, null, connect);
46     }
47
48     function buildGrid() {
49
50         thingGrid.overrideWidgetArgs.title = {readOnly : true};
51         thingGrid.overrideWidgetArgs.create_date = {readOnly : true};
52         thingGrid.overrideWidgetArgs.message = {readOnly : true};
53         thingGrid.overrideWidgetArgs.read_date = {readOnly : true};
54         thingGrid.overrideWidgetArgs.sending_lib = {readOnly : true};
55
56         if(thingContextOrg == null)
57             thingContextOrg = openils.User.user.ws_ou();
58
59         fieldmapper.standardRequest(
60             ['open-ils.pcrud', 'open-ils.pcrud.search.aum.atomic'],
61             {   async: true,
62                 params: [
63                     openils.User.authtoken,
64                     {
65                         "sending_lib":fieldmapper.aou.descendantNodeList(thingContextOrg,true),
66                         "usr":[% usr_id %]
67                     },
68                     {"order_by":{"aum":"create_date DESC"}}
69                 ],
70                 oncomplete: function(r) {
71                     if(thingList = openils.Util.readResponse(r)) {
72                         thingList = openils.Util.objectSort(thingList);
73                         dojo.forEach(thingList,
74                                     function(e) {
75                                         thingGrid.store.newItem(aum.toStoreItem(e));
76                                     }
77                                     );
78                     }
79                 }
80             }
81         );
82     }
83
84     openils.Util.addOnLoad(thingInit);
85 </script>
86
87 <!-- grid -->
88
89 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
90         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
91             <div>[% l('Patron Messages') %]</div>
92             <div>
93                 <button dojoType='dijit.form.Button' onClick='thingGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
94             </div>
95         </div>
96         <div>
97             <span>[% l('Context Org Unit') %]</span>
98             <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='thingContextOrgSelect'
99                 searchAttr='shortname' labelAttr='shortname'> </select>
100         </div>
101         <table  jsId="thingGrid"
102                 dojoType="openils.widget.AutoGrid"
103                 query="{usr: [% usr_id %]}"
104                 fieldOrder="['id', 'create_date', 'title', 'sending_lib', 'read_date', 'deleted']"
105                 suppressFields="['usr', 'message']"
106                 suppressEditFields="['id','usr']"
107                 fmClass='aum'
108                 defaultCellWidth='10'
109                 editOnEnter='true'>
110             <thead>
111                 <tr><th field='sending_lib' get='getOrgInfo'></th></tr>
112             </thead>
113         </table>
114     </div>
115 </div>
116 [% END %]