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');
20 /** really need to put this in a shared location... */
21 function getOrgInfo(rowIndex, item) {
23 var orgId = this.grid.store.getValue(item, this.field);
24 return fieldmapper.aou.findOrgUnit(orgId).shortname();
27 function thingInit() {
29 thingGrid.disableSelectorForRow = function(rowIdx) {
30 var item = thingGrid.getItem(rowIdx);
31 return (thingGrid.store.getValue(item, 'id') < 0);
35 var connect = function() {
36 dojo.connect(thingContextOrgSelect, 'onChange',
38 thingContextOrg = this.getValue();
39 thingGrid.resetStore();
44 // go ahead and let staff see everything
45 new openils.User().buildPermOrgSelector('STAFF_LOGIN', thingContextOrgSelect, null, connect);
48 function buildGrid() {
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};
56 if(thingContextOrg == null)
57 thingContextOrg = openils.User.user.ws_ou();
59 fieldmapper.standardRequest(
60 ['open-ils.pcrud', 'open-ils.pcrud.search.aum.atomic'],
63 openils.User.authtoken,
65 "sending_lib":fieldmapper.aou.descendantNodeList(thingContextOrg,true),
68 {"order_by":{"aum":"create_date DESC"}}
70 oncomplete: function(r) {
71 if(thingList = openils.Util.readResponse(r)) {
72 thingList = openils.Util.objectSort(thingList);
73 dojo.forEach(thingList,
75 thingGrid.store.newItem(aum.toStoreItem(e));
84 openils.Util.addOnLoad(thingInit);
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>
93 <button dojoType='dijit.form.Button' onClick='thingGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
97 <span>[% l('Context Org Unit') %]</span>
98 <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='thingContextOrgSelect'
99 searchAttr='shortname' labelAttr='shortname'> </select>
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']"
108 defaultCellWidth='10'
111 <tr><th field='sending_lib' get='getOrgInfo'/></tr>