← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15020: js generator for bi-monthly periods

 

------------------------------------------------------------
revno: 15020
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 20:07:44 +0545
message:
  js generator for bi-monthly periods
modified:
  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/main.vm


--
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:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-04-27 14:22:44 +0000
@@ -39,6 +39,10 @@
     var startDate = cal.newDate(year, month, 1);
     var endDate = cal.newDate(startDate).set(startDate.daysInMonth(month), 'd');
 
+    if( startDate.year() != endDate.year() ) {
+      break;
+    }
+
     var period = {};
     period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
     period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
@@ -51,3 +55,30 @@
 
   return periods;
 };
+
+dhis2.period.generateBiMonthlyPeriods = function( cal, offset ) {
+  var year = cal.today().year() - offset;
+
+  var periods = [];
+
+  for( var month = 1; month <= cal.monthsInYear(year); month += 2 ) {
+    var startDate = cal.newDate(year, month, 1);
+    var endDate = cal.newDate(startDate).set(month + 1, 'm');
+    endDate.set(endDate.daysInMonth(month + 1), 'd');
+
+    if( startDate.year() != endDate.year() ) {
+      break;
+    }
+
+    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'] = 'Monthly_' + period['startDate'];
+    period['iso'] = startDate.formatDate("yyyymm") + 'B';
+
+    periods.push(period);
+  }
+
+  return periods;
+};

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2014-04-07 02:08:51 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2014-04-27 14:22:44 +0000
@@ -1,8 +1,5 @@
 <!DOCTYPE HTML>
-<!--[if IE 7]><html #if( $manifest ) manifest="$manifest" #end class="ie7"><![endif]-->
-<!--[if IE 8]><html #if( $manifest ) manifest="$manifest" #end class="ie8"><![endif]-->
-<!--[if IE 9]><html #if( $manifest ) manifest="$manifest" #end class="ie9"><![endif]-->
-<![if !IE]><html #if( $manifest ) manifest="$manifest" #end><![endif]>
+<html>
   <head>
     <title>$encoder.htmlEncode( $applicationTitle )</title>
     <meta name="description" content="DHIS 2">
@@ -54,6 +51,14 @@
     <script type="text/javascript" src="../dhis-web-commons/javascripts/validationRules.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.array.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.select.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.plus.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.coptic.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.ethiopian.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.islamic.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.julian.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.nepali.min.js?_rev=$!{buildRevision}"></script>
+    <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.period.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.selected.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.availability.js?_rev=$!{buildRevision}"></script>