[open-ils-commits] r15568 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/ui/default/acq/po web/opac/locale/en-US web/templates/default/acq/po xul/staff_client/chrome/content/main xul/staff_client/chrome/locale/en-US (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 17 17:15:15 EST 2010
Author: phasefx
Date: 2010-02-17 17:15:09 -0500 (Wed, 17 Feb 2010)
New Revision: 15568
Added:
trunk/Open-ILS/web/js/ui/default/acq/po/events.js
trunk/Open-ILS/web/templates/default/acq/po/events.tt2
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
UI for Purchase Order related Events
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2010-02-17 20:51:19 UTC (rev 15567)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2010-02-17 22:15:09 UTC (rev 15568)
@@ -1162,6 +1162,10 @@
(my $search_field = $self->api_name) =~ s/.*\.([_a-z]+)$/$1/;
my $obj_type = 'acqpo';
+ if ($search_field eq 'ordering_agency') {
+ $search_value = $U->get_org_descendants($search_value);
+ }
+
my $query = {
"select"=>{"atev"=>["id"]},
"from"=>"atev",
@@ -1183,7 +1187,8 @@
}
},
"state"=>"pending"
- }
+ },
+ "order_by"=>[{"class"=>"atev", "field"=>"run_time", "direction"=>"desc"}]
};
if (defined $options->{state}) {
@@ -1194,6 +1199,9 @@
$query->{'where'}{'start_time'} = $options->{start_time};
}
+ if (defined $options->{order_by}) {
+ $query->{'order_by'} = $options->{order_by};
+ }
my $po_events = $e->json_query($query);
my $flesh_fields = $options->{flesh_fields} || {};
Added: trunk/Open-ILS/web/js/ui/default/acq/po/events.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/po/events.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/acq/po/events.js 2010-02-17 22:15:09 UTC (rev 15568)
@@ -0,0 +1,223 @@
+dojo.require('openils.widget.AutoGrid');
+dojo.require('fieldmapper.OrgUtils');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
+dojo.require('dijit.form.DateTextBox');
+dojo.require('dojo.date.stamp');
+
+var eventState;
+var eventContextOrg;
+var eventList;
+var eventStartDateRange;
+var eventEndDateRange;
+
+function eventInit() {
+ try {
+ buildStateSelector();
+ buildOrgSelector();
+ buildDatePickers();
+ buildEventGrid();
+ } catch(E) {
+ //dump('Error in acq/events.js, eventInit(): ' + E);
+ throw(E);
+ }
+}
+
+function buildDatePickers() {
+ var today = new Date();
+ var yesterday = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1);
+ eventStartDatePicker.constraints.max = today;
+ eventStartDatePicker.setValue( yesterday );
+ eventStartDateRange = eventStartDatePicker.getValue();
+ eventEndDatePicker.constraints.max = today;
+ eventEndDatePicker.setValue( today );
+ eventEndDateRange = eventEndDatePicker.getValue();
+ dojo.connect(
+ eventStartDatePicker,
+ 'onChange',
+ function() {
+ var new_date = arguments[0];
+ if (new_date > eventEndDatePicker.getValue()) {
+ var swap = eventEndDatePicker.getValue();
+ eventEndDatePicker.setValue( new_date );
+ this.setValue( swap );
+ }
+ eventStartDateRange = this.getValue();
+ eventGrid.resetStore();
+ buildEventGrid();
+ }
+ );
+ dojo.connect(
+ eventEndDatePicker,
+ 'onChange',
+ function() {
+ var new_date = arguments[0];
+ if (new_date < eventStartDatePicker.getValue()) {
+ var swap = eventStartDatePicker.getValue();
+ eventStartDatePicker.setValue( new_date );
+ this.setValue( swap );
+ }
+ eventEndDateRange = this.getValue();
+ eventGrid.resetStore();
+ buildEventGrid();
+ }
+ );
+
+}
+
+function buildStateSelector() {
+ try {
+ eventStateSelect.store = new dojo.data.ItemFileReadStore({
+ data : {
+ identifier:"value",
+ label: "name",
+ items: [
+ /* FIXME: I18N? */
+ {name:"Pending", value:'pending'},
+ {name:"Complete", value:'complete'},
+ {name:"Error", value:'error'}
+ ]
+ }
+ });
+ eventStateSelect.setValue('pending');
+ dojo.connect(
+ eventStateSelect,
+ 'onChange',
+ function() {
+ try {
+ eventState = this.getValue();
+ eventGrid.resetStore();
+ buildEventGrid();
+ } catch(E) {
+ //dump('Error in acq/events.js, eventInit, connect, onChange: ' + E);
+ throw(E);
+ }
+ }
+ );
+
+ } catch(E) {
+ //dump('Error in acq/events.js, buildStateSelector(): ' + E);
+ throw(E);
+ }
+}
+
+function buildOrgSelector() {
+ try {
+ var connect = function() {
+ try {
+ dojo.connect(
+ eventContextOrgSelect,
+ 'onChange',
+ function() {
+ try {
+ eventContextOrg = this.getValue();
+ eventGrid.resetStore();
+ buildEventGrid();
+ } catch(E) {
+ //dump('Error in acq/events.js, eventInit, connect, onChange: ' + E);
+ throw(E);
+ }
+ }
+ );
+ } catch(E) {
+ //dump('Error in acq/events.js, eventInit, connect: ' + E);
+ throw(E);
+ }
+ };
+ new openils.User().buildPermOrgSelector('STAFF_LOGIN', eventContextOrgSelect, null, connect);
+
+ eventGrid.cancelSelected = function() { doSelected('open-ils.acq.purchase_order.event.cancel.batch') };
+ eventGrid.resetSelected = function() { doSelected('open-ils.acq.purchase_order.event.reset.batch') };
+
+ } catch(E) {
+ //dump('Error in acq/events.js, buildOrgSelector(): ' + E);
+ throw(E);
+ }
+}
+
+function doSelected(method) {
+ try {
+ var ids = [];
+ dojo.forEach(
+ eventGrid.getSelectedItems(),
+ function(item) {
+ ids.push( eventGrid.store.getValue(item,'id') );
+ }
+ );
+ fieldmapper.standardRequest(
+ [ 'open-ils.acq', method ],
+ { async: true,
+ params: [openils.User.authtoken, ids],
+ onresponse: function(r) {
+ try {
+ var result = openils.Util.readResponse(r);
+ if (typeof result.ilsevent != 'undefined') { throw(result); }
+ } catch(E) {
+ //dump('Error in acq/events.js, doSelected(), onresponse(): ' + E);
+ }
+ },
+ onerror: function(r) {
+ try {
+ var result = openils.Util.readResponse(r);
+ throw(result);
+ } catch(E) {
+ //dump('Error in acq/events.js, doSelected(), onerror(): ' + E);
+ throw(E);
+ }
+ },
+ oncomplete: function(r) {
+ try {
+ var result = openils.Util.readResponse(r);
+ eventGrid.resetStore();
+ buildEventGrid();
+ } catch(E) {
+ //dump('Error in acq/events.js, doSelected(), oncomplete(): ' + E);
+ throw(E);
+ }
+ }
+ }
+ );
+ } catch(E) {
+ //dump('Error in acq/events.js, doSelected(): ' + E);
+ throw(E);
+ }
+}
+
+function buildEventGrid() {
+ if(eventContextOrg == null) {
+ eventContextOrg = openils.User.user.ws_ou();
+ }
+ if(eventState == null) {
+ eventState = 'pending';
+ }
+ var filter = {"state":eventState, "order_by":[{"class":"atev", "field":"run_time", "direction":"desc"}]};
+ if(eventStartDateRange != null) {
+ /* the dijit appears to always provide 00:00:00 for the timestamp component */
+ var end_of_day = eventEndDateRange; end_of_day.setDate( end_of_day.getDate() + 1 );
+ filter['start_time'] = {
+ 'between' : [
+ dojo.date.stamp.toISOString( eventStartDateRange ),
+ dojo.date.stamp.toISOString( end_of_day )
+ ]
+ }
+ }
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.purchase_order.events.ordering_agency'],
+ { async: true,
+ params: [openils.User.authtoken, eventContextOrg, filter],
+ onresponse: function(r) {
+ try {
+ if(eventObject = openils.Util.readResponse(r)) {
+ eventGrid.store.newItem(atev.toStoreItem(eventObject));
+ }
+ } catch(E) {
+ //dump('Error in acq/events.js, buildEventGrid, onresponse: ' + E);
+ throw(E);
+ }
+ }
+ }
+ );
+}
+
+openils.Util.addOnLoad(eventInit);
+
+
Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2010-02-17 20:51:19 UTC (rev 15567)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2010-02-17 22:15:09 UTC (rev 15568)
@@ -782,6 +782,8 @@
<!ENTITY staff.main.menu.acq.upload.accesskey "O">
<!ENTITY staff.main.menu.acq.po.label "Purchase Orders">
<!ENTITY staff.main.menu.acq.po.accesskey "P">
+<!ENTITY staff.main.menu.acq.po_events.label "Purchase Order Events">
+<!ENTITY staff.main.menu.acq.po_events.accesskey "E">
<!ENTITY staff.main.menu.acq.fund.label "Funds">
<!ENTITY staff.main.menu.acq.fund.accesskey "F">
<!ENTITY staff.main.menu.acq.funding_source.label "Funding Sources">
Added: trunk/Open-ILS/web/templates/default/acq/po/events.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/po/events.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/acq/po/events.tt2 2010-02-17 22:15:09 UTC (rev 15568)
@@ -0,0 +1,58 @@
+[% WRAPPER default/base.tt2 %]
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/po/events.js"> </script>
+
+<!-- grid -->
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class="oils-header-panel">
+ <div>PO Triggered Events</div>
+ <div>
+ <button dojoType="dijit.form.Button" onClick="eventGrid.cancelSelected()">Cancel Selected</button>
+ <button dojoType="dijit.form.Button" onClick="eventGrid.resetSelected()">Reset Selected</button>
+ </div>
+ </div>
+ <div class="oils-acq-basic-form-div">
+ <span>
+ <label for="state">State</label>
+ <select name="state"
+ dojoType="dijit.form.FilteringSelect"
+ jsId="eventStateSelect"
+ searchAttr="name"
+ labelAttr="name"></select>
+ </span>
+ <span>
+ <label for="orgUnit">Context Org Unit</label>
+ <select name="orgUnit"
+ dojoType="openils.widget.OrgUnitFilteringSelect"
+ jsId="eventContextOrgSelect"
+ searchAttr="shortname"
+ labelAttr="shortname"></select>
+ </span>
+ <span>
+ <label for="startDate">Start Date Range</label>
+ <input name="startDate"
+ type="text"
+ dojoType="dijit.form.DateTextBox"
+ jsId="eventStartDatePicker" />
+ </span>
+ <span>
+ <label for="endDate">End Date Range</label>
+ <input name="endDate"
+ type="text"
+ dojoType="dijit.form.DateTextBox"
+ jsId="eventEndDatePicker" />
+ </span>
+ </div>
+ <table jsId="eventGrid"
+ dojoType="openils.widget.AutoGrid"
+ query="{id: '*'}"
+ fmClass="atev"
+ suppressFields="['update_process','user_data','template_output','error_output','async_output','event_def']"
+ defaultCellWidth="'auto'"
+ editOnEnter="false">
+ </table>
+ </div>
+</div>
+[% END %]
+
+
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2010-02-17 20:51:19 UTC (rev 15567)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2010-02-17 22:15:09 UTC (rev 15568)
@@ -667,6 +667,10 @@
['oncommand'],
function() { open_eg_web_page('acq/po/search', 'menu.cmd_acq_view_po.tab'); }
],
+ 'cmd_acq_view_po_events' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/po/events', 'menu.cmd_acq_view_po_events.tab'); }
+ ],
'cmd_acq_upload' : [
['oncommand'],
function() { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab'); }
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul 2010-02-17 20:51:19 UTC (rev 15567)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul 2010-02-17 22:15:09 UTC (rev 15568)
@@ -79,6 +79,7 @@
<command id="cmd_acq_view_picklist" />
<command id="cmd_acq_upload" />
<command id="cmd_acq_view_po" />
+ <command id="cmd_acq_view_po_events" />
<command id="cmd_acq_bib_search" />
<command id="cmd_acq_li_search" />
<command id="cmd_acq_new_brief_record" />
@@ -256,6 +257,7 @@
<menuitem label="&staff.main.menu.acq.brief_record.label;" accesskey="&staff.main.menu.acq.brief_record.accesskey;" command="cmd_acq_new_brief_record"/>
<menuseparator />
<menuitem label="&staff.main.menu.acq.po.label;" accesskey="&staff.main.menu.acq.po.accesskey;" command="cmd_acq_view_po" />
+ <menuitem label="&staff.main.menu.acq.po_events.label;" accesskey="&staff.main.menu.acq.po_events.accesskey;" command="cmd_acq_view_po_events" />
<menuseparator />
<menuitem label="&staff.main.menu.acq.fund.label;" accesskey="&staff.main.menu.acq.fund.accesskey;" command="cmd_acq_view_fund" />
<menuitem label="&staff.main.menu.acq.funding_source.label;" accesskey="&staff.main.menu.acq.funding_source.accesskey;" command="cmd_acq_view_funding_source" />
Modified: trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2010-02-17 20:51:19 UTC (rev 15567)
+++ trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2010-02-17 22:15:09 UTC (rev 15568)
@@ -226,6 +226,7 @@
menu.cmd_acq_upload.tab=Load Order Record
menu.cmd_acq_new_brief_record.tab=New Brief Record
menu.cmd_acq_view_po.tab=Purchase Orders
+menu.cmd_acq_view_po_events.tab=Purchase Order Events
menu.cmd_acq_view_fund.tab=Funds
menu.cmd_acq_view_funding_source.tab=Funding Sources
menu.cmd_acq_view_provider.tab=Providers
More information about the open-ils-commits
mailing list