[Suiviobsmer-commits] r715 - in trunk/wao-ui/src/main: java/fr/ifremer/wao/ui/pages webapp
Author: bleny Date: 2010-10-27 09:57:27 +0000 (Wed, 27 Oct 2010) New Revision: 715 Log: add totals by column in sampling plan Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java trunk/wao-ui/src/main/webapp/SamplingPlan.tml Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-10-27 09:12:20 UTC (rev 714) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-10-27 09:57:27 UTC (rev 715) @@ -647,19 +647,19 @@ } if (!edited && !periodChanged) { - // No company change possible when sampleRow has real tide time - if (!getSampleRow().hasSampleMonthRealTideTime()) { - // Save company - Company company = getCompanySelectModel().findObject(companyId); - getSampleRow().setCompany(company); - } + // No company change possible when sampleRow has real tide time + if (!getSampleRow().hasSampleMonthRealTideTime()) { + // Save company + Company company = getCompanySelectModel().findObject(companyId); + getSampleRow().setCompany(company); + } - // Save sampleMonths - getSampleRow().setSampleMonth(getSampleMonths()); + // Save sampleMonths + getSampleRow().setSampleMonth(getSampleMonths()); - serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog()); + serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog()); - return SamplingPlan.class; + return SamplingPlan.class; } else { // Reinitialize professionId for select to avoid selection from existing Profession professionId = null; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-10-27 09:12:20 UTC (rev 714) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-10-27 09:57:27 UTC (rev 715) @@ -60,6 +60,7 @@ import java.text.DateFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -400,6 +401,59 @@ return NumberFormat.getNumberInstance(); } + private List<String> totals; + + @Property + private String total; + + public List<String> getTotals() { + + List<String> totals = new ArrayList<String>(); + + // high totals are the total... of the totals, it will appear + // in the bottom right, as the last element of the "totals" line + Integer highTotalExpected = 0; + Integer highTotalReal = 0; + + for (Date month : getMonths()) { + this.month = month; + + Integer totalExpected = 0, totalReal = 0; + + for (SampleRow row : getData()) { + this.row = row; + + + Integer expected = getNbTidesExpected(), real = getNbTidesReal(); + if (logger.isDebugEnabled()) { + logger.debug(String.format("expected = %s, real = %s", expected, real)); + } + + if (expected != null) { + totalExpected += expected; + } + if (real != null) { + totalReal += real; + } + } + + String total = totalExpected.toString(); + if (canDisplayTidesReal() && totalReal != 0) { + total += " (" + totalReal + ")"; + } + + totals.add(total); + + highTotalExpected += totalExpected; + highTotalReal += totalReal; + + } + + totals.add(highTotalExpected + " (" + highTotalReal + ")"); + + return totals; + } + /** ------------------------- HTML & STYLE ----------------------------- **/ @Property @@ -407,7 +461,7 @@ public String getRowComment() { String comment = row.getComment(); - // Problem whith " in chenilleKit ToolTip component + // Problem with " in chenilleKit ToolTip component comment = comment.replace("\n", "<br />"); return comment; } Modified: trunk/wao-ui/src/main/webapp/SamplingPlan.tml =================================================================== --- trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2010-10-27 09:12:20 UTC (rev 714) +++ trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2010-10-27 09:57:27 UTC (rev 715) @@ -296,6 +296,20 @@ </td> </tr> </t:loop> + <tr> + <td colspan="${nbColumnsTotal}" class="facade"> + Totaux + </td> + </tr> + <tr> + <td colspan="${nbColumnsForProfession}" /> + <t:loop source="totals" value="total"> + <td class="width50 acenter ${monthCurrentClass}"> + ${total} + </td> + </t:loop> + <td colspan="${nbColumnsForOther}" /> + </tr> </tbody> </table> </t:zone>
participants (1)
-
bleny@users.labs.libre-entreprise.org