changed PO create button to only create POs on selected titles
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Jun 2008 02:58:50 +0000 (02:58 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Jun 2008 02:58:50 +0000 (02:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9911 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/li_search.html

index 1393960..20238aa 100644 (file)
@@ -80,25 +80,40 @@ function viewList() {
 function createPOFromLineitems() {
     var po = new acqpo()
     po.provider(newPOProviderSelector.getValue());
+
+    // find the selected lineitems
+    var selected = liGrid.selection.getSelected();
+    var selList = [];
+    for(var idx = 0; idx < selected.length; idx++) {
+        var rowIdx = selected[idx];
+        var id = liGrid.model.getRow(rowIdx).id;
+        for(var i = 0; i < lineitems.length; i++) {
+            if(lineitems[i].id() == id)
+                selList.push(lineitems[i]);
+        }
+    }
+
     openils.acq.PO.create(po, 
         function(poId) {
-            updateLiList(poId);
+            updateLiList(poId, selList);
         }
     );
 }
 
-function updateLiList(poId) {
-    _updateLiList(poId, 0);
+function updateLiList(poId, selList) {
+    _updateLiList(poId, selList, 0);
 }
 
-function _updateLiList(poId, idx) {
-    if(idx >= lineitems.length)
+function _updateLiList(poId, selList, idx) {
+    if(idx >= selList.length)
         return location.href = 'view/' + poId;
-    var li = lineitems[idx];
+    var li = selList[idx];
+    if(li.purchase_order())
+        return _updateLiList(poId, selList, ++idx);
     li.purchase_order(poId);
     new openils.acq.Lineitems({lineitem:li}).update(
         function(stat) {
-            _updateLiList(poId, ++idx);
+            _updateLiList(poId, selList, ++idx);
         }
     );
 }
index e5ca85a..340a303 100644 (file)
@@ -50,7 +50,7 @@
     <script>dojo.style('searchProgress', 'visibility', 'hidden');</script>
 
     <div dojoType="dijit.form.DropDownButton" id='oils-acq-li-search-po-create'>
-        <span>${('Create PO')}</span>
+        <span>${('Create PO From Selected Titles')}</span>
         <div dojoType="dijit.TooltipDialog" execute="createPOFromLineitems(arguments[0]);">
             <script type='dojo/connect' event='onOpen'>
                 buildProviderSelect(newPOProviderSelector,