Skip to content

Commit

Permalink
Added 'Year' as an additional reporting range option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Omondi authored and Ken Omondi committed Oct 28, 2016
1 parent d649ffe commit 6d3d100
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class ReportPeriodFragmentController {

public void controller(@FragmentParam("pastMonths") int pastMonths,
@FragmentParam("pastYears") int pastYears,
FragmentModel model,
@SpringBean KenyaUiUtils kenyaui) {

Expand All @@ -48,7 +49,23 @@ public void controller(@FragmentParam("pastMonths") int pastMonths,
"range", kenyaui.formatDateParam(start) + "|" + kenyaui.formatDateParam(end)
));
}

model.addAttribute("months", months);

List<SimpleObject> years = new ArrayList<SimpleObject>();
labelFormat = new SimpleDateFormat("yyyy");

start = DateUtil.getStartOfPeriod(new Date(), 4);
for (int i = 0; i < pastYears; ++i) {
Date end = DateUtil.getEndOfPeriod(start, 4);

years.add(SimpleObject.create(
"label", labelFormat.format(start),
"range", kenyaui.formatDateParam(start) + "|" + kenyaui.formatDateParam(end)
));
start = DateUtil.getStartOfMonth(start, -1);
start = DateUtil.getStartOfPeriod(start, 4);

}
model.addAttribute("years", years);
}
}

0 comments on commit 6d3d100

Please sign in to comment.