Author: apatel
Date: Sun Nov 1 07:22:50 2009 New Revision: 831648 URL: http://svn.apache.org/viewvc?rev=831648&view=rev Log: Added bulk action for updating invoice status. Also cleaned up javascript code to take advantage of prototype library. Still remains to move javascript in separate file and also css trick to show button disabled when it is. Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml?rev=831648&r1=831647&r2=831648&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Sun Nov 1 07:22:50 2009 @@ -674,4 +674,13 @@ <log level="info" message="Removed invoiceItemAssoc: ${invoiceItemAssoc}"/> </iterate> </simple-method> + + <simple-method method-name="massChangeInvoiceStatus" short-description="Service set status of Invoices in bulk."> + <iterate list="parameters.invoiceIds" entry="invoiceId"> + <set field="setInvoiceStatusMap.invoiceId" from-field="invoiceId"/> + <set field="setInvoiceStatusMap.statusId" from-field="parameters.statusId"/> + <call-service service-name="setInvoiceStatus" in-map-name="setInvoiceStatusMap"/> + <clear-field field="setInvoiceStatusMap"/> + </iterate> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=831648&r1=831647&r2=831648&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Sun Nov 1 07:22:50 2009 @@ -342,4 +342,13 @@ <description>Remove invoiceItemAssoc record on cancel invoice</description> <attribute name="invoiceId" type="String" mode="IN" optional="false"/> </service> + + <service name="massChangeInvoiceStatus" engine="simple" + location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="massChangeInvoiceStatus" auth="true"> + <description>Set status of invoices in bulk.</description> + <attribute name="invoiceIds" type="List" mode="IN" optional="false"/> + <attribute name="statusId" type="String" mode="IN" optional="false"/> + <attribute name="errorMessage" type="String" optional="true" mode="OUT"/> + </service> + </services> Modified: ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml?rev=831648&r1=831647&r2=831648&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml Sun Nov 1 07:22:50 2009 @@ -99,6 +99,11 @@ <security https="true" auth="true"/> <response name="success" type="view" value="FindApPaymentGroups"/> </request-map> + <request-map uri="massChangeInvoiceStatus"> + <security https="true" auth="true"/> + <event type="service" invoke="massChangeInvoiceStatus"/> + <response name="success" type="view" value="FindPurchaseInvoices"/> + </request-map> <!-- ================ Vendor requests ================ --> <request-map uri="findVendors"> Modified: ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl?rev=831648&r1=831647&r2=831648&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl (original) +++ ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl Sun Nov 1 07:22:50 2009 @@ -19,46 +19,34 @@ <script language="JavaScript" type="text/javascript"> <!-- function toggleInvoiceId(master) { - var form = document.listPurchaseInvoices; - var invoices = form.elements.length; - for (var i = 0; i < invoices; i++) { - var element = form.elements[i]; - if (element.name == "invoiceIds") { - element.checked = master.checked; - } - } + var invoices = $('listPurchaseInvoices').getInputs('checkbox','invoiceIds'); + invoices.each(function(invoice){ + invoice.checked = master.checked; + }); getInvoiceRunningTotal(); } function getInvoiceRunningTotal() { - var form = document.listPurchaseInvoices; - var invoices = form.elements.length; - var isSingle = true; - var isAllSelected = true; - for (var i = 0; i < invoices; i++) { - var element = form.elements[i]; - if (element.name == "invoiceIds") { - if (element.checked) { - isSingle = false; - } else { - isAllSelected = false; - } - } - } - if (isAllSelected) { + var invoices = $('listPurchaseInvoices').getInputs('checkbox','invoiceIds'); + if(invoices.pluck('checked').all()) { $('checkAllInvoices').checked = true; } else { $('checkAllInvoices').checked = false; } - if (!isSingle) { + if(invoices.pluck('checked').any()) { new Ajax.Request('getInvoiceRunningTotal', { asynchronous: false, onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); $('showInvoiceRunningTotal').update(data.invoiceRunningTotal); - }, parameters: $('listPurchaseInvoices').serialize(), requestHeaders: {Accept: 'application/json'} + }, + parameters: $('listPurchaseInvoices').serialize(), + requestHeaders: {Accept: 'application/json'} }); - $('submitButton').disabled = false; + if($F('serviceName') != "") { + $('submitButton').disabled = false; + } + } else { $('submitButton').disabled = true; $('showInvoiceRunningTotal').update(""); @@ -66,31 +54,40 @@ } function setServiceName(selection) { - document.listPurchaseInvoices.action = '<@ofbizUrl>'+selection.value+'</@ofbizUrl>'; - showIssueChecks(selection); - $('submitButton').disabled = true; - getInvoiceRunningTotal(); + if ( selection.value == 'massInvoicesToApprove' || selection.value == 'massInvoicesToReceive' || selection.value == 'massInvoicesToReady' || selection.value == 'massInvoicesToPaid' || selection.value == 'massInvoicesToWriteoff' || selection.value == 'massInvoicesToCancel') { + document.listPurchaseInvoices.action = $('invoiceStatusChange').value; + } + else { + document.listPurchaseInvoices.action = selection.value; + } + if (selection.value == 'massInvoicesToApprove') { + $('statusId').value = "INVOICE_APPROVED"; + } else if (selection.value == 'massInvoicesToReceive') { + $('statusId').value = "INVOICE_RECEIVED"; + }else if (selection.value == 'massInvoicesToReady') { + $('statusId').value = "INVOICE_READY"; + }else if (selection.value == 'massInvoicesToPaid') { + $('statusId').value = "INVOICE_PAID"; + }else if (selection.value == 'massInvoicesToWriteoff') { + $('statusId').value = "INVOICE_WRITEOFF"; + }else if (selection.value == 'massInvoicesToCancel') { + $('statusId').value = "INVOICE_CANCELLED"; + } + if ($('processMassCheckRun').selected) { + Effect.BlindDown('issueChecks'); + } else { + Effect.BlindUp('issueChecks'); + } + if($('listPurchaseInvoices').getInputs('checkbox','invoiceIds').pluck('checked').any() && ($F('serviceName') != "")) { + $('submitButton').disabled = false; + } + } function runAction() { - var form = document.listPurchaseInvoices; - var invoices = form.elements.length; - for (var i = 0; i < invoices; i++) { - var element = form.elements[i]; - if (element.name == "invoiceIds") { - element.disabled = false; - } - } - form.submit(); + $('listPurchaseInvoices').submit(); } -function showIssueChecks(selection) { - if (selection.value == 'processMassCheckRun') { - Effect.BlindDown('issueChecks',{duration: 0.0}); - } else { - Effect.BlindUp('issueChecks',{duration: 0.0}); - } -} --> </script> @@ -103,14 +100,21 @@ <div align="right"> <!-- May add some more options in future like cancel selected invoices--> <select name="serviceName" id="serviceName" onchange="javascript:setServiceName(this);"> - <option value="">${uiLabelMap.AccountingSelectAction}</options> - <option value="processMassCheckRun">${uiLabelMap.AccountingIssueCheck}</option> + <option value="">${uiLabelMap.AccountingSelectAction}</option> + <option value="<@ofbizUrl>processMassCheckRun</@ofbizUrl>" id="processMassCheckRun">${uiLabelMap.AccountingIssueCheck}</option> + <option value="massInvoicesToApprove">${uiLabelMap.AccountingInvoiceStatusToApproved}</option> + <option value="massInvoicesToReceive">${uiLabelMap.AccountingInvoiceStatusToReceived}</option> + <option value="massInvoicesToReady">${uiLabelMap.AccountingInvoiceStatusToReady}</option> + <option value="massInvoicesToPaid">${uiLabelMap.AccountingInvoiceStatusToPaid}</option> + <option value="massInvoicesToWriteoff">${uiLabelMap.AccountingInvoiceStatusToWriteoff}</option> + <option value="massInvoicesToCancel">${uiLabelMap.AccountingInvoiceStatusToCancelled}</option> </select> <input id="submitButton" type="button" onclick="javascript:runAction();" value="${uiLabelMap.OrderRunAction}" disabled/> </div> + <input type="hidden" name="invoiceStatusChange" id="invoiceStatusChange" value="<@ofbizUrl>massChangeInvoiceStatus</@ofbizUrl>"/> <input type="hidden" name="organizationPartyId" value="${organizationPartyId}"/> <input type="hidden" name="partyIdFrom" value="${parameters.partyIdFrom?if_exists}"/> - <input type="hidden" name="statusId" value="${parameters.statusId?if_exists}"/> + <input type="hidden" name="statusId" id="statusId" value="${parameters.statusId?if_exists}"/> <input type="hidden" name="fromInvoiceDate" value="${parameters.fromInvoiceDate?if_exists}"/> <input type="hidden" name="thruInvoiceDate" value="${parameters.thruInvoiceDate?if_exists}"/> <input type="hidden" name="fromDueDate" value="${parameters.fromDueDate?if_exists}"/> @@ -165,5 +169,5 @@ </table> </form> <#else> - <td colspan='4'><h3>${uiLabelMap.AccountingNoInvoicesFound}</h3></td> + <h3>${uiLabelMap.AccountingNoInvoicesFound}</h3> </#if> |
Free forum by Nabble | Edit this page |