added a marc order record upload form for creating picklists and/or purchase orders...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Mar 2009 20:50:01 +0000 (20:50 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Mar 2009 20:50:01 +0000 (20:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12658 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/skin/default.css
Open-ILS/web/js/ui/default/acq/picklist/upload.js [new file with mode: 0644]
Open-ILS/web/templates/default/acq/picklist/upload.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/menu.tt2

index bb7f771..e7fceb5 100644 (file)
@@ -50,6 +50,9 @@ table { border-collapse: collapse; }
 
 .label { margin: 1px; }
 
+.oils-generic-table th { padding:5px; font-weight: bold; }
+.oils-generic-table td { padding:5px; }
+
 
 /* local dojo style enhancements ----------------------------------- */
 /*
diff --git a/Open-ILS/web/js/ui/default/acq/picklist/upload.js b/Open-ILS/web/js/ui/default/acq/picklist/upload.js
new file mode 100644 (file)
index 0000000..d272854
--- /dev/null
@@ -0,0 +1,118 @@
+dojo.require('dojo.data.ItemFileReadStore');
+dojo.require('dijit.ProgressBar');
+dojo.require('dijit.form.CheckBox');
+dojo.require('dijit.form.TextBox');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.form.ComboBox');
+dojo.require('dijit.form.Button');
+dojo.require("dojo.io.iframe");
+dojo.require('openils.User');
+dojo.require('openils.widget.AutoFieldWidget');
+dojo.require('openils.acq.Picklist');
+
+var VANDELAY_URL = '/vandelay-upload';
+var providerWidget;
+var orderAgencyWidget;
+
+function init() {
+    dojo.byId('acq-pl-upload-ses').value = openils.User.authtoken;
+
+    new openils.widget.AutoFieldWidget({
+        fmClass : 'acqpo',
+        fmField : 'provider',
+        limitPerms : ['CREATE_PICKLIST'],
+        parentNode : dojo.byId('acq-pl-upload-provider'),
+    }).build(
+        function(w) { providerWidget = w }
+    );
+
+    new openils.widget.AutoFieldWidget({
+        fmClass : 'acqpo',
+        fmField : 'ordering_agency',
+        limitPerms : ['CREATE_PURCHASE_ORDER'],
+        parentNode : dojo.byId('acq-pl-upload-agency'),
+    }).build(
+        function(w) { orderAgencyWidget = w }
+    );
+
+    fieldmapper.standardRequest(
+        ['open-ils.acq', 'open-ils.acq.picklist.user.retrieve.atomic'],
+        {   async: true,
+            params: [openils.User.authtoken], 
+            oncomplete : function(r) {
+                var list = openils.Util.readResponse(r);
+                acqPlUploadPlSelector.store = 
+                    new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(list)});
+            }
+        }
+    );
+}
+
+function acqUploadRecords() {
+    openils.Util.show('acq-pl-upload-progress');
+    var picklist = acqPlUploadPlSelector.attr('value');
+    if(picklist) {
+        // ComboBox value is the display string.  find the actual picklist
+        // and create a new one if necessary
+        acqPlUploadPlSelector.store.fetch({
+            query : {name:picklist}, 
+            onComplete : function(items) {
+                if(items.length == 0) {
+                    // create a new picklist for these items
+                    openils.acq.Picklist.create(
+                        {name:picklist, org_unit: orderAgencyWidget.attr('value')},
+                        function(plId) { acqSendUploadForm({picklist:plId}) }
+                    );
+                } else {
+                    acqSendUploadForm({picklist:items[0].id});
+                }
+            }
+        });
+    } else {
+        acqSendUploadForm({});
+    }
+}
+
+function acqSendUploadForm(args) {
+    dojo.io.iframe.send({
+        url: VANDELAY_URL,
+        method: "post",
+        handleAs: "html",
+        form: dojo.byId('acq-pl-upload-form'),
+        content : {
+            picklist : args.picklist,
+            provider : providerWidget.attr('value'),
+            ordering_agency : orderAgencyWidget.attr('value')
+        },
+        handle: function(data, ioArgs){
+            acqHandlePostUpload(data.documentElement.textContent);
+        }
+    });
+}
+
+
+function acqHandlePostUpload(key) {
+    openils.Util.hide('acq-pl-upload-progress');
+    fieldmapper.standardRequest(
+        ['open-ils.acq', 'open-ils.acq.process_upload_records'],
+        {   async: true,
+            params: [openils.User.authtoken, key],
+            onresponse : function(r) {
+                var resp = openils.Util.readResponse(r);
+                if(resp.complete) {
+                    if(resp.picklist) {
+                        location.href = location.href + '/../view/' + resp.picklist.id();
+                    } else {
+                        location.href = location.href + '/../../po/view/' + resp.purchase_order.id;
+                    }
+                } else {
+                    dojo.byId('acq-pl-upload-count').innerHTML = resp.count;
+                }
+            },
+        }
+    );
+}
+
+
+openils.Util.addOnLoad(init);
+
diff --git a/Open-ILS/web/templates/default/acq/picklist/upload.tt2 b/Open-ILS/web/templates/default/acq/picklist/upload.tt2
new file mode 100644 (file)
index 0000000..a354469
--- /dev/null
@@ -0,0 +1,51 @@
+[% WRAPPER 'default/base.tt2' %]
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/picklist/upload.js'> </script>
+
+<h1>Upload</h1><br/>
+<form id="acq-pl-upload-form" enctype="multipart/form-data">
+    <input type='hidden' name='ses' id='acq-pl-upload-ses'/>
+    <table class='oils-generic-table'>
+        <tbody>
+            <tr>
+                <td>Create Purchase Order</td>
+                <td>
+                    <input dojoType='dijit.form.CheckBox' jsId='acqPlUploadToPo' name='create_po'></input>
+                </td>
+            </tr>
+            <tr>
+                <td>Provider</td>
+                <td><div id='acq-pl-upload-provider'></div></td>
+            </tr>
+            <tr id='acq-pl-upload-agency-row'>
+                <td>Context Org Unit</td>
+                <td><div id='acq-pl-upload-agency'></div></td>
+            </tr>
+            <tr id='acq-pl-upload-picklist'>
+                <td>Add to Picklist</td>
+                <td>
+                    <select jsId='acqPlUploadPlSelector' dojoType='dijit.form.ComboBox'></select>
+                </td>
+            </tr>
+            <tr>
+                <td>Records File</td>
+                <td><input size='36' type="file" name="marc_upload"></input></td>
+            </tr>
+            <tr>
+                <td align='center' colspan='2'>
+                    <button dojoType="dijit.form.Button" onClick="acqUploadRecords()">Upload</button>
+                </td>
+            </tr>
+        </tbody>
+    </table>
+
+    <br/>
+    <br/>
+    <div id="acq-pl-upload-progress" class='hidden'>
+        <div>
+            <span>Processing...</span>
+            <span id='acq-pl-upload-count'></span>
+        </div>
+        <div dojoType="dijit.ProgressBar" style="width:300px" indeterminate="true"></div>
+    </div>
+</form>
+[% END %]
index 8aa39c9..8282fe1 100644 (file)
                             onClick="location.href = '[% ctx.base_uri %]/acq/picklist/bib_search';">
                             Title Search
                         </div>
+                        <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
+                            onClick="location.href = '[% ctx.base_uri %]/acq/picklist/upload';">
+                            Load Records
+                        </div>
                     </div>
                 </div>