acq invoice : added save-and-clear button; minor code refactor
authorBill Erickson <berick@esilibrary.com>
Wed, 25 Jul 2012 15:39:39 +0000 (11:39 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 25 Jul 2012 15:39:39 +0000 (11:39 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/acq/invoice/view.tt2
Open-ILS/web/js/ui/default/acq/invoice/view.js

index 8d6aa72..382f572 100644 (file)
                         <tr>
                             <td colspan='3' style='text-align:right;'>
                                 <button jsId='invoiceSaveButton' class='hide-complete'
-                                    dojoType='dijit.form.Button' onclick='saveChanges();'>Save</button>
+                                    dojoType='dijit.form.Button' onclick='saveChanges();'>[% l('Save') %]</button>
+                                <button jsId='invoiceSaveButton' class='hide-complete'
+                                    dojoType='dijit.form.Button' onclick='saveChanges({clear:true});'>[% l('Save &amp; Clear') %]</button>
                                 <button jsId='invoiceProrateButton' class='hide-complete'
-                                    dojoType='dijit.form.Button' onclick='saveChanges(true);'>Save &amp; Prorate</button>
+                                    dojoType='dijit.form.Button' onclick='saveChanges({prorate:true});'>[% l('Prorate') %]</button>
                                 <button jsId='invoiceCloseButton' class='hide-complete'
-                                    dojoType='dijit.form.Button' onclick='saveChanges(false, true);'>Save &amp; Close</button>
+                                    dojoType='dijit.form.Button' onclick='saveChanges({close:true});'>[% l('Close') %]</button>
                                 <span class='hidden' id='acq-invoice-reopen-button-wrapper'>
                                     <button jsId='invoiceReopenButton' 
-                                        dojoType='dijit.form.Button' onclick='saveChanges(false, false, true);'>Reopen Invoice</button>
+                                        dojoType='dijit.form.Button' onclick='saveChanges({reopen:true});'>[% l('Reopen') %]</button>
                                 </span>
                             </td>
                             <td class='acq-invoice-center-col'><div jsId='totalInvoicedBox' dojoType='dijit.form.CurrencyTextBox' style='width:9em;'></div></td>
index 6fe4b0e..d754c06 100644 (file)
@@ -794,12 +794,9 @@ function liMarcAttr(lineitem, name) {
     return (attr) ? attr.attr_value() : '';
 }
 
-function saveChanges(doProrate, doClose, doReopen) {
-    createExtraCopies(
-        function() {
-            saveChangesPartTwo(doProrate, doClose, doReopen);
-        }
-    );
+function saveChanges(args) {
+    args = args || {};
+    createExtraCopies(function() { saveChangesPartTwo(args); });
 }
 
 // Define a helper function to 'unflesh' sub-objects from an fmclass object.
@@ -814,10 +811,10 @@ function unflesh() {
     });
 }
 
-function saveChangesPartTwo(doProrate, doClose, doReopen) {
-    
+function saveChangesPartTwo(args) {
+    args = args || {};
 
-    if(doReopen) {
+    if(args.reopen) {
         invoice.complete('f');
 
     } else {
@@ -836,7 +833,7 @@ function saveChangesPartTwo(doProrate, doClose, doReopen) {
             return;
         }
 
-        if(doClose)
+        if(args.close)
             invoice.complete('t');
 
 
@@ -886,9 +883,13 @@ function saveChangesPartTwo(doProrate, doClose, doReopen) {
                 progressDialog.hide();
                 var invoice = openils.Util.readResponse(r);
                 if(invoice) {
-                    if(doProrate)
+                    if(args.prorate)
                         return prorateInvoice(invoice);
-                    location.href = oilsBasePath + '/acq/invoice/view/' + invoice.id();
+                    if (args.clear) {
+                        location.href = oilsBasePath + '/acq/invoice/view?create=1';
+                    } else {
+                        location.href = oilsBasePath + '/acq/invoice/view/' + invoice.id();
+                    }
                 }
             }
         }