← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5180: Applied patch from Jason. Implements financial period types in periodType.js which is used in dat...

 

------------------------------------------------------------
revno: 5180
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-11-17 06:52:26 +0100
message:
  Applied patch from Jason. Implements financial period types in periodType.js which is used in data entry. Nice work.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.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/periodType.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js	2011-09-16 07:53:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js	2011-11-17 05:52:26 +0000
@@ -9,6 +9,9 @@
     periodTypes['Quarterly'] = new QuarterlyPeriodType( dateFormat );
     periodTypes['SixMonthly'] = new SixMonthlyPeriodType( dateFormat );
     periodTypes['Yearly'] = new YearlyPeriodType( dateFormat );
+    periodTypes['FinancialOct'] = new FinancialOctoberPeriodType( dateFormat );
+    periodTypes['FinancialJuly'] = new FinancialJulyPeriodType( dateFormat );
+    periodTypes['FinancialApril'] = new FinancialAprilPeriodType( dateFormat );
 
     this.get = function( key )
     {
@@ -236,3 +239,72 @@
         return periods;
     };
 }
+
+function FinancialOctoberPeriodType( dateFormat )
+{
+    this.generatePeriods = function( offset )
+    {
+        var periods = [];
+        var year = new Date().getFullYear() + offset;
+        var startDate = $.date( year + '-10-01', dateFormat ).adjust( 'Y', -5 );
+
+        for ( var i = 0; i < 11; i++ )
+        {
+            var period = [];
+            period['startDate'] = startDate.format( dateFormat );
+            period['name'] =  monthNames[9] + ' ' +  startDate.date().getFullYear() + '-' + monthNames[8] + ' ' + (startDate.date().getFullYear() +1 );
+            period['id'] = 'FinancialOct_' + period['startDate'];
+            periods[i] = period;
+
+            startDate.adjust( 'Y', +1 );
+        }
+
+        return periods;
+    };
+}
+
+function FinancialJulyPeriodType( dateFormat )
+{
+    this.generatePeriods = function( offset )
+    {
+        var periods = [];
+        var year = new Date().getFullYear() + offset;
+        var startDate = $.date( year + '-07-01', dateFormat ).adjust( 'Y', -5 );
+
+        for ( var i = 0; i < 11; i++ )
+        {
+            var period = [];
+            period['startDate'] = startDate.format( dateFormat );
+            period['name'] =  monthNames[6] + ' ' +  startDate.date().getFullYear() + '-' + monthNames[5] + ' ' + (startDate.date().getFullYear() +1 );
+            period['id'] = 'FinancialJuly_' + period['startDate'];
+            periods[i] = period;
+
+            startDate.adjust( 'Y', +1 );
+        }
+
+        return periods;
+    };
+}
+
+function FinancialAprilPeriodType( dateFormat )
+{
+    this.generatePeriods = function( offset )
+    {
+        var periods = [];
+        var year = new Date().getFullYear() + offset;
+        var startDate = $.date( year + '-04-01', dateFormat ).adjust( 'Y', -5 );
+
+        for ( var i = 0; i < 11; i++ )
+        {
+            var period = [];
+            period['startDate'] = startDate.format( dateFormat );
+            period['name'] =  monthNames[3] + ' ' +  startDate.date().getFullYear() + '-' + monthNames[2] + ' ' + (startDate.date().getFullYear() +1 );
+            period['id'] = 'FinancialApril_' + period['startDate'];
+            periods[i] = period;
+
+            startDate.adjust( 'Y', +1 );
+        }
+
+        return periods;
+    };
+}
\ No newline at end of file