--- /dev/null
+dojo.require('openils.Util');
+dojo.require('openils.User');
+dojo.require('openils.widget.AutoGrid');
+dojo.require('fieldmapper.OrgUtils');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
+
+var contextOrg;
+
+function setup() {
+ buildGrid();
+
+ var connect = function() {
+ dojo.connect(contextOrgSelector, 'onChange',
+ function() {
+ contextOrg = this.attr('value');
+ crGrid.resetStore();
+ buildGrid();
+ }
+ );
+ };
+
+ new openils.User().buildPermOrgSelector(
+ 'ADMIN_ACQ_CANCEL_CAUSE', contextOrgSelector, null, connect);
+}
+
+function buildGrid() {
+
+ if(contextOrg == null)
+ contextOrg = openils.User.user.ws_ou();
+
+ crGrid.loadAll(
+ {order_by : {acqcr : 'label'}},
+ {org_unit : fieldmapper.aou.fullPath(contextOrg, true)}
+ );
+}
+
+openils.Util.addOnLoad(setup);
+
+
--- /dev/null
+[% WRAPPER default/base.tt2 %]
+[% ctx.page_titel = 'Cancel Reasons' %]
+<script src='[% ctx.media_prefix %]/js/ui/default/conify/global/acq/cancel_reason.js'> </script>
+
+<!-- grid -->
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>PO / Item / Request Cancellation Reasons</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='crGrid.showCreateDialog()'>New Cancel Reason</button>
+ <button dojoType='dijit.form.Button' onClick='crGrid.deleteSelected()'>Delete Selected</button>
+ </div>
+ </div>
+ <div>
+ <span>Context Org Unit</span>
+ <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='contextOrgSelector'
+ searchAttr='shortname' labelAttr='shortname'> </select>
+ </div>
+ <table jsId="crGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'org_unit', 'label', 'description']"
+ query="{id: '*'}"
+ defaultCellWidth='"auto"'
+ fmClass='acqcr'
+ showPaginator='true'
+ editOnEnter='true'>
+ </table>
+ </div>
+</div>
+[% END %]
+
+