Author: jacopoc
Date: Sun Jun 1 00:25:32 2008 New Revision: 662159 URL: http://svn.apache.org/viewvc?rev=662159&view=rev Log: Converted another bsh script to groovy: there are a lot more improvements that can be done on this (the original bsh script was not very good actually), but for now this is hopefully enough. Added: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy - copied, changed from r662153, ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/month.bsh Removed: ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/month.bsh Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml Copied: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy (from r662153, ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/month.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy?p2=ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy&p1=ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/month.bsh&r1=662153&r2=662159&rev=662159&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/month.bsh (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy Sun Jun 1 00:25:32 2008 @@ -27,25 +27,22 @@ import java.util.Calendar; import java.text.NumberFormat; -delegator = request.getAttribute("delegator"); -dispatcher = request.getAttribute("dispatcher"); +fixedAssetId = parameters.fixedAssetId; +fixedAsset = delegator.findByPrimaryKeyCache("FixedAsset", [fixedAssetId: fixedAssetId]); -fixedAssetId = request.getParameter("fixedAssetId"); -fixedAsset = delegator.findByPrimaryKeyCache("FixedAsset", UtilMisc.toMap("fixedAssetId",fixedAssetId)); - -String startMonth = request.getParameter("month"); //optional command to change the month +String startMonth = parameters.month; //optional command to change the month Timestamp currentMonth = session.getAttribute("currentMonth"); // the month displayed the last time. Timestamp now = null; -if (startMonth == null || currentMonth == null) // a fresh start +if (!startMonth || !currentMonth) // a fresh start now = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()); -else if (startMonth.equals("1") && currentMonth != null) - now = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(currentMonth, 35)); -else if (startMonth.equals("-1") && currentMonth != null) +else if (startMonth.equals("1") && currentMonth) + now = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(currentMonth, 35)); +else if (startMonth.equals("-1") && currentMonth) now = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(currentMonth, -15)); -else if (startMonth.equals("3") && currentMonth != null) +else if (startMonth.equals("3") && currentMonth) now = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(currentMonth, 100)); -else if (startMonth.equals("-3") && currentMonth != null) +else if (startMonth.equals("-3") && currentMonth) now = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(currentMonth, -75)); else now = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()); @@ -84,12 +81,12 @@ if (excDayRecord.get("exceptionCapacity") != null && excDayRecord.getDouble("exceptionCapacity").doubleValue() != 0) available = excDayRecord.getString("exceptionCapacity"); extraText = "Avail.: " + available + "<br/>Allocated: " + excDayRecord.getString("usedCapacity"); - if (dbInt.hasNext()) { + if (dbInt.hasNext()) { excDayRecord = dbInt.next(); dbValid = true; - } - else + } else { dbValid = false; + } } days.put(UtilDateTime.days[day-1], UtilDateTime.getDayStart(currentWeek,day).toString().substring(8,10)); days.put(UtilDateTime.days[day-1]+"Data", extraText); @@ -99,9 +96,9 @@ currentWeek = UtilDateTime.getWeekStart(currentWeek,7); } int monthNr = NumberFormat.getNumberInstance().parse(now.toString().substring(5,7)).intValue(); -context.put("month",UtilDateTime.months[monthNr-1]); -context.put("year",now.toString().substring(0,4)); -context.put("weeks",weeks); -context.put("now",now); -context.put("nextMonth",nextMonth); +context.month = UtilDateTime.months[monthNr-1]; +context.year = now.toString().substring(0,4); +context.weeks = weeks; +context.now = now; +context.nextMonth = nextMonth; session.setAttribute("currentMonth",currentMonth); Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml?rev=662159&r1=662158&r2=662159&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml (original) +++ ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml Sun Jun 1 00:25:32 2008 @@ -186,7 +186,7 @@ <set field="labelTitleProperty" value="AccountingFixedAssetCalendar"/> <set field="fixedAssetId" from-field="parameters.fixedAssetId"/> <entity-one entity-name="FixedAsset" value-name="fixedAsset"/> - <script location="component://accounting/webapp/accounting/fixedasset/month.bsh"/> + <script location="component://accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy"/> </actions> <widgets> <decorator-screen name="CommonFixedAssetDecorator" location="${parameters.fixedAssetDecoratorLocation}"> @@ -325,8 +325,8 @@ <widgets> <decorator-screen name="CommonFixedAssetDecorator" location="${parameters.fixedAssetDecoratorLocation}"> <decorator-section name="body"> - <container style="button-bar"><link target="EditFixedAssetMaint?fixedAssetId=${fixedAssetId}" text="${uiLabelMap.AccountingNewFixedAssetMaint}" style="buttontext"/></container> - <include-form name="ListFixedAssetMaints" location="component://accounting/webapp/accounting/fixedasset/FixedAssetForms.xml"/> + <container style="button-bar"><link target="EditFixedAssetMaint?fixedAssetId=${fixedAssetId}" text="${uiLabelMap.AccountingNewFixedAssetMaint}" style="buttontext"/></container> + <include-form name="ListFixedAssetMaints" location="component://accounting/webapp/accounting/fixedasset/FixedAssetForms.xml"/> </decorator-section> </decorator-screen> </widgets> |
Free forum by Nabble | Edit this page |