← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15023: six-monthly js generator

 

------------------------------------------------------------
revno: 15023
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 20:30:34 +0545
message:
  six-monthly js generator
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-04-27 14:33:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-04-27 14:45:34 +0000
@@ -74,7 +74,7 @@
     period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
     period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
     period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
-    period['id'] = 'Monthly_' + period['startDate'];
+    period['id'] = 'BiMonthly_' + period['startDate'];
     period['iso'] = startDate.formatDate("yyyymm") + 'B';
 
     periods.push(period);
@@ -89,7 +89,6 @@
   var periods = [];
 
   for( var month = 1, idx = 1; month <= cal.monthsInYear(year); month += 3, idx++ ) {
-    log('month: ' + month);
     var startDate = cal.newDate(year, month, 1);
     var endDate = cal.newDate(startDate).set(month + 2, 'm');
     endDate.set(endDate.daysInMonth(month + 2), 'd');
@@ -102,7 +101,7 @@
     period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
     period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
     period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
-    period['id'] = 'Monthly_' + period['startDate'];
+    period['id'] = 'Quarterly_' + period['startDate'];
     period['iso'] = startDate.formatDate("yyyy") + 'Q' + idx;
 
     periods.push(period);
@@ -110,3 +109,37 @@
 
   return periods;
 };
+
+dhis2.period.generateSixMonthlyPeriods = function( cal, offset ) {
+  var year = cal.today().year() - offset;
+
+  var periods = [];
+
+  var startDate = cal.newDate(year, 1, 1);
+  var endDate = cal.newDate(startDate).set(6, 'm');
+  endDate.set(endDate.daysInMonth(6), 'd');
+
+  var period = {};
+  period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+  period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
+  period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
+  period['id'] = 'SixMonthly_' + period['startDate'];
+  period['iso'] = startDate.formatDate("yyyy") + 'S' + 1;
+
+  periods.push(period);
+
+  startDate = cal.newDate(year, 7, 1);
+  endDate = cal.newDate(startDate).set(cal.monthsInYear(year), 'm');
+  endDate.set(endDate.daysInMonth(12), 'd');
+
+  period = {};
+  period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+  period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
+  period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
+  period['id'] = 'SixMonthly_' + period['startDate'];
+  period['iso'] = startDate.formatDate("yyyy") + 'S' + 2;
+
+  periods.push(period);
+
+  return periods;
+};