← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13956: Add SixMonthlyAprilPeriodType

 

------------------------------------------------------------
revno: 13956
committer: Jim Grace <jimgrace@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-02-08 13:09:18 -0500
message:
  Add SixMonthlyAprilPeriodType
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml
  dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties
  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/periodTypeNoDep.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/i18n.json
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm
  dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.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-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2013-11-07 20:45:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2014-02-08 18:09:18 +0000
@@ -66,6 +66,7 @@
             add( new BiMonthlyPeriodType() );
             add( new QuarterlyPeriodType() );
             add( new SixMonthlyPeriodType() );
+            add( new SixMonthlyAprilPeriodType() );
             add( new YearlyPeriodType() );
             add( new FinancialAprilPeriodType() );
             add( new FinancialJulyPeriodType() );
@@ -302,6 +303,10 @@
         {
             return new SixMonthlyPeriodType();
         }
+        if ( isoPeriod.matches( "\\b\\d{4}AprilS\\d\\b" ) )
+        {
+            return new SixMonthlyAprilPeriodType();
+        }
         if ( isoPeriod.matches( "\\b\\d{6}B\\b" ) )
         {
             return new BiMonthlyPeriodType();

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java	2014-02-08 18:09:18 +0000
@@ -0,0 +1,170 @@
+package org.hisp.dhis.period;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Abstract class for SixMonthly period types, including those starting
+ * at the beginning of the calendar year and those starting at the beginning
+ * of other months.
+ *
+ * @author Jim Grace
+ */
+
+public abstract class SixMonthlyAbstractPeriodType
+        extends CalendarPeriodType
+{
+    private static final long serialVersionUID = -7135018015977806913L;
+
+    public static final int FREQUENCY_ORDER = 182;
+
+    // -------------------------------------------------------------------------
+    // Abstract methods
+    // -------------------------------------------------------------------------
+
+    protected abstract int getBaseMonth();
+
+    // -------------------------------------------------------------------------
+    // PeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public Period createPeriod()
+    {
+        return createPeriod( createCalendarInstance() );
+    }
+
+    @Override
+    public Period createPeriod( Date date )
+    {
+        return createPeriod( createCalendarInstance( date ) );
+    }
+
+    @Override
+    public Period createPeriod( Calendar cal )
+    {
+        int yearMonth = cal.get( Calendar.MONTH ) + 12 * cal.get( Calendar.YEAR ) - getBaseMonth();
+
+        cal.set( Calendar.YEAR, yearMonth / 12 );
+        cal.set( Calendar.MONTH, ( ( ( yearMonth % 12 ) / 6 ) * 6 ) + getBaseMonth() );
+        cal.set( Calendar.DAY_OF_MONTH, 1 );
+
+        Date startDate = cal.getTime();
+
+        cal.add( Calendar.MONTH, 5 );
+        cal.set( Calendar.DAY_OF_MONTH, cal.getActualMaximum( Calendar.DAY_OF_MONTH ) );
+
+        return new Period( this, startDate, cal.getTime() );
+    }
+
+    @Override
+    public int getFrequencyOrder()
+    {
+        return FREQUENCY_ORDER;
+    }
+
+    // -------------------------------------------------------------------------
+    // CalendarPeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public Period getNextPeriod( Period period )
+    {
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+        cal.add( Calendar.MONTH, 6 );
+        return createPeriod( cal );
+    }
+
+    @Override
+    public Period getPreviousPeriod( Period period )
+    {
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+        cal.add( Calendar.MONTH, -6 );
+        return createPeriod( cal );
+    }
+
+    /**
+     * Generates six-monthly Periods for the whole year in which the given
+     * Period's startDate exists.
+     */
+    @Override
+    public List<Period> generatePeriods( Date date )
+    {
+        ArrayList<Period> periods = new ArrayList<Period>();
+
+        Period period = createPeriod ( date );
+
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+
+        if ( cal.get( Calendar.MONTH ) == getBaseMonth() )
+        {
+            periods.add( period );
+            periods.add( getNextPeriod( period ) );
+        }
+        else
+        {
+            periods.add( getPreviousPeriod( period ) );
+            periods.add( period );
+        }
+        return periods;
+    }
+
+    /**
+     * Generates the last 2 six-months where the last one is the six-month
+     * which the given date is inside.
+     */
+    @Override
+    public List<Period> generateRollingPeriods( Date date )
+    {
+        Period period = createPeriod( date );
+
+        ArrayList<Period> periods = new ArrayList<Period>();
+
+        periods.add( getPreviousPeriod( period ) );
+        periods.add( period );
+
+        return periods;
+    }
+
+    @Override
+    public Date getRewindedDate( Date date, Integer rewindedPeriods )
+    {
+        date = date != null ? date : new Date();
+        rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
+
+        Calendar cal = createCalendarInstance( date );
+        cal.add( Calendar.MONTH, (rewindedPeriods * -6) );
+
+        return cal.getTime();
+    }
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java	2014-02-08 18:09:18 +0000
@@ -0,0 +1,141 @@
+package org.hisp.dhis.period;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * PeriodType for six-monthly Periods aligned to a financial year starting in
+ * April or October. A valid April six-monthly Period has startDate set to
+ * either April 1st or October 1st, and endDate set to the last day of the
+ * fifth month after the startDate.
+ *
+ * @author Torgeir Lorange Ostby
+ * @author Jim Grace
+ */
+
+public class SixMonthlyAprilPeriodType
+        extends SixMonthlyAbstractPeriodType
+{
+    private static final long serialVersionUID = -2770872821413382644L;
+
+    private static final String ISO_FORMAT = "yyyyAprilSn";
+
+    private static final int BASE_MONTH = Calendar.APRIL;
+
+    private static final String BASE_MONTH_NAME = "April";
+
+    /**
+     * The name of the SixMonthlyPeriodType, which is "SixMonthly".
+     */
+    public static final String NAME = "SixMonthlyApril";
+
+    // -------------------------------------------------------------------------
+    // PeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String getName()
+    {
+        return NAME;
+    }
+
+    @Override
+    public int getBaseMonth()
+    {
+        return BASE_MONTH;
+    }
+
+    // -------------------------------------------------------------------------
+    // CalendarPeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String getIsoDate( Period period )
+    {
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+        int year = cal.get( Calendar.YEAR );
+        int month = cal.get( Calendar.MONTH );
+
+        return year + BASE_MONTH_NAME + Semester.getByMonth( month ).name();
+    }
+
+    @Override
+    public Period createPeriod( String isoDate )
+    {
+        int year = Integer.parseInt( isoDate.substring( 0, 4 ) );
+        int month = Semester.valueOf( isoDate.substring( 9, 11 ) ).getMonth();
+
+        Calendar cal = createCalendarInstance();
+        cal.set( year, month, 1 );
+        return createPeriod( cal );
+    }
+
+    /**
+     * n refers to the semester, can be [1-2].
+     */
+    @Override
+    public String getIsoFormat()
+    {
+        return ISO_FORMAT;
+    }
+
+    public enum Semester
+    {
+        S1( Calendar.APRIL ), S2( Calendar.OCTOBER );
+
+        private final int month;
+
+        Semester( int month )
+        {
+            this.month = month;
+        }
+
+        public int getMonth()
+        {
+            return month;
+        }
+
+        public static Semester getByMonth( int month )
+        {
+            switch ( month )
+            {
+                case Calendar.APRIL:
+                    return S1;
+                case Calendar.OCTOBER:
+                    return S2;
+                default:
+                    throw new IllegalArgumentException( "Not a valid six-monthly starting month" );
+            }
+        }
+    }
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java	2014-02-08 18:09:18 +0000
@@ -42,7 +42,7 @@
  * @version $Id: SixMonthlyPeriodType.java 2971 2007-03-03 18:54:56Z torgeilo $
  */
 public class SixMonthlyPeriodType
-    extends CalendarPeriodType
+    extends SixMonthlyAbstractPeriodType
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
@@ -51,13 +51,13 @@
 
     private static final String ISO_FORMAT = "yyyySn";
 
+    private static final int BASE_MONTH = Calendar.JANUARY;
+
     /**
      * The name of the SixMonthlyPeriodType, which is "SixMonthly".
      */
     public static final String NAME = "SixMonthly";
 
-    public static final int FREQUENCY_ORDER = 182;
-
     // -------------------------------------------------------------------------
     // PeriodType functionality
     // -------------------------------------------------------------------------
@@ -69,35 +69,9 @@
     }
 
     @Override
-    public Period createPeriod()
-    {
-        return createPeriod( createCalendarInstance() );
-    }
-
-    @Override
-    public Period createPeriod( Date date )
-    {
-        return createPeriod( createCalendarInstance( date ) );
-    }
-
-    @Override
-    public Period createPeriod( Calendar cal )
-    {
-        cal.set( Calendar.MONTH, cal.get( Calendar.MONTH ) - cal.get( Calendar.MONTH ) % 6 );
-        cal.set( Calendar.DAY_OF_MONTH, 1 );
-
-        Date startDate = cal.getTime();
-
-        cal.add( Calendar.MONTH, 5 );
-        cal.set( Calendar.DAY_OF_MONTH, cal.getActualMaximum( Calendar.DAY_OF_MONTH ) );
-
-        return new Period( this, startDate, cal.getTime() );
-    }
-
-    @Override
-    public int getFrequencyOrder()
-    {
-        return FREQUENCY_ORDER;
+    public int getBaseMonth()
+    {
+        return BASE_MONTH;
     }
 
     // -------------------------------------------------------------------------
@@ -105,66 +79,6 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public Period getNextPeriod( Period period )
-    {
-        Calendar cal = createCalendarInstance( period.getStartDate() );
-        cal.add( Calendar.MONTH, 6 );
-        return createPeriod( cal );
-    }
-
-    @Override
-    public Period getPreviousPeriod( Period period )
-    {
-        Calendar cal = createCalendarInstance( period.getStartDate() );
-        cal.add( Calendar.MONTH, -6 );
-        return createPeriod( cal );
-    }
-
-    /**
-     * Generates six-monthly Periods for the whole year in which the given
-     * Period's startDate exists.
-     */
-    @Override
-    public List<Period> generatePeriods( Date date )
-    {
-        Calendar cal = createCalendarInstance( date );
-        cal.set( Calendar.DAY_OF_YEAR, 1 );
-
-        int year = cal.get( Calendar.YEAR );
-        ArrayList<Period> periods = new ArrayList<Period>();
-
-        while ( cal.get( Calendar.YEAR ) == year )
-        {
-            periods.add( createPeriod( cal ) );
-            cal.add( Calendar.MONTH, 6 );
-        }
-
-        return periods;
-    }
-
-    /**
-     * Generates the last 2 six-months where the last one is the six-month
-     * which the given date is inside.
-     */
-    @Override
-    public List<Period> generateRollingPeriods( Date date )
-    {
-        Calendar cal = createCalendarInstance( date );
-        cal.set( Calendar.DAY_OF_MONTH, 1 );
-        cal.add( Calendar.MONTH, ( ( cal.get( Calendar.MONTH ) % 6 ) * -1 ) - 6 );
-
-        ArrayList<Period> periods = new ArrayList<Period>();
-        
-        for ( int i = 0; i < 2; i++ )
-        {
-            periods.add( createPeriod( cal ) );
-            cal.add( Calendar.MONTH, 6 );
-        }
-        
-        return periods;
-    }
-    
-    @Override
     public String getIsoDate( Period period )
     {
         Calendar cal = createCalendarInstance( period.getStartDate() );
@@ -223,16 +137,4 @@
             }
         }
     }
-    
-    @Override
-    public Date getRewindedDate( Date date, Integer rewindedPeriods )
-    {
-        date = date != null ? date : new Date();        
-        rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
-
-        Calendar cal = createCalendarInstance( date );        
-        cal.add( Calendar.MONTH, (rewindedPeriods * -6) );
-
-        return cal.getTime();
-    }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java	2014-02-08 18:09:18 +0000
@@ -39,7 +39,7 @@
     public void testGetByIndex()
     {
         assertNull( PeriodType.getByIndex( -1 ) );
-        assertEquals( new YearlyPeriodType(), PeriodType.getByIndex( 7 ) );
+        assertEquals( new YearlyPeriodType(), PeriodType.getByIndex( 8 ) );
         assertNull( PeriodType.getByIndex( 999 ) );    
     }
 
@@ -52,6 +52,12 @@
         assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011W32").getName(),"Weekly");
         assertEquals( PeriodType.getPeriodTypeFromIsoString( "20110101").getName(),"Daily");
         assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011Q3").getName(),"Quarterly");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "201101B").getName(),"BiMonthly");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011S1").getName(),"SixMonthly");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011AprilS1").getName(),"SixMonthlyApril");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011April").getName(),"FinancialApril");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011July").getName(),"FinancialJuly");
+        assertEquals( PeriodType.getPeriodTypeFromIsoString( "2011Oct").getName(),"FinancialOct");
 
         assertNull(PeriodType.getPeriodTypeFromIsoString( "201"));
         assertNull(PeriodType.getPeriodTypeFromIsoString( "20111"));

=== added file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java	2014-02-08 18:09:18 +0000
@@ -0,0 +1,190 @@
+package org.hisp.dhis.period;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Calendar;
+import java.util.List;
+
+import org.hisp.dhis.period.Cal;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Jim Grace
+ */
+public class SixMonthlyAprilPeriodTypeTest
+{
+    private Cal startCal;
+    private Cal endCal;
+    private Cal testCal;
+    private SixMonthlyAprilPeriodType periodType;
+
+    @Before
+    public void before()
+    {
+        startCal = new Cal();
+        endCal = new Cal();
+        testCal = new Cal();
+        periodType = new SixMonthlyAprilPeriodType();
+    }
+
+    @Test
+    public void testCreatePeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        startCal.set( 2009, 4, 1 );
+        endCal.set( 2009, 9, 30 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+
+        testCal.set( 2009, 12, 15 );
+
+        startCal.set( 2009, 10, 1 );
+        endCal.set( 2010, 3, 31 );
+
+        period = periodType.createPeriod( testCal.time() );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+
+    @Test
+    public void testGetNextPeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getNextPeriod( period );
+
+        startCal.set( 2009, 10, 1 );
+        endCal.set( 2010, 3, 31 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+
+        testCal.set( 2009, 12, 15 );
+
+        period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getNextPeriod( period );
+
+        startCal.set( 2010, 4, 1 );
+        endCal.set( 2010, 9, 30 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+
+    @Test
+    public void testGetPreviousPeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getPreviousPeriod( period );
+
+        startCal.set( 2008, 10, 1 );
+        endCal.set( 2009, 3, 31 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+
+        testCal.set( 2009, 12, 15 );
+
+        period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getPreviousPeriod( period );
+
+        startCal.set( 2009, 4, 1 );
+        endCal.set( 2009, 9, 30 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+
+    @Test
+    public void testGeneratePeriods()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        List<Period> periods = periodType.generatePeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
+
+        testCal.set( 2009, 12, 15 );
+
+        periods = periodType.generatePeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
+    }
+
+    @Test
+    public void testGenerateRollingPeriods()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2008, 10, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 1 ) );
+
+        testCal.set( 2009, 12, 15 );
+
+        periods = periodType.generateRollingPeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
+    }
+
+    @Test
+    public void testGenerateLast5Years()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        List<Period> periods = periodType.generateLast5Years( testCal.time() );
+
+        assertEquals( 10, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2005, 4, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2005, 10, 1 ).time() ), periods.get( 1 ) );
+    }
+}

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java	2014-02-08 18:09:18 +0000
@@ -83,7 +83,7 @@
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, Calendar.AUGUST, 15 );
+        testCal.set( 2009, 8, 15 );
 
         Period period = periodType.createPeriod( testCal.time() );
         
@@ -94,6 +94,18 @@
 
         assertEquals( startCal.time(), period.getStartDate() );
         assertEquals( endCal.time(), period.getEndDate() );
+
+        testCal.set( 2009, 4, 15 );
+
+        period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getNextPeriod( period );
+
+        startCal.set( 2009, 7, 1 );
+        endCal.set( 2009, 12, 31 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
     }
     
     @Test
@@ -110,6 +122,18 @@
 
         assertEquals( startCal.time(), period.getStartDate() );
         assertEquals( endCal.time(), period.getEndDate() );
+
+        testCal.set( 2009, 4, 15 );
+
+        period = periodType.createPeriod( testCal.time() );
+
+        period = periodType.getPreviousPeriod( period );
+
+        startCal.set( 2008, 7, 1 );
+        endCal.set( 2008, 12, 31 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
     }
     
     @Test
@@ -122,16 +146,32 @@
         assertEquals( 2, periods.size() );
         assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
         assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
+
+        testCal.set( 2009, 4, 15 );
+
+        periods = periodType.generatePeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
     }
 
     @Test
     public void testGenerateRollingPeriods()
     {
-        testCal.set( 2009, 4, 15 );
+        testCal.set( 2009, 8, 15 );
         
         List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
         
         assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
+
+        testCal.set( 2009, 4, 15 );
+
+        periods = periodType.generateRollingPeriods( testCal.time() );
+
+        assertEquals( 2, periods.size() );
         assertEquals( periodType.createPeriod( new Cal( 2008, 7, 1 ).time() ), periods.get( 0 ) );
         assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 1 ) );
     }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java	2014-02-08 18:09:18 +0000
@@ -62,6 +62,7 @@
         Period year1 = new Period( new YearlyPeriodType(), getDate( 2010, 1, 1 ), getDate( 2010, 12, 31 ) );
         Period quarter1 = new Period( new QuarterlyPeriodType(), getDate( 2010, 1, 1 ), getDate( 2010, 3, 31 ) );
         Period semester1 = new Period( new SixMonthlyPeriodType(), getDate( 2010, 1, 1 ), getDate( 2010, 6, 30 ) );
+        Period semesterApril1 = new Period( new SixMonthlyAprilPeriodType(), getDate( 2010, 4, 1 ), getDate( 2010, 9, 30 ) );
         Period biMonth1 = new Period( new BiMonthlyPeriodType(), getDate( 2010, 3, 1 ), getDate( 2010, 4, 30 ) );
         Period financialApril = new Period( new FinancialAprilPeriodType(), getDate( 2010, 4, 1 ), getDate( 2011, 3, 31 ) );
         Period financialJuly = new Period( new FinancialJulyPeriodType(), getDate( 2010, 7, 1 ), getDate( 2011, 6, 30 ) );
@@ -72,6 +73,7 @@
         assertEquals( "Year format", "2010", year1.getIsoDate() );
         assertEquals( "Quarter format", "2010Q1", quarter1.getIsoDate() );
         assertEquals( "Semester format", "2010S1", semester1.getIsoDate() );
+        assertEquals( "SemesterApril format", "2010AprilS1", semesterApril1.getIsoDate() );
         assertEquals( "Bimonth format", "201003B", biMonth1.getIsoDate() );
         assertEquals( "Financial April", "2010April", financialApril.getIsoDate() );
         assertEquals( "Financial July", "2010July", financialJuly.getIsoDate() );
@@ -82,6 +84,7 @@
         assertEquals( year1, PeriodType.getPeriodFromIsoString( "2010" ) );
         assertEquals( quarter1, PeriodType.getPeriodFromIsoString( "2010Q1" ) );
         assertEquals( semester1, PeriodType.getPeriodFromIsoString( "2010S1" ) );
+        assertEquals( semesterApril1, PeriodType.getPeriodFromIsoString( "2010AprilS1" ) );
         assertEquals( biMonth1, PeriodType.getPeriodFromIsoString( "201003B" ) );
         assertEquals( financialApril, PeriodType.getPeriodFromIsoString( "2010April" ) );
         assertEquals( financialJuly, PeriodType.getPeriodFromIsoString( "2010July" ) );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml	2013-04-09 07:45:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml	2014-02-08 18:09:18 +0000
@@ -20,6 +20,7 @@
     <subclass name="org.hisp.dhis.period.BiMonthlyPeriodType" discriminator-value="BiMonthly" />
     <subclass name="org.hisp.dhis.period.QuarterlyPeriodType" discriminator-value="Quarterly" />
     <subclass name="org.hisp.dhis.period.SixMonthlyPeriodType" discriminator-value="SixMonthly" />
+    <subclass name="org.hisp.dhis.period.SixMonthlyAprilPeriodType" discriminator-value="SixMonthlyApril" />
     <subclass name="org.hisp.dhis.period.YearlyPeriodType" discriminator-value="Yearly" />
     <subclass name="org.hisp.dhis.period.TwoYearlyPeriodType" discriminator-value="TwoYearly" />
     <subclass name="org.hisp.dhis.period.FinancialAprilPeriodType" discriminator-value="FinancialApril" />

=== modified file 'dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties	2013-12-30 11:47:50 +0000
+++ dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties	2014-02-08 18:09:18 +0000
@@ -186,6 +186,7 @@
 BiMonthly=Bimonthly
 Quarterly=Quarterly
 SixMonthly=Six-monthly
+SixMonthlyApril=Six-monthly April
 Yearly=Yearly
 TwoYearly=Two-yearly
 OnChange=On-change

=== 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	2013-10-21 14:11:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js	2014-02-08 18:09:18 +0000
@@ -9,6 +9,7 @@
     periodTypes['BiMonthly'] = new BiMonthlyPeriodType( dateFormat );
     periodTypes['Quarterly'] = new QuarterlyPeriodType( dateFormat );
     periodTypes['SixMonthly'] = new SixMonthlyPeriodType( dateFormat );
+    periodTypes['SixMonthlyApril'] = new SixMonthlyAprilPeriodType( dateFormat );
     periodTypes['Yearly'] = new YearlyPeriodType( dateFormat );
     periodTypes['FinancialOct'] = new FinancialOctoberPeriodType( dateFormat );
     periodTypes['FinancialJuly'] = new FinancialJulyPeriodType( dateFormat );
@@ -261,6 +262,33 @@
     };
 }
 
+function SixMonthlyAprilPeriodType( dateFormat )
+{
+    this.generatePeriods = function( offset )
+    {
+        var periods = [];
+        var year = new Date().getFullYear() + offset;
+
+        var period = [];
+        period['startDate'] = year + '-04-01';
+        period['endDate'] = year + '-09-30';
+        period['name'] = monthNames[3] + ' - ' + monthNames[8] + ' ' + year;
+        period['id'] = 'SixMonthlyApril_' + period['startDate'];
+        period['iso'] = year + 'AprilS1';
+        periods[0] = period;
+
+        period = [];
+        period['startDate'] = year + '-10-01';
+        period['endDate'] = ( year + 1 ) + '-03-31';
+        period['name'] = monthNames[9] + ' ' + year + ' - ' + monthNames[2] + ' ' + ( year + 1 );
+        period['id'] = 'SixMonthlyApril_' + period['startDate'];
+        period['iso'] = year + 'AprilS2';
+        periods[1] = period;
+
+        return periods;
+    };
+}
+
 function YearlyPeriodType( dateFormat )
 {
     this.generatePeriods = function( offset )

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodTypeNoDep.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodTypeNoDep.js	2013-06-26 12:19:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodTypeNoDep.js	2014-02-08 18:09:18 +0000
@@ -36,6 +36,7 @@
     periodTypes['BiMonthly'] = new BiMonthlyPeriodType( format_yyyymmdd, monthNames, filterFuturePeriods );
     periodTypes['Quarterly'] = new QuarterlyPeriodType( format_yyyymmdd, monthNames, filterFuturePeriods );
     periodTypes['SixMonthly'] = new SixMonthlyPeriodType( monthNames, filterFuturePeriods );
+    periodTypes['SixMonthlyApril'] = new SixMonthlyAprilPeriodType( monthNames, filterFuturePeriods );
     periodTypes['Yearly'] = new YearlyPeriodType( format_yyyymmdd, filterFuturePeriods );
     periodTypes['FinancialOct'] = new FinancialOctoberPeriodType( format_yyyymmdd, monthNames, filterFuturePeriods );
     periodTypes['FinancialJuly'] = new FinancialJulyPeriodType( format_yyyymmdd, monthNames, filterFuturePeriods );
@@ -245,10 +246,10 @@
     this.generatePeriods = function( config )
     {
         var periods = [],
-			offset = parseInt(config.offset),
-			isFilter = config.filterFuturePeriods,
-			isReverse = config.reversePeriods,
-			year = new Date().getFullYear() + offset;
+            offset = parseInt(config.offset),
+            isFilter = config.filterFuturePeriods,
+            isReverse = config.reversePeriods,
+            year = new Date().getFullYear() + offset;
 
         var period = {};
         period['startDate'] = year + '-01-01';
@@ -256,7 +257,7 @@
         period['name'] = monthNames[0] + ' - ' + monthNames[5] + ' ' + year;
         //period['id'] = 'SixMonthly_' + period['startDate'];
         period['iso'] = year + 'S1';
-		period['id'] = period['iso'];
+        period['id'] = period['iso'];
         periods.push(period);
 
         period = {};
@@ -265,7 +266,42 @@
         period['name'] = monthNames[6] + ' - ' + monthNames[11] + ' ' + year;
         //period['id'] = 'SixMonthly_' + period['startDate'];
         period['iso'] = year + 'S2';
-		period['id'] = period['iso'];
+        period['id'] = period['iso'];
+        periods.push(period);
+
+        periods = isFilter ? fnFilter( periods ) : periods;
+        periods = isReverse ? periods.reverse() : periods;
+
+        return periods;
+    };
+}
+
+function SixMonthlyAprilPeriodType( monthNames, fnFilter )
+{
+    this.generatePeriods = function( config )
+    {
+        var periods = [],
+            offset = parseInt(config.offset),
+            isFilter = config.filterFuturePeriods,
+            isReverse = config.reversePeriods,
+            year = new Date().getFullYear() + offset;
+
+        var period = {};
+        period['startDate'] = year + '-04-01';
+        period['endDate'] = year + '-09-30';
+        period['name'] = monthNames[3] + ' - ' + monthNames[8] + ' ' + year;
+        //period['id'] = 'SixMonthlyApril_' + period['startDate'];
+        period['iso'] = year + 'AprilS1';
+        period['id'] = period['iso'];
+        periods.push(period);
+
+        period = {};
+        period['startDate'] = year + '-10-01';
+        period['endDate'] = ( year + 1 ) + '-03-31';
+        period['name'] = monthNames[9] + ' ' + year + ' - ' + monthNames[2] + ' ' + ( year + 1 );
+        //period['id'] = 'SixMonthlyApril_' + period['startDate'];
+        period['iso'] = year + 'AprilS2';
+        period['id'] = period['iso'];
         periods.push(period);
 
         periods = isFilter ? fnFilter( periods ) : periods;

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js	2014-01-03 19:36:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js	2014-02-08 18:09:18 +0000
@@ -1,1 +1,1 @@
-Ext.onReady(function(){function b(){var o=0;var l=0;var j=0;var i=0;var p=0;var m=0;var k=0;this.addData=function(n,s){if(p==0){m=n;k=s}else{var r=n-m;var q=s-k;j+=r*r*p/(p+1);i+=r*q*p/(p+1);m+=r/(p+1);k+=q/(p+1)}o+=n;l+=s;p++};this.predict=function(n){var q=this.getSlope();return this.getIntercept(q)+q*n};this.getSlope=function(){if(p<2){return Number.NaN}return i/j};this.getIntercept=function(n){return(l-n*o)/p}}Ext.Ajax.method="GET";DV={};DV.instances=[];DV.i18n={};DV.isDebug=false;DV.isSessionStorage=("sessionStorage" in window&&window.sessionStorage!==null);DV.getCore=function(o){var k={},m={},l={},i={},j={},n;(function(){k.finals={ajax:{path_module:"/dhis-web-visualizer/",path_api:"/api/",path_commons:"/dhis-web-commons-ajax-json/",data_get:"chartValues.json",indicator_get:"indicatorGroups/",indicator_getall:"indicators.json?paging=false&links=false",indicatorgroup_get:"indicatorGroups.json?paging=false&links=false",dataelement_get:"dataElementGroups/",dataelement_getall:"dataElements.json?domainType=aggregate&paging=false&links=false",dataelementgroup_get:"dataElementGroups.json?paging=false&links=false",dataset_get:"dataSets.json?paging=false&links=false"},dimension:{data:{value:"data",name:DV.i18n.data,dimensionName:"dx",objectName:"dx"},indicator:{value:"indicator",name:DV.i18n.indicator,dimensionName:"dx",objectName:"in"},dataElement:{value:"dataelement",name:DV.i18n.data_element,dimensionName:"dx",objectName:"de"},operand:{value:"operand",name:"Operand",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataset",name:DV.i18n.dataset,dimensionName:"dx",objectName:"ds"},category:{name:DV.i18n.categories,dimensionName:"co",objectName:"co"},period:{value:"period",name:DV.i18n.period,dimensionName:"pe",objectName:"pe"},fixedPeriod:{value:"periods"},relativePeriod:{value:"relativePeriods"},organisationUnit:{value:"organisationUnits",name:DV.i18n.organisation_units,dimensionName:"ou",objectName:"ou"},dimension:{value:"dimension"},value:{value:"value"}},chart:{series:"series",category:"category",filter:"filter",column:"column",stackedcolumn:"stackedcolumn",bar:"bar",stackedbar:"stackedbar",line:"line",area:"area",pie:"pie",radar:"radar"},data:{domain:"domain_",targetLine:"targetline_",baseLine:"baseline_",trendLine:"trendline_"},image:{png:"png",pdf:"pdf"},cmd:{init:"init_",none:"none_",urlparam:"id"},root:{id:"root"}};n=k.finals.dimension;n.objectNameMap={};n.objectNameMap[n.data.objectName]=n.data;n.objectNameMap[n.indicator.objectName]=n.indicator;n.objectNameMap[n.dataElement.objectName]=n.dataElement;n.objectNameMap[n.operand.objectName]=n.operand;n.objectNameMap[n.dataSet.objectName]=n.dataSet;n.objectNameMap[n.category.objectName]=n.category;n.objectNameMap[n.period.objectName]=n.period;n.objectNameMap[n.organisationUnit.objectName]=n.organisationUnit;n.objectNameMap[n.dimension.objectName]=n.dimension;k.period={periodTypes:[{id:"Daily",name:DV.i18n.daily},{id:"Weekly",name:DV.i18n.weekly},{id:"Monthly",name:DV.i18n.monthly},{id:"BiMonthly",name:DV.i18n.bimonthly},{id:"Quarterly",name:DV.i18n.quarterly},{id:"SixMonthly",name:DV.i18n.sixmonthly},{id:"Yearly",name:DV.i18n.yearly},{id:"FinancialOct",name:DV.i18n.financial_oct},{id:"FinancialJuly",name:DV.i18n.financial_july},{id:"FinancialApril",name:DV.i18n.financial_april}]};k.layout={west_width:424,west_fieldset_width:416,west_width_padding:4,west_fill:2,west_fill_accordion_indicator:59,west_fill_accordion_dataelement:59,west_fill_accordion_dataset:33,west_fill_accordion_period:296,west_fill_accordion_organisationunit:62,west_maxheight_accordion_indicator:350,west_maxheight_accordion_dataelement:350,west_maxheight_accordion_dataset:350,west_maxheight_accordion_period:513,west_maxheight_accordion_organisationunit:500,west_maxheight_accordion_group:350,west_scrollbarheight_accordion_indicator:300,west_scrollbarheight_accordion_dataelement:300,west_scrollbarheight_accordion_dataset:300,west_scrollbarheight_accordion_period:450,west_scrollbarheight_accordion_organisationunit:450,west_scrollbarheight_accordion_group:300,east_tbar_height:31,east_gridcolumn_height:30,form_label_width:55,window_favorite_ypos:100,window_confirm_width:250,window_share_width:500,grid_favorite_width:420,grid_row_height:27,treepanel_minheight:135,treepanel_maxheight:400,treepanel_fill_default:310,treepanel_toolbar_menu_width_group:140,treepanel_toolbar_menu_width_level:120,multiselect_minheight:100,multiselect_maxheight:250,multiselect_fill_default:345,multiselect_fill_reportingrates:315};k.chart={style:{inset:30,fontFamily:"Arial,Sans-serif,Lucida Grande,Ubuntu"},theme:{dv1:["#94ae0a","#0b3b68","#a61120","#ff8809","#7c7474","#a61187","#ffd13e","#24ad9a","#a66111","#414141","#4500c4","#1d5700"]}};k.status={icon:{error:"error_s.png",warning:"warning.png",ok:"ok.png"}}}());(function(){m.layout={};m.layout.Record=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Record: config is not an object: "+p);return}if(!Ext.isString(p.id)){alert("Record: id is not text: "+p);return}p.id=p.id.replace(".","-");return p}()};m.layout.Dimension=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Dimension: config is not an object: "+p);return}if(!Ext.isString(p.dimension)){console.log("Dimension: name is not a string: "+p);return}if(p.dimension!==k.finals.dimension.category.objectName){var q=[];if(!Ext.isArray(p.items)){console.log("Dimension: items is not an array: "+p);return}for(var r=0;r<p.items.length;r++){q.push(m.layout.Record(p.items[r]))}p.items=Ext.Array.clean(q);if(!p.items.length){console.log("Dimension: has no valid items: "+p);return}}return p}()};m.layout.Layout=function(q){var q=Ext.clone(q),r={},p,s;p=function(u){var u=Ext.clone(u);if(!(u&&Ext.isArray(u)&&u.length)){return}for(var t=0;t<u.length;t++){u[t]=m.layout.Dimension(u[t])}u=Ext.Array.clean(u);return u.length?u:null};analytical2layout=function(u){var w=Ext.clone(u),x=n.category.objectName;u=Ext.clone(u);w.columns=[];w.rows=[];w.filters=w.filters||[];if(Ext.isArray(u.columns)&&u.columns.length){u.columns.reverse();for(var t=0,v;t<u.columns.length;t++){v=u.columns[t];if(v.dimension===x){continue}if(!w.columns.length){w.columns.push(v)}else{if(v.dimension===n.indicator.objectName){w.filters.push(w.columns.pop());w.columns=[v]}else{w.filters.push(v)}}}}if(Ext.isArray(u.rows)&&u.rows.length){u.rows.reverse();for(var t=0,v;t<u.rows.length;t++){v=u.rows[t];if(v.dimension===x){continue}if(!w.rows.length){w.rows.push(v)}else{if(v.dimension===n.indicator.objectName){w.filters.push(w.rows.pop());w.rows=[v]}else{w.filters.push(v)}}}}return w};s=function(){var v=k.finals.dimension,u,w={};if(!r){return}u=Ext.Array.clean([].concat(r.columns||[],r.rows||[],r.filters||[]));for(var t=0;t<u.length;t++){w[u[t].dimension]=u[t]}if(r.filters&&r.filters.length){for(var t=0;t<r.filters.length;t++){if(r.filters[t].dimension===v.indicator.objectName){j.message.alert(DV.i18n.indicators_cannot_be_specified_as_filter||"Indicators cannot be specified as filter");return}if(r.filters[t].dimension===v.category.objectName){j.message.alert(DV.i18n.categories_cannot_be_specified_as_filter||"Categories cannot be specified as filter");return}if(r.filters[t].dimension===v.dataSet.objectName){j.message.alert(DV.i18n.data_sets_cannot_be_specified_as_filter||"Data sets cannot be specified as filter");return}}}if(w[v.operand.objectName]&&w[v.indicator.objectName]){j.message.alert("Indicators and detailed data elements cannot be specified together");return}if(w[v.operand.objectName]&&w[v.dataElement.objectName]){j.message.alert("Detailed data elements and totals cannot be specified together");return}if(w[v.operand.objectName]&&w[v.dataSet.objectName]){j.message.alert("Data sets and detailed data elements cannot be specified together");return}if(w[v.operand.objectName]&&w[v.category.objectName]){j.message.alert("Categories and detailed data elements cannot be specified together");return}return true};return function(){var t=[],v=k.finals.dimension;if(!(q&&Ext.isObject(q))){alert("Layout: config is not an object ("+o.el+")");return}q.columns=p(q.columns);q.rows=p(q.rows);q.filters=p(q.filters);if(!q.columns){alert("No series items selected");return}if(!q.rows){alert("No category items selected");return}for(var u=0,w=Ext.Array.clean([].concat(q.columns||[],q.rows||[],q.filters||[]));u<w.length;u++){if(m.layout.Dimension(w[u])){t.push(w[u].dimension)}}if(!Ext.Array.contains(t,v.period.objectName)){alert("At least one period must be specified as series, category or filter");return}if(q.id){r.id=q.id}if(q.name){r.name=q.name}q=analytical2layout(q);r.type=Ext.isString(q.type)?q.type.toLowerCase():k.finals.chart.column;r.columns=q.columns;r.rows=q.rows;r.filters=q.filters;r.showTrendLine=Ext.isBoolean(q.regression)?q.regression:(Ext.isBoolean(q.showTrendLine)?q.showTrendLine:false);r.showValues=Ext.isBoolean(q.showData)?q.showData:(Ext.isBoolean(q.showValues)?q.showValues:true);r.hideLegend=Ext.isBoolean(q.hideLegend)?q.hideLegend:false;r.hideTitle=Ext.isBoolean(q.hideTitle)?q.hideTitle:false;r.targetLineValue=Ext.isNumber(q.targetLineValue)?q.targetLineValue:null;r.targetLineTitle=Ext.isString(q.targetLineLabel)&&!Ext.isEmpty(q.targetLineLabel)?q.targetLineLabel:(Ext.isString(q.targetLineTitle)&&!Ext.isEmpty(q.targetLineTitle)?q.targetLineTitle:null);r.baseLineValue=Ext.isNumber(q.baseLineValue)?q.baseLineValue:null;r.baseLineTitle=Ext.isString(q.baseLineLabel)&&!Ext.isEmpty(q.baseLineLabel)?q.baseLineLabel:(Ext.isString(q.baseLineTitle)&&!Ext.isEmpty(q.baseLineTitle)?q.baseLineTitle:null);r.title=Ext.isString(q.title)&&!Ext.isEmpty(q.title)?q.title:null;r.domainAxisTitle=Ext.isString(q.domainAxisLabel)&&!Ext.isEmpty(q.domainAxisLabel)?q.domainAxisLabel:(Ext.isString(q.domainAxisTitle)&&!Ext.isEmpty(q.domainAxisTitle)?q.domainAxisTitle:null);r.rangeAxisTitle=Ext.isString(q.rangeAxisLabel)&&!Ext.isEmpty(q.rangeAxisLabel)?q.rangeAxisLabel:(Ext.isString(q.rangeAxisTitle)&&!Ext.isEmpty(q.rangeAxisTitle)?q.rangeAxisTitle:null);r.parentGraphMap=Ext.isObject(q.parentGraphMap)?q.parentGraphMap:null;if(!s()){return}return r}()};m.response={};m.response.Header=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Header: config is not an object: "+p);return}if(!Ext.isString(p.name)){console.log("Header: name is not a string: "+p);return}if(!Ext.isBoolean(p.meta)){console.log("Header: meta is not boolean: "+p);return}return p}()};m.response.Response=function(p){var p=Ext.clone(p);return function(){if(!(p&&Ext.isObject(p))){console.log("Response: config is not an object");return}if(!(p.headers&&Ext.isArray(p.headers))){console.log("Response: headers is not an array");return}for(var q=0,r;q<p.headers.length;q++){p.headers[q]=m.response.Header(p.headers[q])}p.headers=Ext.Array.clean(p.headers);if(!p.headers.length){console.log("Response: no valid headers");return}if(!(Ext.isArray(p.rows)&&p.rows.length>0)){alert("No values found");return}if(p.headers.length!==p.rows[0].length){console.log("Response: headers.length !== rows[0].length")}return p}()}}());(function(){l.prototype={};l.prototype.array={};l.prototype.array.getLength=function(q,p){if(!Ext.isArray(q)){if(!p){console.log("support.prototype.array.getLength: not an array")}return null}return q.length};l.prototype.array.sort=function(r,q,p){if(!l.prototype.array.getLength(r)){return}p=p||"name";r.sort(function(t,s){if(Ext.isObject(t)&&Ext.isObject(s)&&p){t=t[p];s=s[p]}if(Ext.isString(t)&&Ext.isString(s)){t=t.toLowerCase();s=s.toLowerCase();if(q==="DESC"){return t<s?1:(t>s?-1:0)}else{return t<s?-1:(t>s?1:0)}}else{if(Ext.isNumber(t)&&Ext.isNumber(s)){return q==="DESC"?s-t:t-s}}return 0});return r};l.prototype.object={};l.prototype.object.getLength=function(p,s){if(!Ext.isObject(p)){if(!s){console.log("support.prototype.object.getLength: not an object")}return null}var r=0;for(var q in p){if(p.hasOwnProperty(q)){r++}}return r};l.prototype.object.hasObject=function(q,t,s){if(!l.prototype.object.getLength(q)){return null}for(var r in q){var p=q[r];if(q.hasOwnProperty(r)&&p[t]===s){return true}}return null};l.prototype.str={};l.prototype.str.replaceAll=function(r,q,p){return r.replace(new RegExp(q,"g"),p)}}());(function(){i.layout={};i.layout.cleanDimensionArray=function(q){if(!l.prototype.array.getLength(q)){return null}var r=[];for(var p=0;p<q.length;p++){r.push(m.layout.Dimension(q[p]))}r=Ext.Array.clean(r);return r.length?r:null};i.layout.sortDimensionArray=function(s,r){if(!l.prototype.array.getLength(s,true)){return null}s=i.layout.cleanDimensionArray(s);if(!s){console.log("service.layout.sortDimensionArray: no valid dimensions");return null}r=r||"dimensionName";Ext.Array.sort(s,function(u,t){if(u[r]<t[r]){return -1}if(u[r]>t[r]){return 1}return 0});for(var q=0,p;q<s.length;q++){l.prototype.array.sort(s[q].items,"ASC","id");if(l.prototype.array.getLength(s[q].ids)){l.prototype.array.sort(s[q].ids)}}return s};i.layout.getObjectNameDimensionMapFromDimensionArray=function(s){var r={};if(!l.prototype.array.getLength(s)){return null}for(var p=0,q;p<s.length;p++){q=m.layout.Dimension(s[p]);if(q){r[q.dimension]=q}}return l.prototype.object.getLength(r)?r:null};i.layout.getObjectNameDimensionItemsMapFromDimensionArray=function(s){var r={};if(!l.prototype.array.getLength(s)){return null}for(var p=0,q;p<s.length;p++){q=m.layout.Dimension(s[p]);if(q){r[q.dimension]=q.items}}return l.prototype.object.getLength(r)?r:null};i.layout.getExtendedLayout=function(u){var u=Ext.clone(u),w={columns:[],rows:[],filters:[],columnObjectNames:[],columnDimensionNames:[],columnItems:[],columnIds:[],rowObjectNames:[],rowDimensionNames:[],rowItems:[],rowIds:[],axisDimensions:[],axisObjectNames:[],axisDimensionNames:[],sortedAxisDimensionNames:[],filterDimensions:[],filterObjectNames:[],filterDimensionNames:[],filterItems:[],filterIds:[],sortedFilterDimensions:[],dimensions:[],objectNames:[],dimensionNames:[],objectNameDimensionsMap:{},objectNameItemsMap:{},objectNameIdsMap:{},dimensionNameDimensionsMap:{},dimensionNameItemsMap:{},dimensionNameIdsMap:{},dimensionNameSortedIdsMap:{}};Ext.applyIf(w,u);if(u.columns){for(var s=0,t,v,p;s<u.columns.length;s++){t=u.columns[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.columns.push(p);w.columnObjectNames.push(p.objectName);w.columnDimensionNames.push(p.dimensionName);w.columnItems=w.columnItems.concat(p.items);w.columnIds=w.columnIds.concat(p.ids);w.axisDimensions.push(p);w.axisObjectNames.push(p.objectName);w.axisDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}if(u.rows){for(var s=0,t,v,p;s<u.rows.length;s++){t=u.rows[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.rows.push(p);w.rowObjectNames.push(p.objectName);w.rowDimensionNames.push(p.dimensionName);w.rowItems=w.rowItems.concat(p.items);w.rowIds=w.rowIds.concat(p.ids);w.axisDimensions.push(p);w.axisObjectNames.push(p.objectName);w.axisDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}if(u.filters){for(var s=0,t,v,p;s<u.filters.length;s++){t=u.filters[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.filters.push(p);w.filterDimensions.push(p);w.filterObjectNames.push(p.objectName);w.filterDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.filterItems=w.filterItems.concat(p.items);w.filterIds=w.filterIds.concat(p.ids);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}w.axisDimensionNames=Ext.Array.unique(w.axisDimensionNames);w.filterDimensionNames=Ext.Array.unique(w.filterDimensionNames);w.columnDimensionNames=Ext.Array.unique(w.columnDimensionNames);w.rowDimensionNames=Ext.Array.unique(w.rowDimensionNames);w.filterDimensionNames=Ext.Array.unique(w.filterDimensionNames);w.sortedAxisDimensionNames=Ext.clone(w.axisDimensionNames).sort();w.sortedFilterDimensions=i.layout.sortDimensionArray(Ext.clone(w.filterDimensions));w.dimensions=[].concat(w.axisDimensions,w.filterDimensions);w.objectNames=[].concat(w.axisObjectNames,w.filterObjectNames);w.dimensionNames=[].concat(w.axisDimensionNames,w.filterDimensionNames);for(var s=0,q;s<w.dimensionNames.length;s++){q=w.dimensionNames[s];w.dimensionNameDimensionsMap[q]=[];w.dimensionNameItemsMap[q]=[];w.dimensionNameIdsMap[q]=[]}for(var s=0,p;s<w.dimensions.length;s++){p=w.dimensions[s];w.dimensionNameDimensionsMap[p.dimensionName].push(p);w.dimensionNameItemsMap[p.dimensionName]=w.dimensionNameItemsMap[p.dimensionName].concat(p.items);w.dimensionNameIdsMap[p.dimensionName]=w.dimensionNameIdsMap[p.dimensionName].concat(p.ids)}for(var x in w.dimensionNameIdsMap){if(w.dimensionNameIdsMap.hasOwnProperty(x)){w.dimensionNameSortedIdsMap[x]=Ext.clone(w.dimensionNameIdsMap[x]).sort()}}return w};i.layout.getSyncronizedXLayout=function(z,p){var t=Ext.Array.clean([].concat(z.columns||[],z.rows||[],z.filters||[])),L=z.objectNameDimensionsMap[n.organisationUnit.objectName],w=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT"),N=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT_CHILDREN"),K=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT_GRANDCHILDREN"),q=function(){if(L&&Ext.isArray(L.ids)){for(var P=0;P<L.ids.length;P++){if(L.ids[P].substr(0,5)==="LEVEL"){return true}}}return false}(),y=function(){if(L&&Ext.isArray(L.ids)){for(var P=0;P<L.ids.length;P++){if(L.ids[P].substr(0,8)==="OU_GROUP"){return true}}}return false}(),s=n.organisationUnit.objectName,O;for(var H=0,F,x,A;H<t.length;H++){F=t[H];F.items=[];x=p.metaData[F.objectName];if(F.dimensionName===s){if(w||N||K){var J,v,C;if(w){J=[{id:o.user.ou,name:p.metaData.names[o.user.ou]}]}if(N){v=[];for(var E=0;E<o.user.ouc.length;E++){v.push({id:o.user.ouc[E],name:p.metaData.names[o.user.ouc[E]]})}l.prototype.array.sort(v)}if(K){var r=[].concat(o.user.ou,o.user.ouc),u=p.metaData[s];C=[];for(var E=0,B;E<u.length;E++){B=u[E];if(!Ext.Array.contains(r,B)){C.push({id:B,name:p.metaData.names[B]})}}l.prototype.array.sort(C)}F.items=[].concat(J||[],v||[],C||[])}else{if(q||y){for(var E=0,u=p.metaData[s],B;E<u.length;E++){B=u[E];F.items.push({id:B,name:p.metaData.names[B]})}l.prototype.array.sort(F.items)}else{F.items=Ext.clone(z.dimensionNameItemsMap[F.dimensionName])}}}else{if(Ext.isArray(x)&&x.length){var D=Ext.clone(p.metaData[F.dimensionName]);for(var E=0;E<D.length;E++){F.items.push({id:D[E],name:p.metaData.names[D[E]]})}}else{F.items=Ext.clone(z.objectNameItemsMap[F.objectName])}}}O=m.layout.Layout(z);if(O){t=Ext.Array.clean([].concat(O.columns||[],O.rows||[],O.filters||[]));for(var H=0,G=p.metaData.names,I;H<t.length;H++){I=t[H].items;if(Ext.isArray(I)&&I.length){for(var E=0,M;E<I.length;E++){M=I[E];if(Ext.isObject(M)&&Ext.isString(G[M.id])&&!Ext.isString(M.name)){M.name=G[M.id]||""}}}}return i.layout.getExtendedLayout(O)}return null};i.layout.layout2plugin=function(t){var t=Ext.clone(t),s=Ext.Array.clean([].concat(t.columns||[],t.rows||[],t.filters||[]));if(Ext.isString(t.id)){return{id:t.id}}for(var q=0,u,r;q<s.length;q++){u=s[q];delete u.id;delete u.ids;delete u.type;delete u.dimensionName;delete u.objectName;for(var p=0,r;p<u.items.length;p++){r=u.items[p];delete r.name;delete r.code;delete r.created;delete r.lastUpdated}}if(!t.showTrendLine){delete t.showTrendLine}if(!t.targetLineValue){delete t.targetLineValue}if(!t.targetLineTitle){delete t.targetLineTitle}if(!t.baseLineValue){delete t.baseLineValue}if(!t.baseLineTitle){delete t.baseLineTitle}if(t.showValues){delete t.showValues}if(!t.hideLegend){delete t.hideLegend}if(!t.hideTitle){delete t.hideTitle}if(!t.title){delete t.title}if(!t.domainAxisTitle){delete t.domainAxisTitle}if(!t.rangeAxisTitle){delete t.rangeAxisTitle}if(!t.sorting){delete t.sorting}delete t.parentGraphMap;delete t.reportingPeriod;delete t.organisationUnit;delete t.parentOrganisationUnit;delete t.regression;delete t.cumulative;delete t.sortOrder;delete t.topLimit;return t};i.response={};i.response.getExtendedResponse=function(q,p){var r=[];p.nameHeaderMap={};p.idValueMap={};(function(){for(var s=0,t;s<p.headers.length;s++){t=p.headers[s];t.index=s;if(t.meta){t.ids=Ext.clone(q.dimensionNameIdsMap[t.name])||[];t.size=t.ids.length;r=r.concat(t.ids)}}for(var s=0,t;s<p.headers.length;s++){t=p.headers[s];p.nameHeaderMap[t.name]=t}}());(function(){for(var s=0,u,t;s<r.length;s++){u=r[s];if(u.indexOf("-")!==-1){t=u.split("-");p.metaData.names[u]=p.metaData.names[t[0]]+" "+p.metaData.names[t[1]]}}}());(function(){var x=p.nameHeaderMap[k.finals.dimension.value.value].index,t=p.nameHeaderMap[k.finals.dimension.category.dimensionName],B=n.data.dimensionName,y=n.category.dimensionName,v=q.axisDimensionNames,z=[];for(var w=0;w<v.length;w++){z.push(p.nameHeaderMap[v[w]].index);if(t&&!Ext.Array.contains(v,y)&&v[w]===B){z.push(t.index)}}for(var w=0,A,s;w<p.rows.length;w++){A=p.rows[w];s="";for(var u=0;u<z.length;u++){s+=A[z[u]]}p.idValueMap[s]=A[x]}}());return p}}());(function(){j.mask={};j.mask.show=function(p,q){if(!Ext.isObject(p)){console.log("support.gui.mask.show: component not an object");return null}q=q||"Loading..";if(p.mask){p.mask.destroy();p.mask=null}p.mask=new Ext.create("Ext.LoadMask",p,{shadow:false,message:q,style:"box-shadow:0",bodyStyle:"box-shadow:0"});p.mask.show()};j.mask.hide=function(p){if(!Ext.isObject(p)){console.log("support.gui.mask.hide: component not an object");return null}if(p.mask){p.mask.destroy();p.mask=null}};j.message={};j.message.alert=function(p){console.log(p)};j.analytics={};j.analytics.getParamString=function(B,s){var w=s?B.sortedAxisDimensionNames:B.axisDimensionNames,C=s?B.sortedFilterDimensions:B.filterDimensions,p=s?B.dimensionNameSortedIdsMap:B.dimensionNameIdsMap,t="?",r=false,q=B.dimensionNameItemsMap,D=n.indicator.dimensionName;for(var x=0,u,A;x<w.length;x++){u=w[x];t+="dimension="+u;A=Ext.clone(p[u]);if(u===D){for(var v=0,z;v<A.length;v++){z=A[v].indexOf("-");if(z>0){r=true;A[v]=A[v].substr(0,z)}}A=Ext.Array.unique(A)}if(u!==n.category.dimensionName){t+=":"+A.join(";")}if(x<(w.length-1)){t+="&"}}if(r){t+="&dimension="+k.finals.dimension.category.dimensionName}if(Ext.isArray(C)&&C.length){for(var x=0,y;x<C.length;x++){y=C[x];t+="&filter="+y.dimensionName+":"+y.ids.join(";")}}return t};j.analytics.validateUrl=function(q){var r;if(Ext.isIE){r="Too many items selected (url has "+q.length+" characters). Internet Explorer accepts maximum 2048 characters."}else{var p=q.length>8000?"8000":(q.length>4000?"4000":"2000");r="Too many items selected (url has "+q.length+" characters). Please reduce to less than "+p+" characters."}r+="\n\nHint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.";alert(r)};j.chart={};j.chart.createChart=function(K){var u=K.app.xResponse,A=K.app.xLayout,w,s,D,t,H,J,q,x,G,C,I,v,B,r,F,E,z,y,p={};t=function(){var X=k.finals.dimension.period.dimensionName,N=A.columns[0].dimensionName,O=A.rows[0].dimensionName,V=[],W=A.columnIds,R=A.rowIds,ab=[],Z=[],Q=[],Y;for(var U=0,T,M;U<R.length;U++){T={};M=R[U];T[k.finals.data.domain]=u.metaData.names[M];for(var S=0,L;S<W.length;S++){L=l.prototype.str.replaceAll(W[S],"-","")+l.prototype.str.replaceAll(R[U],"-","");T[W[S]]=parseFloat(u.idValueMap[L])}V.push(T)}if(A.showTrendLine){for(var U=0,P,aa;U<W.length;U++){P=new b();aa=k.finals.data.trendLine+W[U];for(var S=0;S<V.length;S++){P.addData(S,V[S][W[U]])}for(var S=0;S<V.length;S++){V[S][aa]=parseFloat(P.predict(S).toFixed(1))}ab.push(aa);u.metaData.names[aa]=DV.i18n.trend+" ("+u.metaData.names[W[U]]+")"}}if(Ext.isNumber(A.targetLineValue)||Ext.isNumber(parseFloat(A.targetLineValue))){for(var U=0;U<V.length;U++){V[U][k.finals.data.targetLine]=parseFloat(A.targetLineValue)}Z.push(k.finals.data.targetLine)}if(Ext.isNumber(A.baseLineValue)||Ext.isNumber(parseFloat(A.baseLineValue))){for(var U=0;U<V.length;U++){V[U][k.finals.data.baseLine]=parseFloat(A.baseLineValue)}Q.push(k.finals.data.baseLine)}Y=Ext.create("Ext.data.Store",{fields:function(){var ac=Ext.clone(W);ac.push(k.finals.data.domain);ac=ac.concat(ab,Z,Q);return ac}(),data:V});Y.rangeFields=W;Y.domainFields=[k.finals.data.domain];Y.trendLineFields=ab;Y.targetLineFields=Z;Y.baseLineFields=Q;Y.numericFields=[].concat(Y.rangeFields,Y.trendLineFields,Y.targetLineFields,Y.baseLineFields);Y.getMaximum=function(){var ad=[];for(var ac=0;ac<Y.numericFields.length;ac++){ad.push(Y.max(Y.numericFields[ac]))}return Ext.Array.max(ad)};Y.getMinimum=function(){var ad=[];for(var ac=0;ac<Y.numericFields.length;ac++){ad.push(Y.max(Y.numericFields[ac]))}return Ext.Array.min(ad)};Y.getMaximumSum=function(){var ad=[],ac=0;Y.each(function(ae){ac=0;for(var af=0;af<Y.rangeFields.length;af++){ac+=ae.data[Y.rangeFields[af]]}ad.push(ac)});return Ext.Array.max(ad)};if(DV.isDebug){console.log("data",V);console.log("rangeFields",Y.rangeFields);console.log("domainFields",Y.domainFields);console.log("trendLineFields",Y.trendLineFields);console.log("targetLineFields",Y.targetLineFields);console.log("baseLineFields",Y.baseLineFields)}return Y};H=function(N){var M=k.finals.chart,P=N.getMinimum(),Q,O;if((A.type===M.stackedcolumn||A.type===M.stackedbar)&&(A.showTrendLine||A.targetLineValue||A.baseLineValue)){var L=[N.getMaximum(),N.getMaximumSum()];Q=Math.ceil(Ext.Array.max(L)*1.1);Q=Math.floor(Q/10)*10}O={type:"Numeric",position:"left",fields:N.numericFields,minimum:P<0?P:0,label:{renderer:Ext.util.Format.numberRenderer("0,0")},grid:{odd:{opacity:1,stroke:"#aaa","stroke-width":0.1},even:{opacity:1,stroke:"#aaa","stroke-width":0.1}}};if(Q){O.maximum=Q}if(A.rangeAxisTitle){O.title=A.rangeAxisTitle}return O};J=function(L){var M={type:"Category",position:"bottom",fields:L.domainFields,label:{rotate:{degrees:330}}};if(A.domainAxisTitle){M.title=A.domainAxisTitle}return M};q=function(M){var L=[];for(var N=0,P,O;N<M.rangeFields.length;N++){P=M.rangeFields[N];L.push(u.metaData.names[P])}return L};x=function(M){var L={type:"column",axis:"left",xField:M.domainFields,yField:M.rangeFields,style:{opacity:0.8,lineWidth:3},markerConfig:{type:"circle",radius:4},tips:v(),title:q(M)};if(A.showValues){L.label={display:"outside","text-anchor":"middle",field:M.rangeFields,font:k.chart.style.fontFamily}}return L};G=function(M){var L=[];for(var N=0;N<M.trendLineFields.length;N++){L.push({type:"line",axis:"left",xField:M.domainFields,yField:M.trendLineFields[N],style:{opacity:0.8,lineWidth:3,"stroke-dasharray":8},markerConfig:{type:"circle",radius:0},title:u.metaData.names[M.trendLineFields[N]]})}return L};C=function(L){return{type:"line",axis:"left",xField:L.domainFields,yField:L.targetLineFields,style:{opacity:1,lineWidth:2,"stroke-width":1,stroke:"#041423"},showMarkers:false,title:(Ext.isString(A.targetLineTitle)?A.targetLineTitle:DV.i18n.target)+" ("+A.targetLineValue+")"}};I=function(L){return{type:"line",axis:"left",xField:L.domainFields,yField:L.baseLineFields,style:{opacity:1,lineWidth:2,"stroke-width":1,stroke:"#041423"},showMarkers:false,title:(Ext.isString(A.baseLineTitle)?A.baseLineTitle:DV.i18n.base)+" ("+A.baseLineValue+")"}};v=function(){return{trackMouse:true,cls:"dv-chart-tips",renderer:function(L,M){this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">'+M.value[1]+'</div><div style="font-size:10px">'+L.data[k.finals.data.domain]+"</div></div>")}}};B=function(M){var L=k.chart.theme.dv1.slice(0,M.rangeFields.length);if(A.targetLineValue||A.baseLineValue){L.push("#051a2e")}if(A.targetLineValue){L.push("#051a2e")}if(A.baseLineValue){L.push("#051a2e")}Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(N){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},N))}})};r=function(V){var R=30,Q=7,W,X=0,S="",N,U=false,P="top",T=0;if(A.type===k.finals.chart.pie){W=V.getCount();V.each(function(Y){S+=Y.data[V.domainFields[0]]})}else{W=V.rangeFields.length;for(var O=0,M,L;O<V.rangeFields.length;O++){if(V.rangeFields[O].indexOf("-")!==-1){L=V.rangeFields[O].split("-");M=u.metaData.names[L[0]]+" "+u.metaData.names[L[1]]}else{M=u.metaData.names[V.rangeFields[O]]}S+=M}}X=S.length;N=(W*R)+(X*Q);if(N>K.app.centerRegion.getWidth()-50){U=true;P="right"}if(P==="right"){T=5}return Ext.create("Ext.chart.Legend",{position:P,isVertical:U,labelFont:"13px "+k.chart.style.fontFamily,boxStroke:"#ffffff",boxStrokeWidth:0,padding:T})};F=function(M){var O=A.filterIds,L=[],Q="",P;if(A.type===k.finals.chart.pie){O=O.concat(A.columnIds)}if(Ext.isArray(O)&&O.length){for(var N=0;N<O.length;N++){Q+=u.metaData.names[O[N]];Q+=N<O.length-1?", ":""}}if(A.title){Q=A.title}P=(K.app.centerRegion.getWidth()/Q.length)<11.6?13:18;return Ext.create("Ext.draw.Sprite",{type:"text",text:Q,font:"bold "+P+"px "+k.chart.style.fontFamily,fill:"#111",height:20,y:20})};E=function(){return function(){this.animate=false;this.setWidth(K.app.centerRegion.getWidth()-15);this.setHeight(K.app.centerRegion.getHeight()-40);this.animate=true}};z=function(){return function(){if(this.items){var P=this.items[0],M=this.legend,O,L;if(this.legend.position==="top"){O=M.x+(M.width/2);L=O-(P.el.getWidth()/2)}else{var N=M?M.width:0;L=(this.width/2)-(P.el.getWidth()/2)}P.setAttributes({x:L},true)}}};y=function(L,Q,N,P){var O,M={store:L,axes:Q,series:N,animate:true,shadow:false,insetPadding:35,width:K.app.centerRegion.getWidth()-15,height:K.app.centerRegion.getHeight()-40,theme:P||"dv1"};if(!A.hideLegend){M.legend=r(L);if(M.legend.position==="right"){M.insetPadding=40}}if(!A.hideTitle){M.items=[F(L)]}else{M.insetPadding=10}O=Ext.create("Ext.chart.Chart",M);O.setChartSize=E();O.setTitlePosition=z();O.onViewportResize=function(){O.setChartSize();O.redraw();O.setTitlePosition()};O.on("afterrender",function(){O.setTitlePosition()});return O};p.column=function(){var L=t(),P=H(L),O=J(L),N=[P,O],M=[x(L)];if(A.showTrendLine){M=G(L).concat(M)}if(A.targetLineValue){M.push(C(L))}if(A.baseLineValue){M.push(I(L))}B(L);return y(L,N,M)};p.stackedcolumn=function(){var M=this.column();for(var L=0,N;L<M.series.items.length;L++){N=M.series.items[L];if(N.type===k.finals.chart.column){N.stacked=true}}return M};p.bar=function(){var T=t(),P=H(T),Q=J(T),S,O=x(T),L,M,U,R;P.position="bottom";Q.position="left";S=[P,Q];O.type="bar";O.axis="bottom";if(A.showValues){O.label={display:"outside","text-anchor":"middle",field:T.rangeFields}}O=[O];if(A.showTrendLine){L=G(T);for(var N=0;N<L.length;N++){L[N].axis="bottom";L[N].xField=T.trendLineFields[N];L[N].yField=T.domainFields}O=L.concat(O)}if(A.targetLineValue){M=C(T);M.axis="bottom";M.xField=T.targetLineFields;M.yField=T.domainFields;O.push(M)}if(A.baseLineValue){U=I(T);U.axis="bottom";U.xField=T.baseLineFields;U.yField=T.domainFields;O.push(U)}B(T);return y(T,S,O)};p.stackedbar=function(){var M=this.bar();for(var L=0,N;L<M.series.items.length;L++){N=M.series.items[L];if(N.type===k.finals.chart.bar){N.stacked=true}}return M};p.line=function(){var S=t(),O=H(S),P=J(S),Q=[O,P],M=[],L=k.chart.theme.dv1.slice(0,S.rangeFields.length),R=q(S);for(var N=0,T;N<S.rangeFields.length;N++){T={type:"line",axis:"left",xField:S.domainFields,yField:S.rangeFields[N],style:{opacity:0.8,lineWidth:3},markerConfig:{type:"circle",radius:4},tips:v(),title:R[N]};M.push(T)}if(A.showTrendLine){M=G(S).concat(M);L=L.concat(L)}if(A.targetLineValue){M.push(C(S));L.push("#051a2e")}if(A.baseLineValue){M.push(I(S));L.push("#051a2e")}Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(U){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},U))}});return y(S,Q,M)};p.area=function(){var L=t(),P=H(L),O=J(L),N=[P,O],M=x(L);M.type="area";M.style.opacity=0.7;M.style.lineWidth=0;delete M.label;delete M.tips;M=[M];if(A.showTrendLine){M=G(L).concat(M)}if(A.targetLineValue){M.push(C(L))}if(A.baseLineValue){M.push(I(L))}B(L);return y(L,N,M)};p.pie=function(){var M=t(),O,L,P,N={field:k.finals.data.domain};if(A.showValues){N.display="middle";N.contrast=true;N.font="14px "+k.chart.style.fontFamily;N.renderer=function(R){var Q=M.getAt(M.findExact(k.finals.data.domain,R));return Q.data[M.rangeFields[0]]}}O=[{type:"pie",field:M.rangeFields[0],donut:7,showInLegend:true,highlight:{segment:{margin:5}},label:N,style:{opacity:0.8,stroke:"#555"},tips:{trackMouse:true,cls:"dv-chart-tips",renderer:function(Q){this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">'+Q.data[M.rangeFields[0]]+'</div><div style="font-size:10px">'+Q.data[k.finals.data.domain]+"</div></div>")}}}];L=k.chart.theme.dv1.slice(0,u.nameHeaderMap[A.rowDimensionNames[0]].ids.length);Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(Q){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},Q))}});P=y(M,null,O);P.insetPadding=40;P.shadow=true;return P};p.radar=function(){var L=t(),R=[],O=[],N=q(L),P;R.push({type:"Radial",position:"radial",label:{display:true}});for(var M=0,Q;M<L.rangeFields.length;M++){Q={showInLegend:true,type:"radar",xField:L.domainFields,yField:L.rangeFields[M],style:{opacity:0.5},tips:v(),title:N[M]};if(A.showValues){Q.label={display:"over",field:L.rangeFields[M]}}O.push(Q)}P=y(L,R,O,"Category2");P.insetPadding=40;P.height=K.app.centerRegion.getHeight()-80;P.setChartSize=function(){this.animate=false;this.setWidth(K.app.centerRegion.getWidth());this.setHeight(K.app.centerRegion.getHeight()-80);this.animate=true};return P};return p[A.type]()}}());(function(){if(Ext.isArray(o.dimensions)){l.prototype.array.sort(o.dimensions);for(var p=0,q;p<o.dimensions.length;p++){q=o.dimensions[p];q.dimensionName=q.id;q.objectName=k.finals.dimension.dimension.objectName;k.finals.dimension.objectNameMap[q.id]=q}}l.prototype.array.sort(o.user.ouc)}());return{conf:k,api:m,support:l,service:i,web:j,init:o}};var d=".dv-chart-tips { border-radius: 2px; padding: 0px 3px 1px; border: 2px solid #000; background-color: #000; } \n";d+=".dv-chart-tips .x-tip-body { background-color: #000; font-size: 13px; font-weight: normal; color: #fff; -webkit-text-stroke: 0; } \n";d+=".dv-chart-tips .x-tip-body div { font-family: arial,sans-serif,ubuntu,consolas !important; } \n";d+=".x-mask-msg { padding: 0; \n border: 0 none; background-image: none; background-color: transparent; } \n";d+=".x-mask-msg div { background-position: 11px center; } \n";d+=".x-mask-msg .x-mask-loading { border: 0 none; \n background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n";Ext.util.CSS.createStyleSheet(d);DV.i18n={target:"Target",base:"Base",trend:"Trend"};DV.plugin={};var g={user:{}},f=[],h=false,c=false,a,e;a=function(j){var o=false,n=[],m=0,l;l=function(){if(++m===n.length){c=true;for(var p=0;p<f.length;p++){e(f[p])}f=[]}};n.push({url:j+"/api/system/context.jsonp",success:function(i){g.contextPath=i.contextPath;l()}});n.push({url:j+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(p){var i=p.organisationUnits[0];g.user.ou=i.id;g.user.ouc=Ext.Array.pluck(i.children,"id");l()}});n.push({url:j+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){g.legendSets=i.mapLegendSets;l()}});n.push({url:j+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){g.dimensions=i.dimensions;l()}});for(var k=0;k<n.length;k++){Ext.data.JsonP.request(n[k])}};e=function(l){var n,k,j,i,m={core:{},app:{}};n=function(o){if(!Ext.isObject(o)){console.log("Chart configuration is not an object");return}if(!Ext.isString(o.el)){console.log("No element id provided");return}o.id=o.id||o.uid;return true};k=function(s){var t=s.core.init,r=s.core.api,q=s.core.support,o=s.core.service,p=s.core.web;t.el=l.el;p.chart=p.chart||{};p.chart.loadChart=function(u){if(!Ext.isString(u)){alert("Invalid chart id");return}Ext.data.JsonP.request({url:t.contextPath+"/api/charts/"+u+".jsonp?viewClass=dimensional&links=false",failure:function(v){window.open(t.contextPath+"/api/charts/"+u+".json?viewClass=dimensional&links=false","_blank")},success:function(w){var v=r.layout.Layout(w);if(v){p.chart.getData(v,true)}}})};p.chart.getData=function(v,w){var u,x;if(!v){return}u=o.layout.getExtendedLayout(v);x=p.analytics.getParamString(u,true);p.mask.show(s.app.centerRegion);Ext.data.JsonP.request({url:t.contextPath+"/api/analytics.jsonp"+x,timeout:60000,headers:{"Content-Type":"application/json",Accepts:"application/json"},disableCaching:false,failure:function(y){p.mask.hide(s.app.centerRegion);window.open(t.contextPath+"/api/analytics.json"+x,"_blank")},success:function(z){var y=r.response.Response(z);if(!y){p.mask.hide(s.app.centerRegion);return}u=o.layout.getSyncronizedXLayout(u,y);if(!u){p.mask.hide(s.app.centerRegion);return}s.app.paramString=x;p.chart.getChart(v,u,y,w)}})};p.chart.getChart=function(z,w,v,A){var B,y,u,x;if(!w){w=o.layout.getExtendedLayout(z)}B=o.response.getExtendedResponse(w,v);s.app.layout=z;s.app.xLayout=w;s.app.response=v;s.app.xResponse=B;s.app.chart=s.core.web.chart.createChart(s);s.app.centerRegion.removeAll();s.app.centerRegion.add(s.app.chart);p.mask.hide(s.app.centerRegion)}};j=function(){var r=Ext.get(m.core.init.el),u,o,v=parseInt(r.getStyle("border-left-width"))+parseInt(r.getStyle("border-right-width")),s=parseInt(r.getStyle("border-top-width"))+parseInt(r.getStyle("border-bottom-width")),t=parseInt(r.getStyle("padding-left"))+parseInt(r.getStyle("padding-right")),p=parseInt(r.getStyle("padding-top"))+parseInt(r.getStyle("padding-bottom")),q=r.getWidth()-v-t,w=r.getHeight()-s-p;o=Ext.create("Ext.panel.Panel",{renderTo:r,bodyStyle:"border: 0 none",width:l.width||q,height:l.height||w,layout:"fit"});return{centerRegion:o}};i=function(){if(!n(l)){return}m.core=DV.getCore(Ext.clone(g));k(m);m.app.viewport=j();m.app.centerRegion=m.app.viewport.centerRegion;if(l.id){m.core.web.chart.loadChart(l.id)}else{layout=m.core.api.layout.Layout(l);if(!layout){return}m.core.web.chart.getData(layout)}}()};DV.plugin.getChart=function(i){if(Ext.isString(i.url)&&i.url.split("").pop()==="/"){i.url=i.url.substr(0,i.url.length-1)}if(c){e(i)}else{f.push(i);if(!h){h=true;a(i.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getChart=DV.plugin.getChart});
+Ext.onReady(function(){function b(){var o=0;var l=0;var j=0;var i=0;var p=0;var m=0;var k=0;this.addData=function(n,s){if(p==0){m=n;k=s}else{var r=n-m;var q=s-k;j+=r*r*p/(p+1);i+=r*q*p/(p+1);m+=r/(p+1);k+=q/(p+1)}o+=n;l+=s;p++};this.predict=function(n){var q=this.getSlope();return this.getIntercept(q)+q*n};this.getSlope=function(){if(p<2){return Number.NaN}return i/j};this.getIntercept=function(n){return(l-n*o)/p}}Ext.Ajax.method="GET";DV={};DV.instances=[];DV.i18n={};DV.isDebug=false;DV.isSessionStorage=("sessionStorage" in window&&window.sessionStorage!==null);DV.getCore=function(o){var k={},m={},l={},i={},j={},n;(function(){k.finals={ajax:{path_module:"/dhis-web-visualizer/",path_api:"/api/",path_commons:"/dhis-web-commons-ajax-json/",data_get:"chartValues.json",indicator_get:"indicatorGroups/",indicator_getall:"indicators.json?paging=false&links=false",indicatorgroup_get:"indicatorGroups.json?paging=false&links=false",dataelement_get:"dataElementGroups/",dataelement_getall:"dataElements.json?domainType=aggregate&paging=false&links=false",dataelementgroup_get:"dataElementGroups.json?paging=false&links=false",dataset_get:"dataSets.json?paging=false&links=false"},dimension:{data:{value:"data",name:DV.i18n.data,dimensionName:"dx",objectName:"dx"},indicator:{value:"indicator",name:DV.i18n.indicator,dimensionName:"dx",objectName:"in"},dataElement:{value:"dataelement",name:DV.i18n.data_element,dimensionName:"dx",objectName:"de"},operand:{value:"operand",name:"Operand",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataset",name:DV.i18n.dataset,dimensionName:"dx",objectName:"ds"},category:{name:DV.i18n.categories,dimensionName:"co",objectName:"co"},period:{value:"period",name:DV.i18n.period,dimensionName:"pe",objectName:"pe"},fixedPeriod:{value:"periods"},relativePeriod:{value:"relativePeriods"},organisationUnit:{value:"organisationUnits",name:DV.i18n.organisation_units,dimensionName:"ou",objectName:"ou"},dimension:{value:"dimension"},value:{value:"value"}},chart:{series:"series",category:"category",filter:"filter",column:"column",stackedcolumn:"stackedcolumn",bar:"bar",stackedbar:"stackedbar",line:"line",area:"area",pie:"pie",radar:"radar"},data:{domain:"domain_",targetLine:"targetline_",baseLine:"baseline_",trendLine:"trendline_"},image:{png:"png",pdf:"pdf"},cmd:{init:"init_",none:"none_",urlparam:"id"},root:{id:"root"}};n=k.finals.dimension;n.objectNameMap={};n.objectNameMap[n.data.objectName]=n.data;n.objectNameMap[n.indicator.objectName]=n.indicator;n.objectNameMap[n.dataElement.objectName]=n.dataElement;n.objectNameMap[n.operand.objectName]=n.operand;n.objectNameMap[n.dataSet.objectName]=n.dataSet;n.objectNameMap[n.category.objectName]=n.category;n.objectNameMap[n.period.objectName]=n.period;n.objectNameMap[n.organisationUnit.objectName]=n.organisationUnit;n.objectNameMap[n.dimension.objectName]=n.dimension;k.period={periodTypes:[{id:"Daily",name:DV.i18n.daily},{id:"Weekly",name:DV.i18n.weekly},{id:"Monthly",name:DV.i18n.monthly},{id:"BiMonthly",name:DV.i18n.bimonthly},{id:"Quarterly",name:DV.i18n.quarterly},{id:"SixMonthly",name:DV.i18n.sixmonthly},{id:"SixMonthlyApril",name:DV.i18n.sixmonthly_april},{id:"Yearly",name:DV.i18n.yearly},{id:"FinancialOct",name:DV.i18n.financial_oct},{id:"FinancialJuly",name:DV.i18n.financial_july},{id:"FinancialApril",name:DV.i18n.financial_april}]};k.layout={west_width:424,west_fieldset_width:416,west_width_padding:4,west_fill:2,west_fill_accordion_indicator:59,west_fill_accordion_dataelement:59,west_fill_accordion_dataset:33,west_fill_accordion_period:296,west_fill_accordion_organisationunit:62,west_maxheight_accordion_indicator:350,west_maxheight_accordion_dataelement:350,west_maxheight_accordion_dataset:350,west_maxheight_accordion_period:513,west_maxheight_accordion_organisationunit:500,west_maxheight_accordion_group:350,west_scrollbarheight_accordion_indicator:300,west_scrollbarheight_accordion_dataelement:300,west_scrollbarheight_accordion_dataset:300,west_scrollbarheight_accordion_period:450,west_scrollbarheight_accordion_organisationunit:450,west_scrollbarheight_accordion_group:300,east_tbar_height:31,east_gridcolumn_height:30,form_label_width:55,window_favorite_ypos:100,window_confirm_width:250,window_share_width:500,grid_favorite_width:420,grid_row_height:27,treepanel_minheight:135,treepanel_maxheight:400,treepanel_fill_default:310,treepanel_toolbar_menu_width_group:140,treepanel_toolbar_menu_width_level:120,multiselect_minheight:100,multiselect_maxheight:250,multiselect_fill_default:345,multiselect_fill_reportingrates:315};k.chart={style:{inset:30,fontFamily:"Arial,Sans-serif,Lucida Grande,Ubuntu"},theme:{dv1:["#94ae0a","#0b3b68","#a61120","#ff8809","#7c7474","#a61187","#ffd13e","#24ad9a","#a66111","#414141","#4500c4","#1d5700"]}};k.status={icon:{error:"error_s.png",warning:"warning.png",ok:"ok.png"}}}());(function(){m.layout={};m.layout.Record=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Record: config is not an object: "+p);return}if(!Ext.isString(p.id)){alert("Record: id is not text: "+p);return}p.id=p.id.replace(".","-");return p}()};m.layout.Dimension=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Dimension: config is not an object: "+p);return}if(!Ext.isString(p.dimension)){console.log("Dimension: name is not a string: "+p);return}if(p.dimension!==k.finals.dimension.category.objectName){var q=[];if(!Ext.isArray(p.items)){console.log("Dimension: items is not an array: "+p);return}for(var r=0;r<p.items.length;r++){q.push(m.layout.Record(p.items[r]))}p.items=Ext.Array.clean(q);if(!p.items.length){console.log("Dimension: has no valid items: "+p);return}}return p}()};m.layout.Layout=function(q){var q=Ext.clone(q),r={},p,s;p=function(u){var u=Ext.clone(u);if(!(u&&Ext.isArray(u)&&u.length)){return}for(var t=0;t<u.length;t++){u[t]=m.layout.Dimension(u[t])}u=Ext.Array.clean(u);return u.length?u:null};analytical2layout=function(u){var w=Ext.clone(u),x=n.category.objectName;u=Ext.clone(u);w.columns=[];w.rows=[];w.filters=w.filters||[];if(Ext.isArray(u.columns)&&u.columns.length){u.columns.reverse();for(var t=0,v;t<u.columns.length;t++){v=u.columns[t];if(v.dimension===x){continue}if(!w.columns.length){w.columns.push(v)}else{if(v.dimension===n.indicator.objectName){w.filters.push(w.columns.pop());w.columns=[v]}else{w.filters.push(v)}}}}if(Ext.isArray(u.rows)&&u.rows.length){u.rows.reverse();for(var t=0,v;t<u.rows.length;t++){v=u.rows[t];if(v.dimension===x){continue}if(!w.rows.length){w.rows.push(v)}else{if(v.dimension===n.indicator.objectName){w.filters.push(w.rows.pop());w.rows=[v]}else{w.filters.push(v)}}}}return w};s=function(){var v=k.finals.dimension,u,w={};if(!r){return}u=Ext.Array.clean([].concat(r.columns||[],r.rows||[],r.filters||[]));for(var t=0;t<u.length;t++){w[u[t].dimension]=u[t]}if(r.filters&&r.filters.length){for(var t=0;t<r.filters.length;t++){if(r.filters[t].dimension===v.indicator.objectName){j.message.alert(DV.i18n.indicators_cannot_be_specified_as_filter||"Indicators cannot be specified as filter");return}if(r.filters[t].dimension===v.category.objectName){j.message.alert(DV.i18n.categories_cannot_be_specified_as_filter||"Categories cannot be specified as filter");return}if(r.filters[t].dimension===v.dataSet.objectName){j.message.alert(DV.i18n.data_sets_cannot_be_specified_as_filter||"Data sets cannot be specified as filter");return}}}if(w[v.operand.objectName]&&w[v.indicator.objectName]){j.message.alert("Indicators and detailed data elements cannot be specified together");return}if(w[v.operand.objectName]&&w[v.dataElement.objectName]){j.message.alert("Detailed data elements and totals cannot be specified together");return}if(w[v.operand.objectName]&&w[v.dataSet.objectName]){j.message.alert("Data sets and detailed data elements cannot be specified together");return}if(w[v.operand.objectName]&&w[v.category.objectName]){j.message.alert("Categories and detailed data elements cannot be specified together");return}return true};return function(){var t=[],v=k.finals.dimension;if(!(q&&Ext.isObject(q))){alert("Layout: config is not an object ("+o.el+")");return}q.columns=p(q.columns);q.rows=p(q.rows);q.filters=p(q.filters);if(!q.columns){alert("No series items selected");return}if(!q.rows){alert("No category items selected");return}for(var u=0,w=Ext.Array.clean([].concat(q.columns||[],q.rows||[],q.filters||[]));u<w.length;u++){if(m.layout.Dimension(w[u])){t.push(w[u].dimension)}}if(!Ext.Array.contains(t,v.period.objectName)){alert("At least one period must be specified as series, category or filter");return}if(q.id){r.id=q.id}if(q.name){r.name=q.name}q=analytical2layout(q);r.type=Ext.isString(q.type)?q.type.toLowerCase():k.finals.chart.column;r.columns=q.columns;r.rows=q.rows;r.filters=q.filters;r.showTrendLine=Ext.isBoolean(q.regression)?q.regression:(Ext.isBoolean(q.showTrendLine)?q.showTrendLine:false);r.showValues=Ext.isBoolean(q.showData)?q.showData:(Ext.isBoolean(q.showValues)?q.showValues:true);r.hideLegend=Ext.isBoolean(q.hideLegend)?q.hideLegend:false;r.hideTitle=Ext.isBoolean(q.hideTitle)?q.hideTitle:false;r.targetLineValue=Ext.isNumber(q.targetLineValue)?q.targetLineValue:null;r.targetLineTitle=Ext.isString(q.targetLineLabel)&&!Ext.isEmpty(q.targetLineLabel)?q.targetLineLabel:(Ext.isString(q.targetLineTitle)&&!Ext.isEmpty(q.targetLineTitle)?q.targetLineTitle:null);r.baseLineValue=Ext.isNumber(q.baseLineValue)?q.baseLineValue:null;r.baseLineTitle=Ext.isString(q.baseLineLabel)&&!Ext.isEmpty(q.baseLineLabel)?q.baseLineLabel:(Ext.isString(q.baseLineTitle)&&!Ext.isEmpty(q.baseLineTitle)?q.baseLineTitle:null);r.title=Ext.isString(q.title)&&!Ext.isEmpty(q.title)?q.title:null;r.domainAxisTitle=Ext.isString(q.domainAxisLabel)&&!Ext.isEmpty(q.domainAxisLabel)?q.domainAxisLabel:(Ext.isString(q.domainAxisTitle)&&!Ext.isEmpty(q.domainAxisTitle)?q.domainAxisTitle:null);r.rangeAxisTitle=Ext.isString(q.rangeAxisLabel)&&!Ext.isEmpty(q.rangeAxisLabel)?q.rangeAxisLabel:(Ext.isString(q.rangeAxisTitle)&&!Ext.isEmpty(q.rangeAxisTitle)?q.rangeAxisTitle:null);r.parentGraphMap=Ext.isObject(q.parentGraphMap)?q.parentGraphMap:null;if(!s()){return}return r}()};m.response={};m.response.Header=function(p){var p=Ext.clone(p);return function(){if(!Ext.isObject(p)){console.log("Header: config is not an object: "+p);return}if(!Ext.isString(p.name)){console.log("Header: name is not a string: "+p);return}if(!Ext.isBoolean(p.meta)){console.log("Header: meta is not boolean: "+p);return}return p}()};m.response.Response=function(p){var p=Ext.clone(p);return function(){if(!(p&&Ext.isObject(p))){console.log("Response: config is not an object");return}if(!(p.headers&&Ext.isArray(p.headers))){console.log("Response: headers is not an array");return}for(var q=0,r;q<p.headers.length;q++){p.headers[q]=m.response.Header(p.headers[q])}p.headers=Ext.Array.clean(p.headers);if(!p.headers.length){console.log("Response: no valid headers");return}if(!(Ext.isArray(p.rows)&&p.rows.length>0)){alert("No values found");return}if(p.headers.length!==p.rows[0].length){console.log("Response: headers.length !== rows[0].length")}return p}()}}());(function(){l.prototype={};l.prototype.array={};l.prototype.array.getLength=function(q,p){if(!Ext.isArray(q)){if(!p){console.log("support.prototype.array.getLength: not an array")}return null}return q.length};l.prototype.array.sort=function(r,q,p){if(!l.prototype.array.getLength(r)){return}p=p||"name";r.sort(function(t,s){if(Ext.isObject(t)&&Ext.isObject(s)&&p){t=t[p];s=s[p]}if(Ext.isString(t)&&Ext.isString(s)){t=t.toLowerCase();s=s.toLowerCase();if(q==="DESC"){return t<s?1:(t>s?-1:0)}else{return t<s?-1:(t>s?1:0)}}else{if(Ext.isNumber(t)&&Ext.isNumber(s)){return q==="DESC"?s-t:t-s}}return 0});return r};l.prototype.object={};l.prototype.object.getLength=function(p,s){if(!Ext.isObject(p)){if(!s){console.log("support.prototype.object.getLength: not an object")}return null}var r=0;for(var q in p){if(p.hasOwnProperty(q)){r++}}return r};l.prototype.object.hasObject=function(q,t,s){if(!l.prototype.object.getLength(q)){return null}for(var r in q){var p=q[r];if(q.hasOwnProperty(r)&&p[t]===s){return true}}return null};l.prototype.str={};l.prototype.str.replaceAll=function(r,q,p){return r.replace(new RegExp(q,"g"),p)}}());(function(){i.layout={};i.layout.cleanDimensionArray=function(q){if(!l.prototype.array.getLength(q)){return null}var r=[];for(var p=0;p<q.length;p++){r.push(m.layout.Dimension(q[p]))}r=Ext.Array.clean(r);return r.length?r:null};i.layout.sortDimensionArray=function(s,r){if(!l.prototype.array.getLength(s,true)){return null}s=i.layout.cleanDimensionArray(s);if(!s){console.log("service.layout.sortDimensionArray: no valid dimensions");return null}r=r||"dimensionName";Ext.Array.sort(s,function(u,t){if(u[r]<t[r]){return -1}if(u[r]>t[r]){return 1}return 0});for(var q=0,p;q<s.length;q++){l.prototype.array.sort(s[q].items,"ASC","id");if(l.prototype.array.getLength(s[q].ids)){l.prototype.array.sort(s[q].ids)}}return s};i.layout.getObjectNameDimensionMapFromDimensionArray=function(s){var r={};if(!l.prototype.array.getLength(s)){return null}for(var p=0,q;p<s.length;p++){q=m.layout.Dimension(s[p]);if(q){r[q.dimension]=q}}return l.prototype.object.getLength(r)?r:null};i.layout.getObjectNameDimensionItemsMapFromDimensionArray=function(s){var r={};if(!l.prototype.array.getLength(s)){return null}for(var p=0,q;p<s.length;p++){q=m.layout.Dimension(s[p]);if(q){r[q.dimension]=q.items}}return l.prototype.object.getLength(r)?r:null};i.layout.getExtendedLayout=function(u){var u=Ext.clone(u),w={columns:[],rows:[],filters:[],columnObjectNames:[],columnDimensionNames:[],columnItems:[],columnIds:[],rowObjectNames:[],rowDimensionNames:[],rowItems:[],rowIds:[],axisDimensions:[],axisObjectNames:[],axisDimensionNames:[],sortedAxisDimensionNames:[],filterDimensions:[],filterObjectNames:[],filterDimensionNames:[],filterItems:[],filterIds:[],sortedFilterDimensions:[],dimensions:[],objectNames:[],dimensionNames:[],objectNameDimensionsMap:{},objectNameItemsMap:{},objectNameIdsMap:{},dimensionNameDimensionsMap:{},dimensionNameItemsMap:{},dimensionNameIdsMap:{},dimensionNameSortedIdsMap:{}};Ext.applyIf(w,u);if(u.columns){for(var s=0,t,v,p;s<u.columns.length;s++){t=u.columns[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.columns.push(p);w.columnObjectNames.push(p.objectName);w.columnDimensionNames.push(p.dimensionName);w.columnItems=w.columnItems.concat(p.items);w.columnIds=w.columnIds.concat(p.ids);w.axisDimensions.push(p);w.axisObjectNames.push(p.objectName);w.axisDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}if(u.rows){for(var s=0,t,v,p;s<u.rows.length;s++){t=u.rows[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.rows.push(p);w.rowObjectNames.push(p.objectName);w.rowDimensionNames.push(p.dimensionName);w.rowItems=w.rowItems.concat(p.items);w.rowIds=w.rowIds.concat(p.ids);w.axisDimensions.push(p);w.axisObjectNames.push(p.objectName);w.axisDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}if(u.filters){for(var s=0,t,v,p;s<u.filters.length;s++){t=u.filters[s];v=t.items;p={};p.dimension=t.dimension;p.objectName=t.dimension;p.dimensionName=n.objectNameMap[t.dimension].dimensionName;if(v){p.items=v;p.ids=[];for(var r=0;r<v.length;r++){p.ids.push(v[r].id)}}w.filters.push(p);w.filterDimensions.push(p);w.filterObjectNames.push(p.objectName);w.filterDimensionNames.push(n.objectNameMap[p.objectName].dimensionName);w.filterItems=w.filterItems.concat(p.items);w.filterIds=w.filterIds.concat(p.ids);w.objectNameDimensionsMap[p.objectName]=p;w.objectNameItemsMap[p.objectName]=p.items;w.objectNameIdsMap[p.objectName]=p.ids}}w.axisDimensionNames=Ext.Array.unique(w.axisDimensionNames);w.filterDimensionNames=Ext.Array.unique(w.filterDimensionNames);w.columnDimensionNames=Ext.Array.unique(w.columnDimensionNames);w.rowDimensionNames=Ext.Array.unique(w.rowDimensionNames);w.filterDimensionNames=Ext.Array.unique(w.filterDimensionNames);w.sortedAxisDimensionNames=Ext.clone(w.axisDimensionNames).sort();w.sortedFilterDimensions=i.layout.sortDimensionArray(Ext.clone(w.filterDimensions));w.dimensions=[].concat(w.axisDimensions,w.filterDimensions);w.objectNames=[].concat(w.axisObjectNames,w.filterObjectNames);w.dimensionNames=[].concat(w.axisDimensionNames,w.filterDimensionNames);for(var s=0,q;s<w.dimensionNames.length;s++){q=w.dimensionNames[s];w.dimensionNameDimensionsMap[q]=[];w.dimensionNameItemsMap[q]=[];w.dimensionNameIdsMap[q]=[]}for(var s=0,p;s<w.dimensions.length;s++){p=w.dimensions[s];w.dimensionNameDimensionsMap[p.dimensionName].push(p);w.dimensionNameItemsMap[p.dimensionName]=w.dimensionNameItemsMap[p.dimensionName].concat(p.items);w.dimensionNameIdsMap[p.dimensionName]=w.dimensionNameIdsMap[p.dimensionName].concat(p.ids)}for(var x in w.dimensionNameIdsMap){if(w.dimensionNameIdsMap.hasOwnProperty(x)){w.dimensionNameSortedIdsMap[x]=Ext.clone(w.dimensionNameIdsMap[x]).sort()}}return w};i.layout.getSyncronizedXLayout=function(z,p){var t=Ext.Array.clean([].concat(z.columns||[],z.rows||[],z.filters||[])),L=z.objectNameDimensionsMap[n.organisationUnit.objectName],w=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT"),N=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT_CHILDREN"),K=L&&Ext.Array.contains(L.ids,"USER_ORGUNIT_GRANDCHILDREN"),q=function(){if(L&&Ext.isArray(L.ids)){for(var P=0;P<L.ids.length;P++){if(L.ids[P].substr(0,5)==="LEVEL"){return true}}}return false}(),y=function(){if(L&&Ext.isArray(L.ids)){for(var P=0;P<L.ids.length;P++){if(L.ids[P].substr(0,8)==="OU_GROUP"){return true}}}return false}(),s=n.organisationUnit.objectName,O;for(var H=0,F,x,A;H<t.length;H++){F=t[H];F.items=[];x=p.metaData[F.objectName];if(F.dimensionName===s){if(w||N||K){var J,v,C;if(w){J=[{id:o.user.ou,name:p.metaData.names[o.user.ou]}]}if(N){v=[];for(var E=0;E<o.user.ouc.length;E++){v.push({id:o.user.ouc[E],name:p.metaData.names[o.user.ouc[E]]})}l.prototype.array.sort(v)}if(K){var r=[].concat(o.user.ou,o.user.ouc),u=p.metaData[s];C=[];for(var E=0,B;E<u.length;E++){B=u[E];if(!Ext.Array.contains(r,B)){C.push({id:B,name:p.metaData.names[B]})}}l.prototype.array.sort(C)}F.items=[].concat(J||[],v||[],C||[])}else{if(q||y){for(var E=0,u=p.metaData[s],B;E<u.length;E++){B=u[E];F.items.push({id:B,name:p.metaData.names[B]})}l.prototype.array.sort(F.items)}else{F.items=Ext.clone(z.dimensionNameItemsMap[F.dimensionName])}}}else{if(Ext.isArray(x)&&x.length){var D=Ext.clone(p.metaData[F.dimensionName]);for(var E=0;E<D.length;E++){F.items.push({id:D[E],name:p.metaData.names[D[E]]})}}else{F.items=Ext.clone(z.objectNameItemsMap[F.objectName])}}}O=m.layout.Layout(z);if(O){t=Ext.Array.clean([].concat(O.columns||[],O.rows||[],O.filters||[]));for(var H=0,G=p.metaData.names,I;H<t.length;H++){I=t[H].items;if(Ext.isArray(I)&&I.length){for(var E=0,M;E<I.length;E++){M=I[E];if(Ext.isObject(M)&&Ext.isString(G[M.id])&&!Ext.isString(M.name)){M.name=G[M.id]||""}}}}return i.layout.getExtendedLayout(O)}return null};i.layout.layout2plugin=function(t){var t=Ext.clone(t),s=Ext.Array.clean([].concat(t.columns||[],t.rows||[],t.filters||[]));if(Ext.isString(t.id)){return{id:t.id}}for(var q=0,u,r;q<s.length;q++){u=s[q];delete u.id;delete u.ids;delete u.type;delete u.dimensionName;delete u.objectName;for(var p=0,r;p<u.items.length;p++){r=u.items[p];delete r.name;delete r.code;delete r.created;delete r.lastUpdated}}if(!t.showTrendLine){delete t.showTrendLine}if(!t.targetLineValue){delete t.targetLineValue}if(!t.targetLineTitle){delete t.targetLineTitle}if(!t.baseLineValue){delete t.baseLineValue}if(!t.baseLineTitle){delete t.baseLineTitle}if(t.showValues){delete t.showValues}if(!t.hideLegend){delete t.hideLegend}if(!t.hideTitle){delete t.hideTitle}if(!t.title){delete t.title}if(!t.domainAxisTitle){delete t.domainAxisTitle}if(!t.rangeAxisTitle){delete t.rangeAxisTitle}if(!t.sorting){delete t.sorting}delete t.parentGraphMap;delete t.reportingPeriod;delete t.organisationUnit;delete t.parentOrganisationUnit;delete t.regression;delete t.cumulative;delete t.sortOrder;delete t.topLimit;return t};i.response={};i.response.getExtendedResponse=function(q,p){var r=[];p.nameHeaderMap={};p.idValueMap={};(function(){for(var s=0,t;s<p.headers.length;s++){t=p.headers[s];t.index=s;if(t.meta){t.ids=Ext.clone(q.dimensionNameIdsMap[t.name])||[];t.size=t.ids.length;r=r.concat(t.ids)}}for(var s=0,t;s<p.headers.length;s++){t=p.headers[s];p.nameHeaderMap[t.name]=t}}());(function(){for(var s=0,u,t;s<r.length;s++){u=r[s];if(u.indexOf("-")!==-1){t=u.split("-");p.metaData.names[u]=p.metaData.names[t[0]]+" "+p.metaData.names[t[1]]}}}());(function(){var x=p.nameHeaderMap[k.finals.dimension.value.value].index,t=p.nameHeaderMap[k.finals.dimension.category.dimensionName],B=n.data.dimensionName,y=n.category.dimensionName,v=q.axisDimensionNames,z=[];for(var w=0;w<v.length;w++){z.push(p.nameHeaderMap[v[w]].index);if(t&&!Ext.Array.contains(v,y)&&v[w]===B){z.push(t.index)}}for(var w=0,A,s;w<p.rows.length;w++){A=p.rows[w];s="";for(var u=0;u<z.length;u++){s+=A[z[u]]}p.idValueMap[s]=A[x]}}());return p}}());(function(){j.mask={};j.mask.show=function(p,q){if(!Ext.isObject(p)){console.log("support.gui.mask.show: component not an object");return null}q=q||"Loading..";if(p.mask){p.mask.destroy();p.mask=null}p.mask=new Ext.create("Ext.LoadMask",p,{shadow:false,message:q,style:"box-shadow:0",bodyStyle:"box-shadow:0"});p.mask.show()};j.mask.hide=function(p){if(!Ext.isObject(p)){console.log("support.gui.mask.hide: component not an object");return null}if(p.mask){p.mask.destroy();p.mask=null}};j.message={};j.message.alert=function(p){console.log(p)};j.analytics={};j.analytics.getParamString=function(B,s){var w=s?B.sortedAxisDimensionNames:B.axisDimensionNames,C=s?B.sortedFilterDimensions:B.filterDimensions,p=s?B.dimensionNameSortedIdsMap:B.dimensionNameIdsMap,t="?",r=false,q=B.dimensionNameItemsMap,D=n.indicator.dimensionName;for(var x=0,u,A;x<w.length;x++){u=w[x];t+="dimension="+u;A=Ext.clone(p[u]);if(u===D){for(var v=0,z;v<A.length;v++){z=A[v].indexOf("-");if(z>0){r=true;A[v]=A[v].substr(0,z)}}A=Ext.Array.unique(A)}if(u!==n.category.dimensionName){t+=":"+A.join(";")}if(x<(w.length-1)){t+="&"}}if(r){t+="&dimension="+k.finals.dimension.category.dimensionName}if(Ext.isArray(C)&&C.length){for(var x=0,y;x<C.length;x++){y=C[x];t+="&filter="+y.dimensionName+":"+y.ids.join(";")}}return t};j.analytics.validateUrl=function(q){var r;if(Ext.isIE){r="Too many items selected (url has "+q.length+" characters). Internet Explorer accepts maximum 2048 characters."}else{var p=q.length>8000?"8000":(q.length>4000?"4000":"2000");r="Too many items selected (url has "+q.length+" characters). Please reduce to less than "+p+" characters."}r+="\n\nHint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.";alert(r)};j.chart={};j.chart.createChart=function(K){var u=K.app.xResponse,A=K.app.xLayout,w,s,D,t,H,J,q,x,G,C,I,v,B,r,F,E,z,y,p={};t=function(){var X=k.finals.dimension.period.dimensionName,N=A.columns[0].dimensionName,O=A.rows[0].dimensionName,V=[],W=A.columnIds,R=A.rowIds,ab=[],Z=[],Q=[],Y;for(var U=0,T,M;U<R.length;U++){T={};M=R[U];T[k.finals.data.domain]=u.metaData.names[M];for(var S=0,L;S<W.length;S++){L=l.prototype.str.replaceAll(W[S],"-","")+l.prototype.str.replaceAll(R[U],"-","");T[W[S]]=parseFloat(u.idValueMap[L])}V.push(T)}if(A.showTrendLine){for(var U=0,P,aa;U<W.length;U++){P=new b();aa=k.finals.data.trendLine+W[U];for(var S=0;S<V.length;S++){P.addData(S,V[S][W[U]])}for(var S=0;S<V.length;S++){V[S][aa]=parseFloat(P.predict(S).toFixed(1))}ab.push(aa);u.metaData.names[aa]=DV.i18n.trend+" ("+u.metaData.names[W[U]]+")"}}if(Ext.isNumber(A.targetLineValue)||Ext.isNumber(parseFloat(A.targetLineValue))){for(var U=0;U<V.length;U++){V[U][k.finals.data.targetLine]=parseFloat(A.targetLineValue)}Z.push(k.finals.data.targetLine)}if(Ext.isNumber(A.baseLineValue)||Ext.isNumber(parseFloat(A.baseLineValue))){for(var U=0;U<V.length;U++){V[U][k.finals.data.baseLine]=parseFloat(A.baseLineValue)}Q.push(k.finals.data.baseLine)}Y=Ext.create("Ext.data.Store",{fields:function(){var ac=Ext.clone(W);ac.push(k.finals.data.domain);ac=ac.concat(ab,Z,Q);return ac}(),data:V});Y.rangeFields=W;Y.domainFields=[k.finals.data.domain];Y.trendLineFields=ab;Y.targetLineFields=Z;Y.baseLineFields=Q;Y.numericFields=[].concat(Y.rangeFields,Y.trendLineFields,Y.targetLineFields,Y.baseLineFields);Y.getMaximum=function(){var ad=[];for(var ac=0;ac<Y.numericFields.length;ac++){ad.push(Y.max(Y.numericFields[ac]))}return Ext.Array.max(ad)};Y.getMinimum=function(){var ad=[];for(var ac=0;ac<Y.numericFields.length;ac++){ad.push(Y.max(Y.numericFields[ac]))}return Ext.Array.min(ad)};Y.getMaximumSum=function(){var ad=[],ac=0;Y.each(function(ae){ac=0;for(var af=0;af<Y.rangeFields.length;af++){ac+=ae.data[Y.rangeFields[af]]}ad.push(ac)});return Ext.Array.max(ad)};if(DV.isDebug){console.log("data",V);console.log("rangeFields",Y.rangeFields);console.log("domainFields",Y.domainFields);console.log("trendLineFields",Y.trendLineFields);console.log("targetLineFields",Y.targetLineFields);console.log("baseLineFields",Y.baseLineFields)}return Y};H=function(N){var M=k.finals.chart,P=N.getMinimum(),Q,O;if((A.type===M.stackedcolumn||A.type===M.stackedbar)&&(A.showTrendLine||A.targetLineValue||A.baseLineValue)){var L=[N.getMaximum(),N.getMaximumSum()];Q=Math.ceil(Ext.Array.max(L)*1.1);Q=Math.floor(Q/10)*10}O={type:"Numeric",position:"left",fields:N.numericFields,minimum:P<0?P:0,label:{renderer:Ext.util.Format.numberRenderer("0,0")},grid:{odd:{opacity:1,stroke:"#aaa","stroke-width":0.1},even:{opacity:1,stroke:"#aaa","stroke-width":0.1}}};if(Q){O.maximum=Q}if(A.rangeAxisTitle){O.title=A.rangeAxisTitle}return O};J=function(L){var M={type:"Category",position:"bottom",fields:L.domainFields,label:{rotate:{degrees:330}}};if(A.domainAxisTitle){M.title=A.domainAxisTitle}return M};q=function(M){var L=[];for(var N=0,P,O;N<M.rangeFields.length;N++){P=M.rangeFields[N];L.push(u.metaData.names[P])}return L};x=function(M){var L={type:"column",axis:"left",xField:M.domainFields,yField:M.rangeFields,style:{opacity:0.8,lineWidth:3},markerConfig:{type:"circle",radius:4},tips:v(),title:q(M)};if(A.showValues){L.label={display:"outside","text-anchor":"middle",field:M.rangeFields,font:k.chart.style.fontFamily}}return L};G=function(M){var L=[];for(var N=0;N<M.trendLineFields.length;N++){L.push({type:"line",axis:"left",xField:M.domainFields,yField:M.trendLineFields[N],style:{opacity:0.8,lineWidth:3,"stroke-dasharray":8},markerConfig:{type:"circle",radius:0},title:u.metaData.names[M.trendLineFields[N]]})}return L};C=function(L){return{type:"line",axis:"left",xField:L.domainFields,yField:L.targetLineFields,style:{opacity:1,lineWidth:2,"stroke-width":1,stroke:"#041423"},showMarkers:false,title:(Ext.isString(A.targetLineTitle)?A.targetLineTitle:DV.i18n.target)+" ("+A.targetLineValue+")"}};I=function(L){return{type:"line",axis:"left",xField:L.domainFields,yField:L.baseLineFields,style:{opacity:1,lineWidth:2,"stroke-width":1,stroke:"#041423"},showMarkers:false,title:(Ext.isString(A.baseLineTitle)?A.baseLineTitle:DV.i18n.base)+" ("+A.baseLineValue+")"}};v=function(){return{trackMouse:true,cls:"dv-chart-tips",renderer:function(L,M){this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">'+M.value[1]+'</div><div style="font-size:10px">'+L.data[k.finals.data.domain]+"</div></div>")}}};B=function(M){var L=k.chart.theme.dv1.slice(0,M.rangeFields.length);if(A.targetLineValue||A.baseLineValue){L.push("#051a2e")}if(A.targetLineValue){L.push("#051a2e")}if(A.baseLineValue){L.push("#051a2e")}Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(N){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},N))}})};r=function(V){var R=30,Q=7,W,X=0,S="",N,U=false,P="top",T=0;if(A.type===k.finals.chart.pie){W=V.getCount();V.each(function(Y){S+=Y.data[V.domainFields[0]]})}else{W=V.rangeFields.length;for(var O=0,M,L;O<V.rangeFields.length;O++){if(V.rangeFields[O].indexOf("-")!==-1){L=V.rangeFields[O].split("-");M=u.metaData.names[L[0]]+" "+u.metaData.names[L[1]]}else{M=u.metaData.names[V.rangeFields[O]]}S+=M}}X=S.length;N=(W*R)+(X*Q);if(N>K.app.centerRegion.getWidth()-50){U=true;P="right"}if(P==="right"){T=5}return Ext.create("Ext.chart.Legend",{position:P,isVertical:U,labelFont:"13px "+k.chart.style.fontFamily,boxStroke:"#ffffff",boxStrokeWidth:0,padding:T})};F=function(M){var O=A.filterIds,L=[],Q="",P;if(A.type===k.finals.chart.pie){O=O.concat(A.columnIds)}if(Ext.isArray(O)&&O.length){for(var N=0;N<O.length;N++){Q+=u.metaData.names[O[N]];Q+=N<O.length-1?", ":""}}if(A.title){Q=A.title}P=(K.app.centerRegion.getWidth()/Q.length)<11.6?13:18;return Ext.create("Ext.draw.Sprite",{type:"text",text:Q,font:"bold "+P+"px "+k.chart.style.fontFamily,fill:"#111",height:20,y:20})};E=function(){return function(){this.animate=false;this.setWidth(K.app.centerRegion.getWidth()-15);this.setHeight(K.app.centerRegion.getHeight()-40);this.animate=true}};z=function(){return function(){if(this.items){var P=this.items[0],M=this.legend,O,L;if(this.legend.position==="top"){O=M.x+(M.width/2);L=O-(P.el.getWidth()/2)}else{var N=M?M.width:0;L=(this.width/2)-(P.el.getWidth()/2)}P.setAttributes({x:L},true)}}};y=function(L,Q,N,P){var O,M={store:L,axes:Q,series:N,animate:true,shadow:false,insetPadding:35,width:K.app.centerRegion.getWidth()-15,height:K.app.centerRegion.getHeight()-40,theme:P||"dv1"};if(!A.hideLegend){M.legend=r(L);if(M.legend.position==="right"){M.insetPadding=40}}if(!A.hideTitle){M.items=[F(L)]}else{M.insetPadding=10}O=Ext.create("Ext.chart.Chart",M);O.setChartSize=E();O.setTitlePosition=z();O.onViewportResize=function(){O.setChartSize();O.redraw();O.setTitlePosition()};O.on("afterrender",function(){O.setTitlePosition()});return O};p.column=function(){var L=t(),P=H(L),O=J(L),N=[P,O],M=[x(L)];if(A.showTrendLine){M=G(L).concat(M)}if(A.targetLineValue){M.push(C(L))}if(A.baseLineValue){M.push(I(L))}B(L);return y(L,N,M)};p.stackedcolumn=function(){var M=this.column();for(var L=0,N;L<M.series.items.length;L++){N=M.series.items[L];if(N.type===k.finals.chart.column){N.stacked=true}}return M};p.bar=function(){var T=t(),P=H(T),Q=J(T),S,O=x(T),L,M,U,R;P.position="bottom";Q.position="left";S=[P,Q];O.type="bar";O.axis="bottom";if(A.showValues){O.label={display:"outside","text-anchor":"middle",field:T.rangeFields}}O=[O];if(A.showTrendLine){L=G(T);for(var N=0;N<L.length;N++){L[N].axis="bottom";L[N].xField=T.trendLineFields[N];L[N].yField=T.domainFields}O=L.concat(O)}if(A.targetLineValue){M=C(T);M.axis="bottom";M.xField=T.targetLineFields;M.yField=T.domainFields;O.push(M)}if(A.baseLineValue){U=I(T);U.axis="bottom";U.xField=T.baseLineFields;U.yField=T.domainFields;O.push(U)}B(T);return y(T,S,O)};p.stackedbar=function(){var M=this.bar();for(var L=0,N;L<M.series.items.length;L++){N=M.series.items[L];if(N.type===k.finals.chart.bar){N.stacked=true}}return M};p.line=function(){var S=t(),O=H(S),P=J(S),Q=[O,P],M=[],L=k.chart.theme.dv1.slice(0,S.rangeFields.length),R=q(S);for(var N=0,T;N<S.rangeFields.length;N++){T={type:"line",axis:"left",xField:S.domainFields,yField:S.rangeFields[N],style:{opacity:0.8,lineWidth:3},markerConfig:{type:"circle",radius:4},tips:v(),title:R[N]};M.push(T)}if(A.showTrendLine){M=G(S).concat(M);L=L.concat(L)}if(A.targetLineValue){M.push(C(S));L.push("#051a2e")}if(A.baseLineValue){M.push(I(S));L.push("#051a2e")}Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(U){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},U))}});return y(S,Q,M)};p.area=function(){var L=t(),P=H(L),O=J(L),N=[P,O],M=x(L);M.type="area";M.style.opacity=0.7;M.style.lineWidth=0;delete M.label;delete M.tips;M=[M];if(A.showTrendLine){M=G(L).concat(M)}if(A.targetLineValue){M.push(C(L))}if(A.baseLineValue){M.push(I(L))}B(L);return y(L,N,M)};p.pie=function(){var M=t(),O,L,P,N={field:k.finals.data.domain};if(A.showValues){N.display="middle";N.contrast=true;N.font="14px "+k.chart.style.fontFamily;N.renderer=function(R){var Q=M.getAt(M.findExact(k.finals.data.domain,R));return Q.data[M.rangeFields[0]]}}O=[{type:"pie",field:M.rangeFields[0],donut:7,showInLegend:true,highlight:{segment:{margin:5}},label:N,style:{opacity:0.8,stroke:"#555"},tips:{trackMouse:true,cls:"dv-chart-tips",renderer:function(Q){this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">'+Q.data[M.rangeFields[0]]+'</div><div style="font-size:10px">'+Q.data[k.finals.data.domain]+"</div></div>")}}}];L=k.chart.theme.dv1.slice(0,u.nameHeaderMap[A.rowDimensionNames[0]].ids.length);Ext.chart.theme.dv1=Ext.extend(Ext.chart.theme.Base,{constructor:function(Q){Ext.chart.theme.Base.prototype.constructor.call(this,Ext.apply({seriesThemes:L,colors:L},Q))}});P=y(M,null,O);P.insetPadding=40;P.shadow=true;return P};p.radar=function(){var L=t(),R=[],O=[],N=q(L),P;R.push({type:"Radial",position:"radial",label:{display:true}});for(var M=0,Q;M<L.rangeFields.length;M++){Q={showInLegend:true,type:"radar",xField:L.domainFields,yField:L.rangeFields[M],style:{opacity:0.5},tips:v(),title:N[M]};if(A.showValues){Q.label={display:"over",field:L.rangeFields[M]}}O.push(Q)}P=y(L,R,O,"Category2");P.insetPadding=40;P.height=K.app.centerRegion.getHeight()-80;P.setChartSize=function(){this.animate=false;this.setWidth(K.app.centerRegion.getWidth());this.setHeight(K.app.centerRegion.getHeight()-80);this.animate=true};return P};return p[A.type]()}}());(function(){if(Ext.isArray(o.dimensions)){l.prototype.array.sort(o.dimensions);for(var p=0,q;p<o.dimensions.length;p++){q=o.dimensions[p];q.dimensionName=q.id;q.objectName=k.finals.dimension.dimension.objectName;k.finals.dimension.objectNameMap[q.id]=q}}l.prototype.array.sort(o.user.ouc)}());return{conf:k,api:m,support:l,service:i,web:j,init:o}};var d=".dv-chart-tips { border-radius: 2px; padding: 0px 3px 1px; border: 2px solid #000; background-color: #000; } \n";d+=".dv-chart-tips .x-tip-body { background-color: #000; font-size: 13px; font-weight: normal; color: #fff; -webkit-text-stroke: 0; } \n";d+=".dv-chart-tips .x-tip-body div { font-family: arial,sans-serif,ubuntu,consolas !important; } \n";d+=".x-mask-msg { padding: 0; \n border: 0 none; background-image: none; background-color: transparent; } \n";d+=".x-mask-msg div { background-position: 11px center; } \n";d+=".x-mask-msg .x-mask-loading { border: 0 none; \n background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n";Ext.util.CSS.createStyleSheet(d);DV.i18n={target:"Target",base:"Base",trend:"Trend"};DV.plugin={};var g={user:{}},f=[],h=false,c=false,a,e;a=function(j){var o=false,n=[],m=0,l;l=function(){if(++m===n.length){c=true;for(var p=0;p<f.length;p++){e(f[p])}f=[]}};n.push({url:j+"/api/system/context.jsonp",success:function(i){g.contextPath=i.contextPath;l()}});n.push({url:j+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(p){var i=p.organisationUnits[0];g.user.ou=i.id;g.user.ouc=Ext.Array.pluck(i.children,"id");l()}});n.push({url:j+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){g.legendSets=i.mapLegendSets;l()}});n.push({url:j+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){g.dimensions=i.dimensions;l()}});for(var k=0;k<n.length;k++){Ext.data.JsonP.request(n[k])}};e=function(l){var n,k,j,i,m={core:{},app:{}};n=function(o){if(!Ext.isObject(o)){console.log("Chart configuration is not an object");return}if(!Ext.isString(o.el)){console.log("No element id provided");return}o.id=o.id||o.uid;return true};k=function(s){var t=s.core.init,r=s.core.api,q=s.core.support,o=s.core.service,p=s.core.web;t.el=l.el;p.chart=p.chart||{};p.chart.loadChart=function(u){if(!Ext.isString(u)){alert("Invalid chart id");return}Ext.data.JsonP.request({url:t.contextPath+"/api/charts/"+u+".jsonp?viewClass=dimensional&links=false",failure:function(v){window.open(t.contextPath+"/api/charts/"+u+".json?viewClass=dimensional&links=false","_blank")},success:function(w){var v=r.layout.Layout(w);if(v){p.chart.getData(v,true)}}})};p.chart.getData=function(v,w){var u,x;if(!v){return}u=o.layout.getExtendedLayout(v);x=p.analytics.getParamString(u,true);p.mask.show(s.app.centerRegion);Ext.data.JsonP.request({url:t.contextPath+"/api/analytics.jsonp"+x,timeout:60000,headers:{"Content-Type":"application/json",Accepts:"application/json"},disableCaching:false,failure:function(y){p.mask.hide(s.app.centerRegion);window.open(t.contextPath+"/api/analytics.json"+x,"_blank")},success:function(z){var y=r.response.Response(z);if(!y){p.mask.hide(s.app.centerRegion);return}u=o.layout.getSyncronizedXLayout(u,y);if(!u){p.mask.hide(s.app.centerRegion);return}s.app.paramString=x;p.chart.getChart(v,u,y,w)}})};p.chart.getChart=function(z,w,v,A){var B,y,u,x;if(!w){w=o.layout.getExtendedLayout(z)}B=o.response.getExtendedResponse(w,v);s.app.layout=z;s.app.xLayout=w;s.app.response=v;s.app.xResponse=B;s.app.chart=s.core.web.chart.createChart(s);s.app.centerRegion.removeAll();s.app.centerRegion.add(s.app.chart);p.mask.hide(s.app.centerRegion)}};j=function(){var r=Ext.get(m.core.init.el),u,o,v=parseInt(r.getStyle("border-left-width"))+parseInt(r.getStyle("border-right-width")),s=parseInt(r.getStyle("border-top-width"))+parseInt(r.getStyle("border-bottom-width")),t=parseInt(r.getStyle("padding-left"))+parseInt(r.getStyle("padding-right")),p=parseInt(r.getStyle("padding-top"))+parseInt(r.getStyle("padding-bottom")),q=r.getWidth()-v-t,w=r.getHeight()-s-p;o=Ext.create("Ext.panel.Panel",{renderTo:r,bodyStyle:"border: 0 none",width:l.width||q,height:l.height||w,layout:"fit"});return{centerRegion:o}};i=function(){if(!n(l)){return}m.core=DV.getCore(Ext.clone(g));k(m);m.app.viewport=j();m.app.centerRegion=m.app.viewport.centerRegion;if(l.id){m.core.web.chart.loadChart(l.id)}else{layout=m.core.api.layout.Layout(l);if(!layout){return}m.core.web.chart.getData(layout)}}()};DV.plugin.getChart=function(i){if(Ext.isString(i.url)&&i.url.split("").pop()==="/"){i.url=i.url.substr(0,i.url.length-1)}if(c){e(i)}else{f.push(i);if(!h){h=true;a(i.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getChart=DV.plugin.getChart});

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js	2014-01-03 19:36:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/map.js	2014-02-08 18:09:18 +0000
@@ -1,1 +1,1 @@
-Ext.onReady(function(){Ext.define("Ext.ux.button.ColorButton",{extend:"Ext.button.Button",alias:"widget.colorbutton",width:109,height:22,defaultValue:null,value:"f1f1f1",getValue:function(){return this.value},setValue:function(i){this.value=i;if(Ext.isDefined(this.getEl())){this.getEl().dom.style.background="#"+i}},reset:function(){this.setValue(this.defaultValue)},menu:{},menuHandler:function(){},initComponent:function(){var i=this;this.defaultValue=this.value;this.menu=Ext.create("Ext.menu.Menu",{showSeparator:false,items:{xtype:"colorpicker",closeAction:"hide",listeners:{select:function(k,j){i.setValue(j);i.menu.hide();i.menuHandler(k,j)}}}});this.callParent()},listeners:{render:function(){this.setValue(this.value)}}});Ext.define("Ext.ux.layout.component.form.MultiSelect",{extend:"Ext.layout.component.field.Field",alias:["layout.multiselectfield"],type:"multiselectfield",defaultHeight:200,sizeBodyContents:function(j,i){var k=this;if(!Ext.isNumber(i)){i=k.defaultHeight}k.owner.panel.setSize(j,i)}});Ext.define("Ext.ux.form.MultiSelect",{extend:"Ext.form.field.Base",alternateClassName:"Ext.ux.Multiselect",alias:["widget.multiselect","widget.multiselectfield"],uses:["Ext.view.BoundList","Ext.form.FieldSet","Ext.ux.layout.component.form.MultiSelect","Ext.view.DragZone","Ext.view.DropZone"],ddReorder:false,appendOnly:false,displayField:"text",allowBlank:true,minSelections:0,maxSelections:Number.MAX_VALUE,blankText:"This field is required",minSelectionsText:"Minimum {0} item(s) required",maxSelectionsText:"Maximum {0} item(s) allowed",delimiter:",",componentLayout:"multiselectfield",fieldBodyCls:Ext.baseCSSPrefix+"form-multiselect-body",initComponent:function(){var i=this;i.bindStore(i.store,true);if(i.store.autoCreated){i.valueField=i.displayField="field1";if(!i.store.expanded){i.displayField="field2"}}if(!Ext.isDefined(i.valueField)){i.valueField=i.displayField}i.callParent()},bindStore:function(i,k){var l=this,m=l.store,j=l.boundList;if(m&&!k&&m!==i&&m.autoDestroy){m.destroy()}l.store=i?Ext.data.StoreManager.lookup(i):null;if(j){j.bindStore(i||null)}},onRender:function(m,i){var n=this,j,l,k;n.callParent(arguments);l=n.boundList=Ext.create("Ext.view.BoundList",{multiSelect:true,store:n.store,displayField:n.displayField,border:false});k=l.getSelectionModel();n.mon(k,{selectionChange:n.onSelectionChange,scope:n});j=n.panel=Ext.create("Ext.panel.Panel",{title:n.listTitle,tbar:n.tbar,items:[l],renderTo:n.bodyEl,layout:"fit"});j.ownerCt=n;n.setRawValue(n.rawValue)},getSubTplMarkup:function(){return""},afterRender:function(){var i=this;i.callParent();if(i.ddReorder&&!i.dragGroup&&!i.dropGroup){i.dragGroup=i.dropGroup="MultiselectDD-"+Ext.id()}if(i.draggable||i.dragGroup){i.dragZone=Ext.create("Ext.view.DragZone",{view:i.boundList,ddGroup:i.dragGroup,dragText:"{0} Item{1}"})}if(i.droppable||i.dropGroup){i.dropZone=Ext.create("Ext.view.DropZone",{view:i.boundList,ddGroup:i.dropGroup,handleNodeDrop:function(p,o,j){var k=this.view,m=k.getStore(),l=p.records,n;p.view.store.remove(l);n=m.indexOf(o);if(j==="after"){n++}m.insert(n,l);k.getSelectionModel().select(l)}})}},onSelectionChange:function(){this.checkChange()},clearValue:function(){this.setValue([])},getSubmitValue:function(){var j=this,i=j.delimiter,k=j.getValue();return Ext.isString(i)?k.join(i):k},getRawValue:function(){var j=this,i=j.boundList;if(i){j.rawValue=Ext.Array.map(i.getSelectionModel().getSelection(),function(k){return k.get(j.valueField)})}return j.rawValue},setRawValue:function(k){var j=this,i=j.boundList,l;k=Ext.Array.from(k);j.rawValue=k;if(i){l=[];Ext.Array.forEach(k,function(o){var n,m=j.store.findRecord(j.valueField,o,n,n,true,true);if(m){l.push(m)}});i.getSelectionModel().select(l,false,true)}return k},valueToRaw:function(i){return i},isEqual:function(n,m){var k=Ext.Array.from,l,j;n=k(n);m=k(m);j=n.length;if(j!==m.length){return false}for(l=0;l<j;l++){if(m[l]!==n[l]){return false}}return true},getErrors:function(j){var i=this,k=Ext.String.format,m=i.callParent(arguments),l;j=Ext.Array.from(j||i.getValue());l=j.length;if(!i.allowBlank&&l<1){m.push(i.blankText)}if(l<this.minSelections){m.push(k(i.minSelectionsText,i.minSelections))}if(l>this.maxSelections){m.push(k(i.maxSelectionsText,i.maxSelections))}return m},onDisable:function(){this.callParent();this.disabled=true;this.updateReadOnly()},onEnable:function(){this.callParent();this.disabled=false;this.updateReadOnly()},setReadOnly:function(i){this.readOnly=i;this.updateReadOnly()},updateReadOnly:function(){var j=this,i=j.boundList,k=j.readOnly||j.disabled;if(i){i.getSelectionModel().setLocked(k)}},onDestroy:function(){Ext.destroyMembers(this,"panel","boundList","dragZone","dropZone");this.callParent()}});OpenLayers.Util.OSM={};OpenLayers.Util.OSM.MISSING_TILE_URL="http://www.openstreetmap.org/openlayers/img/404.png";OpenLayers.Util.OSM.originalOnImageLoadError=OpenLayers.Util.onImageLoadError;OpenLayers.Util.onImageLoadError=function(){if(this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)){this.src=OpenLayers.Util.OSM.MISSING_TILE_URL}else{if(this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)){}else{OpenLayers.Util.OSM.originalOnImageLoadError}}};OpenLayers.Layer.OSM.Mapnik=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png","http://b.tile.openstreetmap.org/${z}/${x}/${y}.png","http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.Mapnik"});OpenLayers.Layer.OSM.Osmarender=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:18,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.Osmarender"});OpenLayers.Layer.OSM.CycleMap=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.CycleMap"});OpenLayers.Control.Circle=OpenLayers.Class(OpenLayers.Control,{feature:null,layer:null,radius:5,origin:null,sides:40,angle:null,snapAngle:null,dragControl:null,initialize:function(i){OpenLayers.Control.prototype.initialize.apply(this,arguments)},activate:function(){var j=OpenLayers.Control.prototype.activate.call(this);if(j){var i={displayInLayerSwitcher:false,calculateInRange:function(){return true}};this.map.addLayer(this.layer)}return j},deactivate:function(){var i=OpenLayers.Control.prototype.deactivate.call(this);if(i){if(this.layer.map!=null){this.layer.destroy(false);if(this.feature){this.feature.destroy()}}this.layer=null;this.feature=null}return i},createGeometry:function(){this.angle=Math.PI*((1/this.sides)-(1/2));if(this.snapAngle){this.angle+=this.snapAngle*(Math.PI/180)}this.feature.geometry=OpenLayers.Geometry.Polygon.createRegularPolygon(this.origin,this.radius,this.sides,this.snapAngle)},modifyGeometry:function(){var k,n,i,j;var m=this.feature.geometry.components[0];if(m.components.length!=(this.sides+1)){this.createGeometry();m=this.feature.geometry.components[0]}for(var l=0;l<this.sides;++l){j=m.components[l];k=this.angle+(l*2*Math.PI/this.sides);j.x=this.origin.x+(this.radius*Math.cos(k));j.y=this.origin.y+(this.radius*Math.sin(k));j.clearBounds()}},updateCircle:function(i,j){this.origin=new OpenLayers.Geometry.Point(i.lon,i.lat);this.radius=j*1;if(!this.feature){this.feature=new OpenLayers.Feature.Vector();this.createGeometry();this.layer.addFeatures([this.feature],{silent:true})}else{this.modifyGeometry()}this.layer.drawFeature(this.feature,this.style)},CLASS_NAME:"Meteorage.Circle"});OpenLayers.Control.newSelectFeature=OpenLayers.Class(OpenLayers.Control,{multipleKey:null,toggleKey:null,multiple:false,clickout:true,toggle:false,hover:false,onSelect:function(){},onUnselect:function(){},onHoverSelect:function(){},onHoverUnselect:function(){},onClickSelect:function(){},onClickUnselect:function(){},geometryTypes:null,layer:null,callbacks:null,selectStyle:null,renderIntent:"select",handler:null,initialize:function(k,j){OpenLayers.Control.prototype.initialize.apply(this,[j]);this.layer=k;this.callbacks=OpenLayers.Util.extend({click:this.clickFeature,clickout:this.clickoutFeature,over:this.overFeature,out:this.outFeature},this.callbacks);var i={geometryTypes:this.geometryTypes};this.handler=new OpenLayers.Handler.Feature(this,k,this.callbacks,i)},unselectAll:function(j){var l;for(var k=this.layer.selectedFeatures.length-1;k>=0;--k){l=this.layer.selectedFeatures[k];if(!j||j.except!=l){this.unselect(l,"click")}}},clickFeature:function(i){if((this.onSelect.name!=""||this.onClickSelect.name!="")&&!this.hover){var j=(OpenLayers.Util.indexOf(this.layer.selectedFeatures,i)>-1);if(j){if(this.toggleSelect()){this.unselect(i)}else{if(!this.multipleSelect()){this.unselectAll({except:i})}}}else{if(!this.multipleSelect()){this.unselectAll({except:i})}}this.select(i,"click")}},multipleSelect:function(){return this.multiple||this.handler.evt[this.multipleKey]},toggleSelect:function(){return this.toggle||this.handler.evt[this.toggleKey]},clickoutFeature:function(i){if(((this.onClickUnselect.name!=""||this.onHoverSelect.name=="")&&!this.hover)&&this.clickout){this.unselectAll()}},overFeature:function(i){if((this.onHoverSelect.name!=""||this.hover)&&(OpenLayers.Util.indexOf(this.layer.selectedFeatures,i)==-1)){this.select(i,"hover")}},outFeature:function(i){if(this.onHoverUnselect.name!=""||this.hover){this.unselect(i,"hover")}},select:function(k,i){this.layer.selectedFeatures.push(k);var j=this.selectStyle||this.renderIntent;this.layer.drawFeature(k,j);this.layer.events.triggerEvent("featureselected",{feature:k});switch(i){case"hover":this.onHoverSelect(k);break;case"click":if(this.onClickSelect.name!=""){this.onClickSelect(k)}else{if(this.onSelect.name!=""){this.onSelect(k)}}break;default:this.onSelect(k);break}},unselect:function(j,i){this.layer.drawFeature(j,"default");OpenLayers.Util.removeItem(this.layer.selectedFeatures,j);this.layer.events.triggerEvent("featureunselected",{feature:j});switch(i){case"hover":this.onHoverUnselect(j);break;case"click":if(this.onClickUnselect.name!=""){this.onClickUnselect(j)}else{if(this.onUnselect.name!=""){this.onUnselect(j)}}break;default:this.onUnselect(j);break}},setMap:function(i){this.handler.setMap(i);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.newSelectFeature"});Ext.define("GeoExt.data.LayerModel",{alternateClassName:"GeoExt.data.LayerRecord",extend:"Ext.data.Model",requires:["Ext.data.proxy.Memory","Ext.data.reader.Json"],alias:"model.gx_layer",statics:{createFromLayer:function(i){return this.proxy.reader.readRecords([i]).records[0]}},fields:["id",{name:"title",type:"string",mapping:"name"},{name:"legendURL",type:"string",mapping:"metadata.legendURL"},{name:"hideTitle",type:"bool",mapping:"metadata.hideTitle"},{name:"hideInLegend",type:"bool",mapping:"metadata.hideInLegend"}],proxy:{type:"memory",reader:{type:"json"}},getLayer:function(){return this.raw}});Ext.define("GeoExt.data.LayerStore",{requires:["GeoExt.data.LayerModel"],extend:"Ext.data.Store",model:"GeoExt.data.LayerModel",statics:{MAP_TO_STORE:1,STORE_TO_MAP:2},map:null,constructor:function(i){var l=this;i=Ext.apply({},i);var k=(GeoExt.MapPanel&&i.map instanceof GeoExt.MapPanel)?i.map.map:i.map;delete i.map;if(i.layers){i.data=i.layers}delete i.layers;var j={initDir:i.initDir};delete i.initDir;l.callParent([i]);if(k){this.bind(k,j)}},bind:function(k,j){var i=this;if(i.map){return}i.map=k;j=Ext.apply({},j);var m=j.initDir;if(j.initDir==undefined){m=GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP}var l=k.layers.slice(0);if(m&GeoExt.data.LayerStore.STORE_TO_MAP){i.each(function(n){i.map.addLayer(n.getLayer())},i)}if(m&GeoExt.data.LayerStore.MAP_TO_STORE){i.loadRawData(l,true)}k.events.on({changelayer:i.onChangeLayer,addlayer:i.onAddLayer,removelayer:i.onRemoveLayer,scope:i});i.on({load:i.onLoad,clear:i.onClear,add:i.onAdd,remove:i.onRemove,update:i.onUpdate,scope:i});i.data.on({replace:i.onReplace,scope:i});i.fireEvent("bind",i,k)},unbind:function(){var i=this;if(i.map){i.map.events.un({changelayer:i.onChangeLayer,addlayer:i.onAddLayer,removelayer:i.onRemoveLayer,scope:i});i.un("load",i.onLoad,i);i.un("clear",i.onClear,i);i.un("add",i.onAdd,i);i.un("remove",i.onRemove,i);i.data.un("replace",i.onReplace,i);i.map=null}},onChangeLayer:function(i){var k=i.layer;var m=this.findBy(function(o,n){return o.getLayer()===k});if(m>-1){var j=this.getAt(m);if(i.property==="order"){if(!this._adding&&!this._removing){var l=this.map.getLayerIndex(k);if(l!==m){this._removing=true;this.remove(j);delete this._removing;this._adding=true;this.insert(l,[j]);delete this._adding}}}else{if(i.property==="name"){j.set("title",k.name)}else{this.fireEvent("update",this,j,Ext.data.Record.EDIT)}}}},onAddLayer:function(i){var k=this;if(!k._adding){k._adding=true;var j=k.proxy.reader.read(i.layer);k.add(j.records);delete k._adding}},onRemoveLayer:function(j){if(this.map.unloadDestroy){if(!this._removing){var i=j.layer;this._removing=true;this.remove(this.getByLayer(i));delete this._removing}}else{this.unbind()}},onLoad:function(o,i,k){if(k){if(!Ext.isArray(i)){i=[i]}if(!this._addRecords){this._removing=true;for(var m=this.map.layers.length-1;m>=0;m--){this.map.removeLayer(this.map.layers[m])}delete this._removing}var j=i.length;if(j>0){var l=new Array(j);for(var n=0;n<j;n++){l[n]=i[n].getLayer()}this._adding=true;this.map.addLayers(l);delete this._adding}}delete this._addRecords},onClear:function(j){this._removing=true;for(var i=this.map.layers.length-1;i>=0;i--){this.map.removeLayer(this.map.layers[i])}delete this._removing},onAdd:function(i,j,m){if(!this._adding){this._adding=true;var k;for(var l=j.length-1;l>=0;--l){k=j[l].getLayer();this.map.addLayer(k);if(m!==this.map.layers.length-1){this.map.setLayerIndex(k,m)}}delete this._adding}},onRemove:function(i,j,l){if(!this._removing){var k=j.getLayer();if(this.map.getLayer(k.id)!=null){this._removing=true;this.removeMapLayer(j);delete this._removing}}},onUpdate:function(m,j,i){if(i===Ext.data.Record.EDIT){if(j.modified&&j.modified.title){var l=j.getLayer();var k=j.get("title");if(k!==l.name){l.setName(k)}}}},removeMapLayer:function(i){this.map.removeLayer(i.getLayer())},onReplace:function(k,j,i){this.removeMapLayer(j)},getByLayer:function(i){var j=this.findBy(function(k){return k.getLayer()===i});if(j>-1){return this.getAt(j)}},destroy:function(){var i=this;i.unbind();i.callParent()},loadRecords:function(j,i){if(i&&i.addRecords){this._addRecords=true}this.callParent(arguments)}});Ext.define("GeoExt.panel.Map",{extend:"Ext.panel.Panel",requires:["GeoExt.data.LayerStore"],alias:"widget.gx_mappanel",alternateClassName:"GeoExt.MapPanel",statics:{guess:function(){var i=Ext.ComponentQuery.query("gx_mappanel");return((i&&i.length>0)?i[0]:null)}},center:null,zoom:null,extent:null,prettyStateKeys:false,map:null,layers:null,stateEvents:["aftermapmove","afterlayervisibilitychange","afterlayeropacitychange","afterlayerorderchange","afterlayernamechange","afterlayeradd","afterlayerremove"],initComponent:function(){if(!(this.map instanceof OpenLayers.Map)){this.map=new OpenLayers.Map(Ext.applyIf(this.map||{},{allOverlays:true}))}var i=this.layers;if(!i||i instanceof Array){this.layers=Ext.create("GeoExt.data.LayerStore",{layers:i,map:this.map.layers.length>0?this.map:null})}if(Ext.isString(this.center)){this.center=OpenLayers.LonLat.fromString(this.center)}else{if(Ext.isArray(this.center)){this.center=new OpenLayers.LonLat(this.center[0],this.center[1])}}if(Ext.isString(this.extent)){this.extent=OpenLayers.Bounds.fromString(this.extent)}else{if(Ext.isArray(this.extent)){this.extent=OpenLayers.Bounds.fromArray(this.extent)}}this.callParent(arguments);this.on("resize",this.onResize,this);this.on("afterlayout",function(){if(typeof this.map.getViewport==="function"){this.items.each(function(j){if(typeof j.addToMapPanel==="function"){j.getEl().appendTo(this.map.getViewport())}},this)}},this);this.map.events.on({moveend:this.onMoveend,changelayer:this.onChangelayer,addlayer:this.onAddlayer,removelayer:this.onRemovelayer,scope:this})},onMoveend:function(i){this.fireEvent("aftermapmove",this,this.map,i)},onChangelayer:function(i){var j=this.map;if(i.property){if(i.property==="visibility"){this.fireEvent("afterlayervisibilitychange",this,j,i)}else{if(i.property==="order"){this.fireEvent("afterlayerorderchange",this,j,i)}else{if(i.property==="nathis"){this.fireEvent("afterlayernathischange",this,j,i)}else{if(i.property==="opacity"){this.fireEvent("afterlayeropacitychange",this,j,i)}}}}}},onAddlayer:function(){this.fireEvent("afterlayeradd")},onRemovelayer:function(){this.fireEvent("afterlayerremove")},onResize:function(){var i=this.map;if(this.body.dom!==i.div){i.render(this.body.dom);this.layers.bind(i);if(i.layers.length>0){this.setInitialExtent()}else{this.layers.on("add",this.setInitialExtent,this,{single:true})}}else{i.updateSize()}},setInitialExtent:function(){var i=this.map;if(!i.getCenter()){if(this.center||this.zoom){i.setCenter(this.center,this.zoom)}else{if(this.extent instanceof OpenLayers.Bounds){i.zoomToExtent(this.extent,true)}else{i.zoomToMaxExtent()}}}},getState:function(){var m=this,k=m.map,l=m.callParent(arguments)||{},i;if(!k){return}var j=k.getCenter();j&&Ext.applyIf(l,{x:j.lon,y:j.lat,zoom:k.getZoom()});m.layers.each(function(n){i=n.getLayer();layerId=this.prettyStateKeys?n.get("title"):n.get("id");l=m.addPropertyToState(l,"visibility_"+layerId,i.getVisibility());l=m.addPropertyToState(l,"opacity_"+layerId,(i.opacity===null)?1:i.opacity)},m);return l},applyState:function(r){var i=this;map=i.map;i.center=new OpenLayers.LonLat(r.x,r.y);i.zoom=r.zoom;var m,p,l,o,q,k;var n=map.layers;for(m=0,p=n.length;m<p;m++){l=n[m];o=i.prettyStateKeys?l.name:l.id;q=r["visibility_"+o];if(q!==undefined){q=(/^true$/i).test(q);if(l.isBaseLayer){if(q){map.setBaseLayer(l)}}else{l.setVisibility(q)}}k=r["opacity_"+o];if(k!==undefined){l.setOpacity(k)}}},onBeforeAdd:function(i){if(Ext.isFunction(i.addToMapPanel)){i.addToMapPanel(this)}this.callParent(arguments)},beforeDestroy:function(){if(this.map&&this.map.events){this.map.events.un({moveend:this.onMoveend,changelayer:this.onChangelayer,scope:this})}if(!this.initialConfig.map||!(this.initialConfig.map instanceof OpenLayers.Map)){if(this.map&&this.map.destroy){this.map.destroy()}}delete this.map;this.callParent(arguments)}});Ext.define("GeoExt.tree.Column",{extend:"Ext.tree.Column",alias:"widget.gx_treecolumn",initComponent:function(){var i=this;i.callParent();var j=i.renderer;this.renderer=function(l,p,q,m,k,o,r){var n=[j(l,p,q,m,k,o,r)];if(q.get("checkedGroup")){n[0]=n[0].replace(/class="([^-]+)-tree-checkbox([^"]+)?"/,'class="$1-tree-checkbox$2 gx-tree-radio"')}n.push('<div class="gx-tree-component gx-tree-component-off" id="tree-record-'+q.id+'"></div>');if(q.uiProvider&&q.uiProvider instanceof "string"){}return n.join("")}},defaultRenderer:function(i){return i}});Ext.define("GeoExt.tree.View",{extend:"Ext.tree.View",alias:"widget.gx_treeview",initComponent:function(){var i=this;i.on("itemupdate",this.onItem,this);i.on("itemadd",this.onItem,this);i.on("createchild",this.createChild,this);return i.callParent(arguments)},onItem:function(j,n,k,i){var l=this;if(!(j instanceof Array)){j=[j]}for(var m=0;m<j.length;m++){this.onNodeRendered(j[m])}},onNodeRendered:function(k){var i=this;var j=Ext.get("tree-record-"+k.id);if(!j){return}if(k.get("layer")){i.fireEvent("createchild",j,k)}if(k.hasChildNodes()){k.eachChild(function(l){i.onNodeRendered(l)},i)}},createChild:function(i,k){var j=k.get("component");if(j){cmpObj=Ext.ComponentManager.create(j);cmpObj.render(i);i.removeCls("gx-tree-component-off")}}});Ext.define("GeoExt.tree.LayerNode",{extend:"Ext.AbstractPlugin",alias:"plugin.gx_layer",init:function(i){this.target=i;var j=i.get("layer");i.set("checked",j.getVisibility());if(!i.get("checkedGroup")&&j.isBaseLayer){i.set("checkedGroup","gx_baselayer")}i.set("fixedText",!!i.text);i.set("leaf",true);if(!i.get("iconCls")){i.set("iconCls","gx-tree-layer-icon")}i.on("afteredit",this.onAfterEdit,this);j.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this})},onAfterEdit:function(k,j){var i=this;if(~Ext.Array.indexOf(j,"checked")){i.onCheckChange()}},onLayerVisibilityChanged:function(){if(!this._visibilityChanging){this.target.set("checked",this.target.get("layer").getVisibility())}},onCheckChange:function(){var k=this.target,i=this.target.get("checked");if(i!=k.get("layer").getVisibility()){k._visibilityChanging=true;var j=k.get("layer");if(i&&j.isBaseLayer&&j.map){j.map.setBaseLayer(j)}else{j.setVisibility(i)}delete k._visibilityChanging}}});Ext.define("GeoExt.tree.LayerLoader",{extend:"Ext.util.Observable",requires:["GeoExt.tree.LayerNode"],store:null,filter:function(i){return i.getLayer().displayInLayerSwitcher===true},baseAttrs:null,load:function(i){if(this.fireEvent("beforeload",this,i)){this.removeStoreHandlers();while(i.firstChild){i.removeChild(i.firstChild)}if(!this.store){this.store=GeoExt.MapPanel.guess().layers}this.store.each(function(j){this.addLayerNode(i,j)},this);this.addStoreHandlers(i);this.fireEvent("load",this,i)}},onStoreAdd:function(i,j,o,l){if(!this._reordering){var k=l.get("container").recordIndexToNodeIndex(o+j.length-1,l);for(var n=0,m=j.length;n<m;++n){this.addLayerNode(l,j[n],k)}}},onStoreRemove:function(j,i){if(!this._reordering){this.removeLayerNode(i,j)}},addLayerNode:function(l,j,i){i=i||0;if(this.filter(j)===true){var m=j.getLayer();var k=this.createNode({plugins:[{ptype:"gx_layer"}],layer:m,text:m.name,listeners:{move:this.onChildMove,scope:this}});if(i!==undefined){l.insertChild(i,k)}else{l.appendChild(k)}l.getChildAt(i).on("move",this.onChildMove,this)}},removeLayerNode:function(i,j){if(this.filter(j)===true){var k=i.findChildBy(function(l){return l.get("layer")==j.getLayer()});if(k){k.un("move",this.onChildMove,this);k.remove()}}},onChildMove:function(v,n,m,q){var p=this,r=p.store.getByLayer(v.get("layer")),w=m.get("container"),s=w.loader;p._reordering=true;if(s instanceof p.self&&p.store===s.store){s._reordering=true;p.store.remove(r);var x;if(m.childNodes.length>1){var o=(q===0)?q+1:q-1;x=p.store.findBy(function(i){return m.childNodes[o].get("layer")===i.getLayer()});if(q===0){x++}}else{if(n.parentNode===m.parentNode){var u=m;do{u=u.previousSibling}while(u&&!(u.get("container") instanceof w.self&&u.lastChild));if(u){x=p.store.findBy(function(i){return u.lastChild.get("layer")===i.getLayer()})}else{var t=m;do{t=t.nextSibling}while(t&&!(t.get("container") instanceof w.self&&t.firstChild));if(t){x=p.store.findBy(function(i){return t.firstChild.get("layer")===i.getLayer()})}x++}}}if(x!==undefined){p.store.insert(x,[r])}else{p.store.insert(oldRecordIndex,[r])}delete s._reordering}delete p._reordering},addStoreHandlers:function(i){if(!this._storeHandlers){this._storeHandlers={add:function(m,k,l){this.onStoreAdd(m,k,l,i)},remove:function(l,k){this.onStoreRemove(k,i)}};for(var j in this._storeHandlers){this.store.on(j,this._storeHandlers[j],this)}}},removeStoreHandlers:function(){if(this._storeHandlers){for(var i in this._storeHandlers){this.store.un(i,this._storeHandlers[i],this)}delete this._storeHandlers}},createNode:function(i){if(this.baseAttrs){Ext.apply(i,this.baseAttrs)}return i},destroy:function(){this.removeStoreHandlers()}});Ext.define("GeoExt.tree.LayerContainer",{extend:"Ext.AbstractPlugin",requires:["GeoExt.tree.LayerLoader"],alias:"plugin.gx_layercontainer",defaultText:"Layers",init:function(k){var i=this;var j=i.loader;i.loader=(j&&j instanceof GeoExt.tree.LayerLoader)?j:new GeoExt.tree.LayerLoader(j);k.set("container",i);if(!k.get("text")){k.set("text",i.defaultText);k.commit()}i.loader.load(k)},recordIndexToNodeIndex:function(p,l){var m=this;var i=m.loader.store;var n=i.getCount();var j=l.childNodes.length;var k=-1;for(var o=n-1;o>=0;--o){if(m.loader.filter(i.getAt(o))===true){++k;if(p===o||k>j-1){break}}}return k}});Ext.define("GeoExt.tree.BaseLayerContainer",{extend:"GeoExt.tree.LayerContainer",alias:"plugin.gx_baselayercontainer",defaultText:"Base Layers",init:function(k){var i=this;var j=i.loader;i.loader=Ext.applyIf(j||{},{baseAttrs:Ext.applyIf((j&&j.baseAttrs)||{},{iconCls:"gx-tree-baselayer-icon",checkedGroup:"baselayer"}),filter:function(m){var l=m.getLayer();return l.displayInLayerSwitcher===true&&l.isBaseLayer===true}});i.callParent(arguments)}});Ext.define("GeoExt.tree.Panel",{extend:"Ext.tree.Panel",alias:"widget.gx_treepanel",requires:["GeoExt.tree.Column","GeoExt.tree.View"],viewType:"gx_treeview",initComponent:function(){var i=this;if(!i.columns){if(i.initialConfig.hideHeaders===undefined){i.hideHeaders=true}i.addCls(Ext.baseCSSPrefix+"autowidth-table");i.columns=[{xtype:"gx_treecolumn",text:"Name",width:Ext.isIE6?null:10000,dataIndex:i.displayField}]}i.callParent()}});Ext.Ajax.method="GET";GIS={core:{instances:[]},i18n:{},isDebug:false,logg:[]};GIS.core.getOLMap=function(j){var k,i;i=function(m,o){var n,l;n=new OpenLayers.Control.Button({displayClass:"olControlButton",trigger:function(){o.call(j.olmap)}});l=new OpenLayers.Control.Panel({defaultControl:n});l.addControls([n]);k.addControl(l);l.div.className+=" "+m;l.div.childNodes[0].className+=" "+m+"Button"};k=new OpenLayers.Map({controls:[new OpenLayers.Control.Navigation({zoomWheelEnabled:true,documentDrag:true}),new OpenLayers.Control.MousePosition({prefix:'<span id="mouseposition" class="el-fontsize-10"><span class="text-mouseposition-lonlat">LON </span>',separator:'<span class="text-mouseposition-lonlat">,&nbsp;LAT </span>',suffix:'<div id="google-logo" name="http://www.google.com/intl/en-US_US/help/terms_maps.html"; onclick="window.open(Ext.get(this).dom.attributes.name.nodeValue);"></div></span>'}),new OpenLayers.Control.Permalink(),new OpenLayers.Control.ScaleLine({geodesic:true,maxWidth:170,minWidth:100})],displayProjection:new OpenLayers.Projection("EPSG:4326"),maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),mouseMove:{},relocate:{}});k.events.register("mousemove",null,function(l){j.olmap.mouseMove.x=l.clientX;j.olmap.mouseMove.y=l.clientY});k.zoomToVisibleExtent=function(){j.util.map.zoomToVisibleExtent(this)};k.closeAllLayers=function(){j.layer.event.core.reset();j.layer.facility.core.reset();j.layer.boundary.core.reset();j.layer.thematic1.core.reset();j.layer.thematic2.core.reset();j.layer.thematic3.core.reset();j.layer.thematic4.core.reset()};i("zoomIn",k.zoomIn);i("zoomOut",k.zoomOut);i("zoomVisible",k.zoomToVisibleExtent);i("measure",function(){GIS.core.MeasureWindow(j).show()});return k};GIS.core.getLayers=function(j){var o={},k,m=["1","2","3","4"];if(window.google){o.googleStreets=new OpenLayers.Layer.Google("Google Streets",{numZoomLevels:20,animationEnabled:true,layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.googleStreets.id="googleStreets";o.googleHybrid=new OpenLayers.Layer.Google("Google Hybrid",{type:google.maps.MapTypeId.HYBRID,numZoomLevels:20,animationEnabled:true,layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.googleHybrid.id="googleHybrid"}o.openStreetMap=new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap",{layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.openStreetMap.id="openStreetMap";o.event=GIS.core.VectorLayer(j,"event",GIS.i18n.event_layer,{opacity:0.8});o.event.core=new mapfish.GeoStat.Event(j.olmap,{layer:o.event,gis:j});o.facility=GIS.core.VectorLayer(j,"facility",GIS.i18n.facility_layer,{opacity:1});o.facility.core=new mapfish.GeoStat.Facility(j.olmap,{layer:o.facility,gis:j});o.boundary=GIS.core.VectorLayer(j,"boundary",GIS.i18n.boundary_layer,{opacity:0.8});o.boundary.core=new mapfish.GeoStat.Boundary(j.olmap,{layer:o.boundary,gis:j});for(var l=0,n;l<m.length;l++){n=m[l];o["thematic"+n]=GIS.core.VectorLayer(j,"thematic"+n,GIS.i18n.thematic_layer+" "+n,{opacity:0.8});o["thematic"+n].layerCategory=j.conf.finals.layer.category_thematic,o["thematic"+n].core=new mapfish.GeoStat["Thematic"+n](j.olmap,{layer:o["thematic"+n],gis:j})}return o};GIS.core.createSelectHandlers=function(r,l){var t=!!GIS.app?(r.init.user.isAdmin?true:false):false,u={},n,i,k,j,m,q=r.conf.finals.dimension,s,p;i=function o(w){if(s){s.destroy()}s=Ext.create("Ext.window.Window",{cls:"gis-window-widget-feature gis-plugin",preventHeader:true,shadow:false,resizable:false,items:{html:w.attributes.label}});s.show();var z=r.viewport.eastRegion.getPosition()[0],y=r.viewport.centerRegion.getPosition()[0],x=y+((z-y)/2),v=r.viewport.centerRegion.getPosition()[1]+(GIS.app?32:0);s.setPosition(x-(s.getWidth()/2),v)};k=function o(v){s.destroy()};j=function o(D){var C,B,w,x,y,A=D.geometry.CLASS_NAME===r.conf.finals.openLayers.point_classname,z=D.attributes;B=function(){if(r.olmap.relocate.window){r.olmap.relocate.window.destroy()}r.olmap.relocate.window=Ext.create("Ext.window.Window",{title:"Relocate facility",layout:"fit",iconCls:"gis-window-title-icon-relocate",cls:"gis-container-default",setMinWidth:function(E){this.setWidth(this.getWidth()<E?E:this.getWidth())},items:{html:z.name,cls:"gis-container-inner"},bbar:["->",{xtype:"button",hideLabel:true,text:GIS.i18n.cancel,handler:function(){r.olmap.relocate.active=false;r.olmap.relocate.window.destroy();r.olmap.getViewport().style.cursor="auto"}}],listeners:{close:function(){r.olmap.relocate.active=false;r.olmap.getViewport().style.cursor="auto"}}});r.olmap.relocate.window.show();r.olmap.relocate.window.setMinWidth(220);r.util.gui.window.setPositionTopRight(r.olmap.relocate.window)};C=function(){Ext.Ajax.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getFacilityInfo.action",params:{id:z.id},success:function(F){var E=Ext.decode(F.responseText);if(l.infrastructuralWindow){l.infrastructuralWindow.destroy()}l.infrastructuralWindow=Ext.create("Ext.window.Window",{title:GIS.i18n.information,layout:"column",iconCls:"gis-window-title-icon-information",cls:"gis-container-default",width:460,height:400,period:null,items:[{cls:"gis-container-inner",columnWidth:0.4,bodyStyle:"padding-right:4px",items:function(){var G=[];if(z.name){G.push({html:GIS.i18n.name,cls:"gis-panel-html-title"},{html:z.name,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.pa){G.push({html:GIS.i18n.parent_unit,cls:"gis-panel-html-title"},{html:E.pa,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.ty){G.push({html:GIS.i18n.type,cls:"gis-panel-html-title"},{html:E.ty,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.co){G.push({html:GIS.i18n.code,cls:"gis-panel-html-title"},{html:E.co,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.ad){G.push({html:GIS.i18n.address,cls:"gis-panel-html-title"},{html:E.ad,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.em){G.push({html:GIS.i18n.email,cls:"gis-panel-html-title"},{html:E.em,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.pn){G.push({html:GIS.i18n.phone_number,cls:"gis-panel-html-title"},{html:E.pn,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}return G}()},{xtype:"form",cls:"gis-container-inner gis-form-widget",columnWidth:0.6,bodyStyle:"padding-left:4px",items:[{html:GIS.i18n.infrastructural_data,cls:"gis-panel-html-title"},{cls:"gis-panel-html-separator"},{xtype:"combo",fieldLabel:GIS.i18n.period,editable:false,valueField:"id",displayField:"name",forceSelection:true,width:255,labelWidth:70,store:r.store.infrastructuralPeriodsByType,lockPosition:false,listeners:{select:function(){n=this.getValue();l.widget.infrastructuralDataElementValuesStore.load({params:{periodId:n,organisationUnitId:z.internalId}})}}},{cls:"gis-panel-html-separator"},{xtype:"grid",cls:"gis-grid",height:300,width:255,scroll:"vertical",columns:[{id:"dataElementName",text:"Data element",dataIndex:"dataElementName",sortable:true,width:195},{id:"value",header:"Value",dataIndex:"value",sortable:true,width:60}],disableSelection:true,store:l.widget.infrastructuralDataElementValuesStore}]}],listeners:{show:function(){if(n){this.down("combo").setValue(n);infrastructuralDataElementValuesStore.load({params:{periodId:n,organisationUnitId:z.internalId}})}}}});l.infrastructuralWindow.show();r.util.gui.window.setPositionTopRight(l.infrastructuralWindow)}})};w=function(I,G,H){var F=Ext.clone(l.core.view),E;F.parentGraphMap={};F.parentGraphMap[I]=G;F.rows=[{dimension:q.organisationUnit.objectName,items:[{id:I},{id:"LEVEL-"+H}]}];if(F){E=l.core.getLoader();E.updateGui=true;E.zoomToVisibleExtent=true;E.hideMask=true;E.load(F)}};var v=[Ext.create("Ext.menu.Item",{text:"Float up",iconCls:"gis-menu-item-icon-float",cls:"gis-plugin",disabled:!z.hasCoordinatesUp,handler:function(){w(z.grandParentId,z.grandParentParentGraph,parseInt(z.level)-1)}}),Ext.create("Ext.menu.Item",{text:"Drill down",iconCls:"gis-menu-item-icon-drill",cls:"gis-menu-item-first gis-plugin",disabled:!z.hasCoordinatesDown,handler:function(){w(z.id,z.parentGraph,parseInt(z.level)+1)}})];if(t&&A){v.push({xtype:"menuseparator"});v.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.relocate,iconCls:"gis-menu-item-icon-relocate",disabled:!r.init.user.isAdmin,handler:function(E){r.olmap.relocate.active=true;r.olmap.relocate.feature=D;r.olmap.getViewport().style.cursor="crosshair";B()}}));v.push(Ext.create("Ext.menu.Item",{text:"Swap lon/lat",iconCls:"gis-menu-item-icon-relocate",disabled:!r.init.user.isAdmin,handler:function(E){var G=D.attributes.id,F=Ext.clone(D.geometry).transform("EPSG:900913","EPSG:4326");if(Ext.isNumber(F.x)&&Ext.isNumber(F.y)&&r.init.user.isAdmin){Ext.Ajax.request({url:r.init.contextPath+"/api/organisationUnits/"+G+".json?links=false",success:function(H){var I=Ext.decode(H.responseText);I.coordinates="["+F.y.toFixed(5)+","+F.x.toFixed(5)+"]";Ext.Ajax.request({url:r.init.contextPath+"/api/metaData?preheatCache=false",method:"POST",headers:{"Content-Type":"application/json"},params:Ext.encode({organisationUnits:[I]}),success:function(K){var J=D.geometry.x,L=D.geometry.y;delete D.geometry.bounds;D.geometry.x=L;D.geometry.y=J;l.redraw();console.log(D.attributes.name+" relocated to "+I.coordinates)}})}})}}}));v.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.show_information_sheet,iconCls:"gis-menu-item-icon-information",handler:function(E){if(r.store.infrastructuralPeriodsByType.isLoaded){C()}else{r.store.infrastructuralPeriodsByType.load({params:{name:r.init.systemSettings.infrastructuralPeriodType},callback:function(){C()}})}}}))}v[v.length-1].addCls("gis-menu-item-last");x=new Ext.menu.Menu({baseCls:"gis-plugin",shadow:false,showSeparator:false,defaults:{bodyStyle:"padding-right:6px"},items:v,listeners:{afterrender:function(){this.getEl().addCls("gis-toolbar-btn-menu")}}});x.showAt([r.olmap.mouseMove.x,r.olmap.mouseMove.y])};u={onHoverSelect:i,onHoverUnselect:k,onClickSelect:j};if(l.id==="event"){u.onClickSelect=function o(D){var z=["label","value","nameColumnMap","psi","ps","longitude","latitude","eventdate","ou","oucode","ouname"],x=D.attributes,v=x.nameColumnMap,y='<table class="padding1">',B=' style="font-weight:bold; padding-right:10px; vertical-align:top"',w=' style="max-width:170px"',A;y+="<tr><td"+B+">"+v.ou+"</td><td"+w+">"+x.ouname+"</td></tr>";y+="<tr><td"+B+">"+v.eventdate+"</td><td"+w+">"+x.eventdate+"</td></tr>";y+="<tr><td"+B+">"+v.longitude+"</td><td"+w+">"+x.longitude+"</td></tr>";y+="<tr><td"+B+">"+v.latitude+"</td><td"+w+">"+x.latitude+"</td></tr>";for(var C in x){if(x.hasOwnProperty(C)&&!Ext.Array.contains(z,C)){y+="<tr><td"+B+">"+v[C]+"</td><td>"+x[C]+"</td></tr>"}}y+="</table>";if(Ext.isObject(p)&&p.destroy){A=p.getPosition();p.destroy();p=null}p=Ext.create("Ext.window.Window",{title:"Event",layout:"fit",resizable:false,bodyStyle:"background-color:#fff; padding:5px",html:y,autoShow:true,listeners:{show:function(E){if(A){E.setPosition(A)}else{r.util.gui.window.setPositionTopRight(E)}},destroy:function(){p=null}}})}}m=new OpenLayers.Control.newSelectFeature(l,u);r.olmap.addControl(m);m.activate()};GIS.core.OrganisationUnitLevelStore=function(i){return Ext.create("Ext.data.Store",{fields:["id","name","level"],proxy:{type:"jsonp",url:i.init.contextPath+i.conf.finals.url.path_api+"organisationUnitLevels.jsonp?viewClass=detailed&links=false&paging=false",reader:{type:"json",root:"organisationUnitLevels"}},autoLoad:true,cmp:[],isLoaded:false,loadFn:function(j){if(this.isLoaded){j.call()}else{this.load(j)}},getRecordByLevel:function(j){return this.getAt(this.findExact("level",j))},listeners:{load:function(){if(!this.isLoaded){this.isLoaded=true;i.util.gui.combo.setQueryMode(this.cmp,"local")}this.sort("level","ASC")}}})};GIS.core.StyleMap=function(l,j){var k={fillOpacity:1,strokeColor:"#fff",strokeWidth:1},i={fillOpacity:0.9,strokeColor:"#fff",strokeWidth:1,cursor:"pointer"};if(l==="boundary"){k.fillOpacity=0;k.strokeColor="#000";k.strokeWidth=1;i.fillColor="#000";i.fillOpacity=0.15;i.strokeColor="#000";i.strokeWidth=1}if(j){k.label="${label}";k.fontFamily="arial,sans-serif,ubuntu,consolas";k.fontSize=j.fontSize?j.fontSize+"px":"13px";k.fontWeight=j.strong?"bold":"normal";k.fontStyle=j.italic?"italic":"normal";k.fontColor=j.color?(j.color.split("").shift()!=="#"?"#"+j.color:j.color):"#000000"}return new OpenLayers.StyleMap({"default":k,select:i})};GIS.core.VectorLayer=function(i,m,k,j){var l=new OpenLayers.Layer.Vector(k,{strategies:[new OpenLayers.Strategy.Refresh({force:true})],styleMap:GIS.core.StyleMap(m),visibility:false,displayInLayerSwitcher:false,layerType:i.conf.finals.layer.type_vector,layerOpacity:j?j.opacity||1:1,setLayerOpacity:function(n){if(n){this.layerOpacity=parseFloat(n)}this.setOpacity(this.layerOpacity)},hasLabels:false});l.id=m;return l};GIS.core.MeasureWindow=function(i){var k,j,l,n,m;m=new OpenLayers.StyleMap({"default":new OpenLayers.Style()});n=new OpenLayers.Control.Measure(OpenLayers.Handler.Path,{persist:true,immediate:true,handlerOption:{layerOptions:{styleMap:m}}});l=function(o){if(o.measure){j.setText(o.measure.toFixed(2)+" "+o.units)}};i.olmap.addControl(n);n.events.on({measurepartial:l,measure:l});n.geodesic=true;n.activate();j=Ext.create("Ext.form.Label",{style:"height: 20px",text:"0 km"});k=Ext.create("Ext.window.Window",{title:GIS.i18n.measure_distance,layout:"fit",cls:"gis-container-default gis-plugin",bodyStyle:"text-align: center",width:130,minWidth:130,resizable:false,items:j,listeners:{show:function(){var o=i.viewport.eastRegion.getPosition()[0]-this.getWidth()-3,p=i.viewport.centerRegion.getPosition()[1]+26;this.setPosition(o,p)},destroy:function(){n.deactivate();i.olmap.removeControl(n)}}});return k};GIS.core.MapLoader=function(j){var n,l,o,m,k=[],i;n=function(){Ext.data.JsonP.request({url:j.init.contextPath+j.conf.finals.url.path_api+"maps/"+j.map.id+".jsonp?viewClass=dimensional&links=false",success:function(v){if(Ext.isArray(v.mapViews)){for(var t=0,p;t<v.mapViews.length;t++){p=v.mapViews[t];if(p){if(Ext.isArray(p.columns)&&p.columns.length){for(var s=0,w;s<p.columns.length;s++){w=p.columns[s];if(Ext.isArray(w.items)&&w.items.length){for(var q=0,u;q<w.items.length;q++){u=w.items[q];u.id=u.id.replace(".","-")}}}}}}}j.map=v;l()},failure:function(){j.olmap.mask.hide();alert("Map id not recognized"+(j.el?" ("+j.el+")":""));return}})};l=function(){var q=j.map.mapViews,p;if(!(Ext.isArray(q)&&q.length)){j.olmap.mask.hide();alert(GIS.i18n.favorite_outdated_create_new);return}for(var r=0;r<q.length;r++){q[r]=j.api.layout.Layout(q[r])}q=Ext.Array.clean(q);if(!q.length){return}if(j.viewport&&j.viewport.favoriteWindow&&j.viewport.favoriteWindow.isVisible()){j.viewport.favoriteWindow.destroy()}j.olmap.closeAllLayers();for(var r=0,s;r<q.length;r++){s=q[r];p=j.layer[s.layer].core.getLoader();p.updateGui=!j.el;p.callBack=m;p.load(s)}};m=function(p){k.push(p);if(k.length===j.map.mapViews.length){o()}};o=function(){k=[];if(j.el){j.olmap.zoomToVisibleExtent()}else{if(j.map.longitude&&j.map.latitude&&j.map.zoom){j.olmap.setCenter(new OpenLayers.LonLat(j.map.longitude,j.map.latitude),j.map.zoom)}else{j.olmap.zoomToVisibleExtent()}}if(j.map.id&&j.viewport.shareButton){j.viewport.shareButton.enable()}if(GIS.isSessionStorage){j.util.layout.setSessionStorage("map",j.util.layout.getAnalytical())}j.olmap.mask.hide()};i={load:function(p){j.olmap.mask.show();if(j.map&&j.map.id){n()}else{if(p){j.map={mapViews:p}}l()}}};return i};GIS.core.LayerLoaderEvent=function(r,k){var j=k.map,l,n,m,i,q,o,p=r.conf.finals.dimension;n=function(s){m(s)};m=function(s){s=s||k.core.view;var w="?",v=[];w+="stage="+s.stage.id;w+="&startDate="+s.startDate;w+="&endDate="+s.endDate;if(Ext.isArray(s.organisationUnits)){for(var u=0;u<s.organisationUnits.length;u++){w+="&dimension=ou:"+s.organisationUnits[u].id}}for(var u=0,t;u<s.dataElements.length;u++){t=s.dataElements[u];w+="&dimension="+t.id;if(t.value){if(t.operator){w+=":"+t.operator}w+=":"+t.value}}Ext.data.JsonP.request({url:r.init.contextPath+"/api/analytics/events/query/"+s.program.id+".jsonp"+w,disableCaching:false,scope:this,success:function(y){var H=[],B=[],J=[],x,C,A=Ext.clone(y.metaData.names);for(var F=0;F<y.headers.length;F++){A[y.headers[F].name]=y.headers[F].column;if(y.headers[F].name==="longitude"){x=F}if(y.headers[F].name==="latitude"){C=F}}if(Ext.isArray(y.rows)&&y.rows.length){for(var F=0,I;F<y.rows.length;F++){I=y.rows[F];if(I[x]&&I[C]){J.push(I)}}}if(!J.length){alert("No coordinates found");j.mask.hide();return}A=Ext.clone(y.metaData.names);for(var F=0;F<y.headers.length;F++){A[y.headers[F].name]=y.headers[F].column}for(var F=0,I,E;F<J.length;F++){I=J[F];E={};for(var D=0;D<I.length;D++){E[y.headers[D].name]=I[D]}E[r.conf.finals.widget.value]=0;E.label=E.ouname;E.nameColumnMap=A;H.push(E)}for(var F=0,z,G;F<H.length;F++){z=H[F];G=r.util.map.getTransformedPointByXY(z.longitude,z.latitude);B.push(new OpenLayers.Feature.Vector(G,z))}k.removeFeatures(k.features);k.addFeatures(B);i(s)}})};i=function(s){s=s||k.core.view;var t={indicator:r.conf.finals.widget.value,method:2,numClasses:5,colors:k.core.getColors("000000","222222"),minSize:5,maxSize:5};k.core.view=s;k.core.applyClassification(t);q(s)};q=function(s){if(k.item){k.item.setValue(true,s.opacity)}else{k.setLayerOpacity(s.opacity)}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(s)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{r.map=null}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();n(s)},loadData:m,loadLegend:i};return o};GIS.core.LayerLoaderFacility=function(r,l){var j=l.map,m,o,n,i,k,q,p;m=function(u,x){var z=l.core.view,y,t,s,v;p.zoomToVisibleExtent=true;if(!z){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.rows[0];s=[];v=z.rows[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}p.zoomToVisibleExtent=false;if(u.organisationUnitGroupSet.id!==z.organisationUnitGroupSet.id){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}if(x){i(u);return r.conf.finals.widget.loadtype_legend}};o=function(s){var t=s.rows[0].items,v="";for(var u=0;u<t.length;u++){v+="ids="+t[u].id;v+=u!==t.length-1?"&":""}Ext.data.JsonP.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getGeoJsonFacilities.action?"+v,scope:this,disableCaching:false,success:function(y){var w=l.core.decode(y),z=new OpenLayers.Format.GeoJSON(),x=r.util.map.getTransformedFeatureArray(z.read(w));if(!Ext.isArray(x)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!x.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}l.core.featureStore.loadFeatures(x.slice(0));n(s,x)},failure:function(w){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};n=function(s,u){s=s||l.core.view;u=u||l.core.featureStore.features;for(var t=0;t<u.length;t++){u[t].attributes.label=u[t].attributes.name}l.removeFeatures(l.features);l.addFeatures(u);i(s)};i=function(s){s=s||l.core.view;var t=r.store.groupsByGroupSet;t.proxy.url=r.init.contextPath+r.conf.finals.url.path_module+"getOrganisationUnitGroupsByGroupSet.action?id="+s.organisationUnitGroupSet.id;t.load({scope:this,callback:function(){var u={indicator:s.organisationUnitGroupSet.id};l.core.view=s;l.core.applyClassification(u);k(s);q(s)}})};k=function(t){var s=t.areaRadius;if(l.circleLayer){l.circleLayer.deactivateControls();l.circleLayer=null}if(Ext.isDefined(s)&&s){l.circleLayer=GIS.app.CircleLayer(l.features,s);nissa=l.circleLayer}};q=function(s){r.viewport.eastRegion.doLayout();l.legendPanel.expand();if(l.item){l.item.setValue(true,s.opacity)}else{l.setLayerOpacity(s.opacity)}if(p.updateGui&&Ext.isObject(l.widget)){l.widget.setGui(s)}if(p.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(p.hideMask){j.mask.hide()}if(p.callBack){p.callBack(l)}else{r.map=null}};p={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();if(this.compare){m(s,true)}else{o(s)}},loadData:n,loadLegend:i};return p};GIS.core.LayerLoaderBoundary=function(q,k){var j=k.map,l,n,m,i,p,o;l=function(t,w){var y=k.core.view,x,s,r,u;if(!y){if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}x=[];s=t.rows[0];r=[];u=y.rows[0];if(s.items.length===u.items.length){for(var v=0;v<s.items.length;v++){x.push(s.items[v].id)}for(var v=0;v<u.items.length;v++){r.push(u.items[v].id)}if(Ext.Array.difference(x,r).length!==0){if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}}else{if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}q.olmap.mask.hide()};n=function(r){var s=r.rows[0].items,u="";for(var t=0;t<s.length;t++){u+="ids="+s[t].id;u+=t!==s.length-1?"&":""}Ext.data.JsonP.request({url:q.init.contextPath+q.conf.finals.url.path_module+"getGeoJson.action?"+u,scope:this,disableCaching:false,success:function(x){var v=q.util.geojson.decode(x),y=new OpenLayers.Format.GeoJSON(),w=q.util.map.getTransformedFeatureArray(y.read(v));if(!Ext.isArray(w)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!w.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}k.core.featureStore.loadFeatures(w.slice(0));m(r,w)},failure:function(v){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};m=function(r,t){r=r||k.core.view;t=t||k.core.featureStore.features;for(var s=0;s<t.length;s++){t[s].attributes.label=t[s].attributes.name;t[s].attributes.value=0}k.removeFeatures(k.features);k.addFeatures(t);i(r)};i=function(r){r=r||k.core.view;var s={indicator:q.conf.finals.widget.value,method:2,numClasses:5,colors:k.core.getColors("000000","000000"),minSize:6,maxSize:6};if(r.labels){if(Ext.isObject(r.labels)){k.styleMap=GIS.core.StyleMap(k.id,r.labels)}else{k.styleMap=GIS.core.StyleMap(k.id,{fontSize:12,strong:false,italic:false,color:"#000"})}}k.core.view=r;k.core.applyClassification(s);p(r)};p=function(r){if(k.item){k.item.setValue(true,r.opacity)}else{k.setLayerOpacity(r.opacity)}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(r)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{q.map=null}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(r){q.olmap.mask.show();if(this.compare){l(r,true)}else{n(r)}},loadData:m,loadLegend:i};return o};GIS.core.LayerLoaderThematic=function(r,k){var j=k.map,l,n,m,i,q,o,p=r.conf.finals.dimension;l=function(u,x){var z=k.core.view,y,t,s,v;o.zoomToVisibleExtent=true;if(!z){if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.rows[0];s=[];v=z.rows[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}o.zoomToVisibleExtent=false;y=[];t=u.columns[0];s=[];v=z.columns[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.filters[0];s=[];v=z.filters[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}if(x){o.zoomToVisibleExtent=false;i(u);return r.conf.finals.widget.loadtype_legend}};n=function(s){var t=s.rows[0].items,v="";for(var u=0;u<t.length;u++){v+="ids="+t[u].id;v+=u!==t.length-1?"&":""}Ext.data.JsonP.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getGeoJson.action?"+v,scope:this,disableCaching:false,success:function(y){var w=r.util.geojson.decode(y),z=new OpenLayers.Format.GeoJSON(),x=r.util.map.getTransformedFeatureArray(z.read(w));if(!Ext.isArray(x)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!x.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}k.core.featureStore.loadFeatures(x.slice(0));m(s,x)},failure:function(w){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};m=function(z,u){var B;z=z||k.core.view;u=u||k.core.featureStore.features;var A=r.conf.finals.dimension,v="?",w=z.columns[0].items,s=z.columns[0].dimension===A.operand.objectName,t=z.filters[0].items,y=z.rows[0].items;v+="dimension=ou:";for(var x=0;x<y.length;x++){v+=y[x].id;v+=x<y.length-1?";":""}v+="&dimension=dx:";for(var x=0;x<w.length;x++){v+=s?w[x].id.split("-")[0]:w[x].id;v+=x<w.length-1?";":""}v+=s?"&dimension=co":"";v+="&filter=pe:";for(var x=0;x<t.length;x++){v+=t[x].id;v+=x<t.length-1?";":""}B=function(O){var H=r.api.response.Response(O),M={},E={},J,G,L,F=[],C,K=[];if(!H){j.mask.hide();return}for(var I=0;I<H.headers.length;I++){if(H.headers[I].name===A.organisationUnit.dimensionName){J=I}else{if(H.headers[I].name===A.value.dimensionName){L=I}}}for(var I=0,D;I<u.length;I++){var D=u[I].attributes.id;M[D]=true}for(var I=0;I<H.rows.length;I++){var D=H.rows[I][J],N=parseFloat(H.rows[I][L]);E[D]=N}for(var I=0;I<u.length;I++){var P=u[I],D=P.attributes.id;if(M.hasOwnProperty(D)&&E.hasOwnProperty(D)){P.attributes.value=E[D];P.attributes.label=P.attributes.name+" ("+P.attributes.value+")";F.push(P)}}k.removeFeatures(k.features);k.addFeatures(F);r.response=H;i(z)};if(Ext.isObject(GIS.app)){Ext.Ajax.request({url:r.init.contextPath+"/api/analytics.json"+v,disableCaching:false,failure:function(C){alert(C.responseText)},success:function(C){B(Ext.decode(C.responseText))}})}else{if(Ext.isObject(GIS.plugin)){Ext.data.JsonP.request({url:r.init.contextPath+"/api/analytics.jsonp"+v,disableCaching:false,scope:this,success:function(C){B(C)}})}}};i=function(u){var w,y,v;u=u||k.core.view;y=function(C){var A=Ext.Array.clean([].concat(u.columns||[],u.rows||[],u.filters||[])),B=C.metaData,H=B[p.period.objectName];for(var F=0,D;F<A.length;F++){D=A[F];for(var E=0,G;E<D.items.length;E++){G=D.items[E];if(G.id.indexOf("-")!==-1){var z=G.id.split("-");G.name=B.names[z[0]]+" "+B.names[z[1]]}else{G.name=B.names[G.id]}}}u.filters[0].items[0].name=B.names[H[H.length-1]]};v=function(){y(r.response);var z={indicator:r.conf.finals.widget.value,method:u.legendSet?mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:u.method,numClasses:u.classes,bounds:w,colors:k.core.getColors(u.colorLow,u.colorHigh),minSize:u.radiusLow,maxSize:u.radiusHigh};k.core.view=u;k.core.colorInterpolation=t;k.core.applyClassification(z);q(u)};if(u.labels){if(Ext.isObject(u.labels)){k.styleMap=GIS.core.StyleMap(k.id,u.labels)}else{k.styleMap=GIS.core.StyleMap(k.id,{fontSize:12,strong:false,italic:false,color:"#000"})}}if(u.legendSet){var w=[],t=[],x=[],s=[];Ext.Ajax.request({url:r.init.contextPath+r.conf.finals.url.path_api+"mapLegendSets/"+u.legendSet.id+".json?links=false&paging=false",scope:this,success:function(A){s=Ext.decode(A.responseText).mapLegends;Ext.Array.sort(s,function(C,B){return C.startValue-B.startValue});for(var z=0;z<s.length;z++){if(w[w.length-1]!==s[z].startValue){if(w.length!==0){t.push(new mapfish.ColorRgb(240,240,240));x.push("")}w.push(s[z].startValue)}t.push(new mapfish.ColorRgb());t[t.length-1].setFromHex(s[z].color);x.push(s[z].name);w.push(s[z].endValue)}u.legendSet.names=x;u.legendSet.bounds=w;u.legendSet.colors=t;v()}})}else{v()}};q=function(s){r.viewport.eastRegion.doLayout();k.legendPanel.expand();k.setLayerOpacity(s.opacity);if(k.item){k.item.setValue(true)}if(k.filterWindow&&k.filterWindow.isVisible()){k.filterWindow.filter()}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(s)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{r.map=null;if(r.viewport.shareButton){}}if(GIS.isSessionStorage){r.util.layout.setSessionStorage("map",r.util.layout.getAnalytical())}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();if(this.compare){l(s,true)}else{n(s)}},loadData:m,loadLegend:i};return o};GIS.core.getInstance=function(o){var l={},j={},m={},k={},n=[],i={};(function(){l.finals={url:{path_api:"/api/",path_module:"/dhis-web-mapping/",path_commons:"/dhis-web-commons-ajax-json/",organisationunitchildren_get:"getOrganisationUnitChildren.action",organisationunitgroup_getall:"organisationUnitGroups.json?paging=false&links=false",dataset_get:"dataSets.json?paging=false&links=false"},layer:{type_base:"base",type_vector:"vector",category_thematic:"thematic"},dimension:{data:{id:"data",value:"data",param:"dx",dimensionName:"dx",objectName:"dx"},category:{name:GIS.i18n.categories,dimensionName:"co",objectName:"co"},indicator:{id:"indicator",value:"indicators",param:"in",dimensionName:"dx",objectName:"in"},dataElement:{id:"dataElement",value:"dataElement",param:"de",dimensionName:"dx",objectName:"de"},operand:{id:"operand",value:"operand",param:"dc",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataSets",dimensionName:"dx",objectName:"ds"},period:{id:"period",value:"period",param:"pe",dimensionName:"pe",objectName:"pe"},organisationUnit:{id:"organisationUnit",value:"organisationUnit",param:"ou",dimensionName:"ou",objectName:"ou"},value:{id:"value",value:"value",param:"value",dimensionName:"value",objectName:"value"}},widget:{value:"value",legendtype_automatic:"automatic",legendtype_predefined:"predefined",symbolizer_color:"color",symbolizer_image:"image",loadtype_organisationunit:"organisationUnit",loadtype_data:"data",loadtype_legend:"legend"},openLayers:{point_classname:"OpenLayers.Geometry.Point"},mapfish:{classify_with_bounds:1,classify_by_equal_intervals:2,classify_by_quantils:3},root:{id:"root"}};l.layout={widget:{item_width:288,itemlabel_width:95,window_width:310},tool:{item_width:228,itemlabel_width:95,window_width:250},grid:{row_height:27}};l.period={periodTypes:[{id:"relativePeriods",name:GIS.i18n.relative},{id:"Daily",name:GIS.i18n.daily},{id:"Weekly",name:GIS.i18n.weekly},{id:"Monthly",name:GIS.i18n.monthly},{id:"BiMonthly",name:GIS.i18n.bimonthly},{id:"Quarterly",name:GIS.i18n.quarterly},{id:"SixMonthly",name:GIS.i18n.sixmonthly},{id:"Yearly",name:GIS.i18n.yearly},{id:"FinancialOct",name:GIS.i18n.financial_oct},{id:"FinancialJuly",name:GIS.i18n.financial_july},{id:"FinancialApril",name:GIS.i18n.financial_april}],relativePeriods:[{id:"LAST_WEEK",name:GIS.i18n.last_week},{id:"LAST_MONTH",name:GIS.i18n.last_month},{id:"LAST_BIMONTH",name:GIS.i18n.last_bimonth},{id:"LAST_QUARTER",name:GIS.i18n.last_quarter},{id:"LAST_SIX_MONTH",name:GIS.i18n.last_sixmonth},{id:"LAST_FINANCIAL_YEAR",name:GIS.i18n.last_financial_year},{id:"THIS_YEAR",name:GIS.i18n.this_year},{id:"LAST_YEAR",name:GIS.i18n.last_year}],relativePeriodsMap:{LAST_WEEK:{id:"LAST_WEEK",name:GIS.i18n.last_week},LAST_MONTH:{id:"LAST_MONTH",name:GIS.i18n.last_month},LAST_BIMONTH:{id:"LAST_BIMONTH",name:GIS.i18n.last_bimonth},LAST_QUARTER:{id:"LAST_QUARTER",name:GIS.i18n.last_quarter},LAST_SIX_MONTH:{id:"LAST_SIX_MONTH",name:GIS.i18n.last_sixmonth},LAST_FINANCIAL_YEAR:{id:"LAST_FINANCIAL_YEAR",name:GIS.i18n.last_financial_year},THIS_YEAR:{id:"THIS_YEAR",name:GIS.i18n.this_year},LAST_YEAR:{id:"LAST_YEAR",name:GIS.i18n.last_year}},integratedRelativePeriodsMap:{LAST_WEEK:"LAST_WEEK",LAST_4_WEEKS:"LAST_WEEK",LAST_12_WEEKS:"LAST_WEEK",LAST_MONTH:"LAST_MONTH",LAST_3_MONTHS:"LAST_MONTH",LAST_12_MONTHS:"LAST_MONTH",LAST_BIMONTH:"LAST_BIMONTH",LAST_6_BIMONTHS:"LAST_BIMONTH",LAST_QUARTER:"LAST_QUARTER",LAST_4_QUARTERS:"LAST_QUARTER",LAST_SIX_MONTH:"LAST_SIX_MONTH",LAST_2_SIXMONTHS:"LAST_SIX_MONTH",LAST_FINANCIAL_YEAR:"LAST_FINANCIAL_YEAR",LAST_5_FINANCIAL_YEARS:"LAST_FINANCIAL_YEAR",THIS_YEAR:"THIS_YEAR",LAST_YEAR:"LAST_YEAR",LAST_5_YEARS:"LAST_YEAR"}}}());(function(){j.map={};j.map.getVisibleVectorLayers=function(){var r=[];for(var q=0,p;q<i.olmap.layers.length;q++){p=i.olmap.layers[q];if(p.layerType===l.finals.layer.type_vector&&p.visibility&&p.features.length){r.push(p)}}return r};j.map.getExtendedBounds=function(r){var q=null;if(r.length){q=r[0].getDataExtent();if(r.length>1){for(var p=1;p<r.length;p++){q.extend(r[p].getDataExtent())}}}return q};j.map.zoomToVisibleExtent=function(q){var p=j.map.getExtendedBounds(j.map.getVisibleVectorLayers(q));if(p){q.zoomToExtent(p)}};j.map.getTransformedFeatureArray=function(s){var p=new OpenLayers.Projection("EPSG:4326"),q=new OpenLayers.Projection("EPSG:900913");for(var r=0;r<s.length;r++){s[r].geometry.transform(p,q)}return s};j.geojson={};j.geojson.decode=function(r){var p={};p.type="FeatureCollection";p.crs={type:"EPSG",properties:{code:"4326"}};p.features=[];for(var q=0;q<r.geojson.length;q++){p.features.push({geometry:{type:parseInt(r.geojson[q].ty)===1?"MultiPolygon":"Point",coordinates:r.geojson[q].co},properties:{id:r.geojson[q].uid,internalId:r.geojson[q].iid,name:r.geojson[q].na,hasCoordinatesDown:r.geojson[q].hcd,hasCoordinatesUp:r.geojson[q].hcu,level:r.geojson[q].le,grandParentParentGraph:r.geojson[q].gppg,grandParentId:r.geojson[q].gpuid,parentGraph:r.geojson[q].parentGraph,parentId:r.geojson[q].pi,parentName:r.geojson[q].pn}})}return p};j.gui={};j.gui.combo={};j.gui.combo.setQueryMode=function(p,r){for(var q=0;q<p.length;q++){p[q].queryMode=r}};j.object={};j.object.sortObjectsByString=function(q,p){p=p||"name";q.sort(function(s,r){var u=s[p].toLowerCase(),t=r[p].toLowerCase();if(u<t){return -1}if(u>t){return 1}return 0});return q};j.object.getLength=function(p){var r=0;for(var q in p){if(p.hasOwnProperty(q)){r++}}return r}}());i.init=o;i.conf=l;i.util=j;(function(){var p=i.conf.finals.dimension;m.layout={};m.response={};m.layout.Record=function(r){var q={};return function(){if(!Ext.isObject(r)){console.log("Record config is not an object: "+r);return}if(!Ext.isString(r.id)){alert("Record id is not text: "+r);return}q.id=r.id.replace(".","-");if(Ext.isString(r.name)){q.name=r.name}return Ext.clone(q)}()};m.layout.Dimension=function(q){var r={};return function(){if(!Ext.isObject(q)){return}if(!Ext.isString(q.dimension)){console.log("Dimension name is not text: "+q);return}if(q.dimension!==l.finals.dimension.category.objectName){var s=[];if(!Ext.isArray(q.items)){console.log("Dimension items is not an array: "+q);return}for(var t=0;t<q.items.length;t++){record=m.layout.Record(q.items[t]);if(record){s.push(record)}}q.items=s;if(!q.items.length){console.log("Dimension has no valid items: "+q);return}}r.dimension=q.dimension;r.items=q.items;return Ext.clone(r)}()};m.layout.Layout=function(r){var r=Ext.clone(r),s={},q,t;q=function(x){var v=[];if(!(x&&Ext.isArray(x)&&x.length)){return}for(var u=0,w;u<x.length;u++){w=m.layout.Dimension(x[u]);if(w){v.push(w)}}x=v;return x.length?x:null};t=function(w){var y=Ext.Array.clean([].concat(w.columns||[],w.rows||[],w.filters||[])),A=l.period.integratedRelativePeriodsMap,v,B,u;for(var x=0,z;x<y.length;x++){z=y[x];if(z.dimension===p.indicator.objectName||z.dimension===p.dataElement.objectName||z.dimension===p.operand.objectName||z.dimension===p.dataSet.objectName){v=z}else{if(z.dimension===p.period.objectName){B=z}else{if(z.dimension===p.organisationUnit.objectName){u=z}}}}if(!u){alert("No organisation units specified");return}if(v){v.items=[v.items[0]]}if(B){B.items=[B.items[0]];B.items[0].id=A[B.items[0].id]?A[B.items[0].id]:B.items[0].id}w.columns=[v];w.rows=[u];w.filters=[B];return w};return function(){var A=[],z=[],C=l.finals.dimension,v=false,u=false,D=false;r=t(r);if(!r){return}r.columns=q(r.columns);r.rows=q(r.rows);r.filters=q(r.filters);if(!r.rows){console.log("Organisation unit dimension is invalid");return}for(var x=0,y,B=Ext.Array.clean([].concat(r.columns,r.rows,r.filters));x<B.length;x++){y=B[x];if(y){if(Ext.isString(y.dimension)){z.push(y.dimension)}if(y.dimension===C.organisationUnit.objectName&&Ext.isArray(y.items)){for(var w=0;w<y.items.length;w++){if(y.items[w].id==="USER_ORGUNIT"){v=true}else{if(y.items[w].id==="USER_ORGUNIT_CHILDREN"){u=true}else{if(y.items[w].id==="USER_ORGUNIT_GRANDCHILDREN"){D=true}}}}}}}s.columns=r.columns;s.rows=r.rows;s.filters=r.filters;s.layer=Ext.isString(r.layer)&&!Ext.isEmpty(r.layer)?r.layer:"thematic1";s.classes=Ext.isNumber(r.classes)&&!Ext.isEmpty(r.classes)?r.classes:5;s.method=Ext.isNumber(r.method)&&!Ext.isEmpty(r.method)?r.method:2;s.colorLow=Ext.isString(r.colorLow)&&!Ext.isEmpty(r.colorLow)?r.colorLow:"ff0000";s.colorHigh=Ext.isString(r.colorHigh)&&!Ext.isEmpty(r.colorHigh)?r.colorHigh:"00ff00";s.radiusLow=Ext.isNumber(r.radiusLow)&&!Ext.isEmpty(r.radiusLow)?r.radiusLow:5;s.radiusHigh=Ext.isNumber(r.radiusHigh)&&!Ext.isEmpty(r.radiusHigh)?r.radiusHigh:15;s.opacity=Ext.isNumber(r.opacity)&&!Ext.isEmpty(r.opacity)?r.opacity:0.8;s.userOrganisationUnit=v;s.userOrganisationUnitChildren=u;s.userOrganisationUnitGrandChildren=D;s.parentGraphMap=Ext.isObject(r.parentGraphMap)?r.parentGraphMap:null;s.legendSet=r.legendSet;s.labels=r.labels;s.organisationUnitGroupSet=r.organisationUnitGroupSet;s.areaRadius=r.areaRadius;return s}()};m.response.Header=function(q){var r={};return function(){if(!Ext.isObject(q)){console.log("Header is not an object: "+q);return}if(!Ext.isString(q.name)){console.log("Header name is not text: "+q);return}if(!Ext.isBoolean(q.meta)){console.log("Header meta is not boolean: "+q);return}r.name=q.name;r.meta=q.meta;return Ext.clone(r)}()};m.response.Response=function(r){var q={};return function(){var t=[];if(!(r&&Ext.isObject(r))){alert("Data response invalid");return false}if(!(r.headers&&Ext.isArray(r.headers))){alert("Data response invalid");return false}for(var s=0,u;s<r.headers.length;s++){u=m.response.Header(r.headers[s]);if(u){t.push(u)}}r.headers=t;if(!r.headers.length){alert("No valid response headers");return}if(!(Ext.isArray(r.rows)&&r.rows.length>0)){alert("No values found");return false}if(r.headers.length!==r.rows[0].length){alert("Data invalid");return false}q.headers=r.headers;q.metaData=r.metaData;q.width=r.width;q.height=r.height;q.rows=r.rows;return q}()}}());(function(){k.organisationUnitLevels=GIS.core.OrganisationUnitLevelStore(i)}());i.api=m;i.store=k;i.olmap=GIS.core.getOLMap(i);i.layer=GIS.core.getLayers(i);i.thematicLayers=[i.layer.thematic1,i.layer.thematic2,i.layer.thematic3,i.layer.thematic4];if(window.google){n.push(i.layer.googleStreets,i.layer.googleHybrid)}n.push(i.layer.openStreetMap,i.layer.thematic4,i.layer.thematic3,i.layer.thematic2,i.layer.thematic1,i.layer.boundary,i.layer.facility,i.layer.event);i.olmap.addLayers(n);GIS.core.instances.push(i);e=i.layer.event;return i};(function(){window.mapfish={_scriptName:"MapFish.js",_getScriptLocation:function(){if(window.gMfLocation){return window.gMfLocation}var t="";var u=mapfish._scriptName;var q=document.getElementsByTagName("script");for(var s=0;s<q.length;s++){var v=q[s].getAttribute("src");if(v){var r=v.lastIndexOf(u);if((r>-1)&&(r+u.length==v.length)){t=v.slice(0,-u.length);break}}}return t}};var o=new Array("core/Color.js","core/GeoStat.js","core/GeoStat/Boundary.js","core/GeoStat/Thematic1.js","core/GeoStat/Thematic2.js","core/GeoStat/Facility.js","core/GeoStat/Symbol.js","core/Util.js");var p="";var n=mapfish._getScriptLocation();for(var j=0;j<o.length;j++){if(/MSIE/.test(navigator.userAgent)||/Safari/.test(navigator.userAgent)){var m="<script src='"+n+o[j]+"'><\/script>";p+=m}else{var l=document.createElement("script");l.src=n+o[j];var k=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;k.appendChild(l)}}if(p){}mapfish.Color=OpenLayers.Class({getColorRgb:function(){}});mapfish.ColorRgb=OpenLayers.Class(mapfish.Color,{redLevel:null,greenLevel:null,blueLevel:null,initialize:function(r,q,i){this.redLevel=r;this.greenLevel=q;this.blueLevel=i},equals:function(i){return i.redLevel==this.redLevel&&i.greenLevel==this.greenLevel&&i.blueLevel==this.blueLevel},getColorRgb:function(){return this},getRgbArray:function(){return[this.redLevel,this.greenLevel,this.blueLevel]},hex2rgbArray:function(q){if(q.charAt(0)=="#"){q=q.substr(1)}var r=[parseInt(q.substring(0,2),16),parseInt(q.substring(2,4),16),parseInt(q.substring(4,6),16)];for(var s=0;s<r.length;s++){if(r[s]<0||r[s]>255){OpenLayers.Console.error("Invalid rgb hex color string: rgbHexString")}}return r},setFromHex:function(i){var q=this.hex2rgbArray(i);this.redLevel=q[0];this.greenLevel=q[1];this.blueLevel=q[2]},setFromRgb:function(q){var i=dojo.colorFromString(q);this.redLevel=i.r;this.greenLevel=i.g;this.blueLevel=i.b},toHexString:function(){var s=this.toHex(this.redLevel);var q=this.toHex(this.greenLevel);var i=this.toHex(this.blueLevel);return"#"+s+q+i},toHex:function(u){var r="0123456789ABCDEF";if(u<0||u>255){var t="Invalid decimal value for color level";OpenLayers.Console.error(t)}var s=Math.floor(u/16);var q=u%16;return r.charAt(s)+r.charAt(q)},CLASS_NAME:"mapfish.ColorRgb"});mapfish.ColorRgb.getColorsArrayByRgbInterpolation=function(y,t,v){var z=[];var r=y.getColorRgb();var q=t.getColorRgb();var x=r.getRgbArray();var w=q.getRgbArray();if(v==1){return[r]}for(var u=0;u<v;u++){var s=[];s[0]=x[0]+u*(w[0]-x[0])/(v-1);s[1]=x[1]+u*(w[1]-x[1])/(v-1);s[2]=x[2]+u*(w[2]-x[2])/(v-1);z[u]=new mapfish.ColorRgb(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]))}return z};mapfish.Util={};mapfish.Util.sum=function(s){for(var q=0,r=0;q<s.length;r+=s[q++]){}return r};mapfish.Util.max=function(i){return Math.max.apply({},i)};mapfish.Util.min=function(i){return Math.min.apply({},i)};mapfish.Util.getIconUrl=function(q,i){if(!i.layer){OpenLayers.Console.warn("Missing required layer option in mapfish.Util.getIconUrl");return""}if(!i.rule){i.rule=i.layer}if(q.indexOf("?")<0){q+="?"}else{if(q.lastIndexOf("&")!=(q.length-1)){if(q.indexOf("?")!=(q.length-1)){q+="&"}}}var i=OpenLayers.Util.extend({layer:"",rule:"",service:"WMS",version:"1.1.1",request:"GetLegendGraphic",format:"image/png",width:16,height:16},i);i=OpenLayers.Util.upperCaseObject(i);return q+OpenLayers.Util.getParameterString(i)};mapfish.Util.arrayEqual=function(r,q){if(r==null||q==null){return false}if(typeof(r)!="object"||typeof(q)!="object"){return false}if(r.length!=q.length){return false}for(var s=0;s<r.length;s++){if(typeof(r[s])!=typeof(q[s])){return false}if(r[s]!=q[s]){return false}}return true};mapfish.Util.isIE7=function(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie 7")>-1};mapfish.Util.relativeToAbsoluteURL=function(q){if(/^\w+:/.test(q)||!q){return q}var i=location.protocol+"//"+location.host;if(q.indexOf("/")==0){return i+q}var r=location.pathname.replace(/\/[^\/]*$/,"");return i+r+"/"+q};mapfish.Util.fixArray=function(i){if(i==""||i==null){return[]}else{if(i instanceof Array){return i}else{return i.split(",")}}};mapfish.GeoStat=OpenLayers.Class({layer:null,format:null,url:null,requestSuccess:function(i){},requestFailure:function(i){},indicator:null,defaultSymbolizer:{},legendDiv:null,initialize:function(r,i){this.map=r;this.addOptions(i);if(!this.layer){var q=new OpenLayers.Layer.Vector("geostat",{displayInLayerSwitcher:false,visibility:false});r.addLayer(q);this.layer=q}this.setUrl(this.url);this.legendDiv=Ext.get(i.legendDiv)},setUrl:function(i){this.url=i;if(this.url){OpenLayers.Request.GET({url:this.url,scope:this,success:this.requestSuccess,failure:this.requestFailure})}},getColors:function(i,r){var s=new mapfish.ColorRgb(),q=new mapfish.ColorRgb();s.setFromHex(i);q.setFromHex(r);return[s,q]},addOptions:function(i){if(i){if(!this.options){this.options={}}OpenLayers.Util.extend(this.options,i);OpenLayers.Util.extend(this,i)}},extendStyle:function(s,r,i){var q=this.layer.styleMap.styles["default"];if(s){q.rules=s}if(r){q.setDefaultStyle(OpenLayers.Util.applyDefaults(r,q.defaultStyle))}if(i){if(!q.context){q.context={}}OpenLayers.Util.extend(q.context,i)}},applyClassification:function(i){this.layer.renderer.clear();this.layer.redraw();this.updateLegend();this.layer.setVisibility(true)},showDetails:function(i){},hideDetails:function(i){},CLASS_NAME:"mapfish.GeoStat"});mapfish.GeoStat.Distribution=OpenLayers.Class({labelGenerator:function(q,s,t){var i=parseFloat(q.lowerBound).toFixed(1),r=parseFloat(q.upperBound).toFixed(1);return i+" - "+r+"&nbsp;&nbsp;("+q.nbVal+")"},values:null,nbVal:null,minVal:null,maxVal:null,initialize:function(i,q){OpenLayers.Util.extend(this,q);this.values=i;this.nbVal=i.length;this.minVal=this.nbVal?mapfish.Util.min(this.values):0;this.maxVal=this.nbVal?mapfish.Util.max(this.values):0},classifyWithBounds:function(q){var z=[];var w=[];var y=[];for(var v=0;v<this.values.length;v++){y.push(this.values[v])}y.sort(function(A,i){return A-i});var x=q.length-1;for(var u=0;u<x;u++){w[u]=0}for(var t=0;t<x-1;t){if(y[0]<q[t+1]){w[t]=w[t]+1;y.shift()}else{t++}}w[x-1]=this.nbVal-mapfish.Util.sum(w);for(var s=0;s<x;s++){z[s]=new mapfish.GeoStat.Bin(w[s],q[s],q[s+1],s==(x-1));var r=this.labelGenerator||this.defaultLabelGenerator;z[s].label=r(z[s],s,x)}return new mapfish.GeoStat.Classification(z)},classifyByEqIntervals:function(s){var r=[];for(var q=0;q<=s;q++){r[q]=this.minVal+q*(this.maxVal-this.minVal)/s}return this.classifyWithBounds(r)},classifyByQuantils:function(u){var i=this.values;i.sort(function(w,v){return w-v});var t=Math.round(this.values.length/u);var s=[];var r=(t===0)?0:t;if(i.length>0){s[0]=i[0];for(j=1;j<u;j++){s[j]=i[r];r+=t}s.push(i[i.length-1])}for(var q=0;q<s.length;q++){s[q]=parseFloat(s[q])}return this.classifyWithBounds(s)},sturgesRule:function(){return Math.floor(1+3.3*Math.log(this.nbVal,10))},classify:function(s,r,i){var q=null;if(!r){r=this.sturgesRule()}switch(parseFloat(s)){case mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:q=this.classifyWithBounds(i);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS:q=this.classifyByEqIntervals(r);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS:q=this.classifyByQuantils(r);break;default:OpenLayers.Console.error("Unsupported or invalid classification method")}return q},CLASS_NAME:"mapfish.GeoStat.Distribution"});mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS=1;mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS=2;mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS=3;mapfish.GeoStat.Bin=OpenLayers.Class({label:null,nbVal:null,lowerBound:null,upperBound:null,isLast:false,initialize:function(r,s,q,i){this.nbVal=r;this.lowerBound=s;this.upperBound=q;this.isLast=i},CLASS_NAME:"mapfish.GeoStat.Bin"});mapfish.GeoStat.Classification=OpenLayers.Class({bins:[],initialize:function(i){this.bins=i},getBoundsArray:function(){var r=[];for(var q=0;q<this.bins.length;q++){r.push(this.bins[q].lowerBound)}if(this.bins.length>0){r.push(this.bins[this.bins.length-1].upperBound)}return r},CLASS_NAME:"mapfish.GeoStat.Classification"});mapfish.GeoStat.Event=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:4,maxSize:4,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderEvent(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},getLegendConfig:function(){return},getImageLegendConfig:function(){return},updateOptions:function(q){var i=OpenLayers.Util.extend({},this.options);this.addOptions(q);if(q){this.setClassification()}},createColorInterpolation:function(){var i=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],i)},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;this.classification=t.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(q){this.updateOptions(q);var v=OpenLayers.Function.bind(function(w){var x=w.attributes[this.indicator];var i=(x-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return i||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:v});var t=this.classification.getBoundsArray();var u=new Array(t.length-1);for(var r=0;r<t.length-1;r++){var s=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:t[r],upperBoundary:t[r+1]})});u[r]=s}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){},CLASS_NAME:"mapfish.GeoStat.Event"});mapfish.GeoStat.Boundary=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderBoundary(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},getLegendConfig:function(){return},getImageLegendConfig:function(){return},updateOptions:function(q){var i=OpenLayers.Util.extend({},this.options);this.addOptions(q);if(q){this.setClassification()}},createColorInterpolation:function(){var i=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],i)},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;this.classification=t.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(q){this.updateOptions(q);var v=OpenLayers.Function.bind(function(w){var x=w.attributes[this.indicator];var i=(x-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return i||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:v});var t=this.classification.getBoundsArray();var u=new Array(t.length-1);for(var r=0;r<t.length-1;r++){var s=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:t[r],upperBoundary:t[r+1]})});u[r]=s}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){},CLASS_NAME:"mapfish.GeoStat.Boundary"});mapfish.GeoStat.Facility=OpenLayers.Class(mapfish.GeoStat,{classification:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderFacility(this.gis,this.layer)},decode:function(v){var t,u,q,r={type:"FeatureCollection",crs:{type:"EPSG",properties:{code:"4326"}},features:[]};for(var s=0;s<v.geojson.length;s++){q=v.geojson[s];t={geometry:{type:parseInt(q.ty)===1?"MultiPolygon":"Point",coordinates:q.co},properties:{id:q.uid,internalId:q.iid,name:q.na}};t.properties=Ext.Object.merge(t.properties,q.groupSets);r.features.push(t)}return r},reset:function(){this.layer.destroyFeatures();this.layer.legendPanel.update("");this.layer.legendPanel.collapse();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitGroupSet=q.organisationUnitGroupSet||i.organisationUnitGroupSet;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},updateOptions:function(i){this.addOptions(i)},applyClassification:function(r){this.updateOptions(r);var q=this.gis.store.groupsByGroupSet.data.items;var u=new Array(q.length);for(var s=0;s<q.length;s++){var t=new OpenLayers.Rule({symbolizer:{pointRadius:8,externalGraphic:"../../images/orgunitgroup/"+q[s].data.symbol},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:this.indicator,value:q[s].data.name})});u[s]=t}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var s=document.createElement("div"),t=document.createElement("div"),q=this.gis.store.groupsByGroupSet.data.items;for(var r=0;r<q.length;r++){t=document.createElement("div");t.style.backgroundImage="url(../../images/orgunitgroup/"+q[r].data.symbol+")";t.style.backgroundRepeat="no-repeat";t.style.width="21px";t.style.height="16px";t.style.marginBottom="2px";t.style.cssFloat="left";s.appendChild(t);t=document.createElement("div");t.innerHTML=q[r].data.name;t.style.height="16px";t.style.lineHeight="17px";s.appendChild(t);t=document.createElement("div");t.style.clear="left";s.appendChild(t)}this.layer.legendPanel.update(s.outerHTML)},CLASS_NAME:"mapfish.GeoStat.Facility"});mapfish.GeoStat.createThematic=function(i){mapfish.GeoStat[i]=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,bounds:null,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(r,q){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderThematic(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();this.featureStore.loadFeatures(this.layer.features.slice(0));this.layer.legendPanel.update("");this.layer.legendPanel.collapse();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(q,r){q=q||this.view;q.valueType=r.valueType||q.valueType;q.indicatorGroup=r.indicatorGroup||q.indicatorGroup;q.indicator=r.indicator||q.indicator;q.dataElementGroup=r.dataElementGroup||q.dataElementGroup;q.dataElement=r.dataElement||q.dataElement;q.periodType=r.periodType||q.periodType;q.period=r.period||q.period;q.legendType=r.legendType||q.legendType;q.legendSet=r.legendSet||q.legendSet;q.classes=r.classes||q.classes;q.method=r.method||q.method;q.colorLow=r.colorLow||q.colorLow;q.colorHigh=r.colorHigh||q.colorHigh;q.radiusLow=r.radiusLow||q.radiusLow;q.radiusHigh=r.radiusHigh||q.radiusHigh;q.organisationUnitLevel=r.organisationUnitLevel||q.organisationUnitLevel;q.parentOrganisationUnit=r.parentOrganisationUnit||q.parentOrganisationUnit;q.parentLevel=r.parentLevel||q.parentLevel;q.parentGraph=r.parentGraph||q.parentGraph;q.opacity=r.opacity||q.opacity;return q},getImageLegendConfig:function(){var t=this.classification.bins,r=this.colorInterpolation,q=[];for(var s=0;s<t.length;s++){q.push({color:r[s].toHexString(),label:t[s].lowerBound.toFixed(1)+" - "+t[s].upperBound.toFixed(1)+" ("+t[s].nbVal+")"})}return q},updateOptions:function(r){var q=OpenLayers.Util.extend({},this.options);this.addOptions(r);if(r){this.setClassification()}},createColorInterpolation:function(){var q=this.classification.bins.length;if(!this.view.legendSet){this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],q)}},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;if(this.view.legendType===this.gis.conf.finals.widget.legendtype_predefined){if(this.bounds[0]>this.minVal){this.bounds.unshift(this.minVal);this.colorInterpolation.unshift(new mapfish.ColorRgb(240,240,240))}if(this.bounds[this.bounds.length-1]<this.maxVal){this.bounds.push(this.maxVal);this.colorInterpolation.push(new mapfish.ColorRgb(240,240,240))}}this.classification=t.classify(this.method,this.numClasses,this.bounds);this.createColorInterpolation()},applyClassification:function(q,s){this.updateOptions(q,s);var w=OpenLayers.Function.bind(function(y){var z=y.attributes[this.indicator];var x=(z-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return x||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:w});var u=this.classification.getBoundsArray();var v=new Array(u.length-1);for(var r=0;r<u.length-1;r++){var t=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:u[r],upperBoundary:u[r+1]})});v[r]=t}this.extendStyle(v);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var r=document.createElement("div"),t,s;t=document.createElement("div");t.style.height="14px";t.style.overflow="hidden";t.title=this.view.columns[0].items[0].name;t.innerHTML=this.view.columns[0].items[0].name;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t);t=document.createElement("div");t.style.height="14px";t.style.overflow="hidden";t.title=this.view.filters[0].items[0].name;t.innerHTML=this.view.filters[0].items[0].name;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t);t=document.createElement("div");t.style.width="1px";t.style.height="5px";r.appendChild(t);if(this.view.legendSet){for(var q=0;q<this.classification.bins.length;q++){t=document.createElement("div");t.style.backgroundColor=this.colorInterpolation[q].toHexString();t.style.width="30px";t.style.height=this.view.legendSet.names[q]?"25px":"20px";t.style.cssFloat="left";t.style.marginRight="8px";r.appendChild(t);t=document.createElement("div");t.style.lineHeight=this.view.legendSet.names[q]?"12px":"7px";t.innerHTML='<b style="color:#222; font-size:10px !important">'+(this.view.legendSet.names[q]||"")+"</b><br/>"+this.classification.bins[q].label;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t)}}else{for(var q=0;q<this.classification.bins.length;q++){t=document.createElement("div");t.style.backgroundColor=this.colorInterpolation[q].toHexString();t.style.width="30px";t.style.height="15px";t.style.cssFloat="left";t.style.marginRight="8px";r.appendChild(t);t=document.createElement("div");t.innerHTML=this.classification.bins[q].label;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t)}}this.layer.legendPanel.update(r.outerHTML)},CLASS_NAME:"mapfish.GeoStat."+i})};mapfish.GeoStat.createThematic("Thematic1");mapfish.GeoStat.createThematic("Thematic2");mapfish.GeoStat.createThematic("Thematic3");mapfish.GeoStat.createThematic("Thematic4")}());var g={user:{}},f=[],h=false,b=false,a,c,d;GIS.i18n={facility_layer_legend:"Facility layer legend",thematic_layer_1_legend:"Thematic layer 1 legend",thematic_layer_2_legend:"Thematic layer 2 legend",thematic_layer_3_legend:"Thematic layer 3 legend",thematic_layer_4_legend:"Thematic layer 4 legend",measure_distance:"Measure distance"};GIS.plugin={};a=function(j){var o=false,n=[],m=0,l;l=function(){if(++m===n.length){b=true;for(var p=0;p<f.length;p++){d(f[p])}f=[]}};n.push({url:j+"/api/system/context.jsonp",success:function(i){g.contextPath=i.contextPath;l()}});n.push({url:j+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(p){var i=p.organisationUnits[0];g.user.ou=i.id;g.user.ouc=Ext.Array.pluck(i.children,"id");l()}});n.push({url:j+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){g.legendSets=i.mapLegendSets;l()}});n.push({url:j+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){g.dimensions=i.dimensions;l()}});for(var k=0;k<n.length;k++){Ext.data.JsonP.request(n[k])}};c=function(){var i=".gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n";i+=".x-panel-body { font-size: 11px; } \n";i+=".x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n";i+=".gis-container-default .x-window-body { padding: 5px; background: #fff; } \n";i+=".olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n";i+='.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';i+=".olControlPanel.zoomIn { right: 72px; } \n";i+=".olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n";i+=".olControlPanel.zoomOut { right: 48px; } \n";i+=".olControlPanel.zoomVisible { right: 24px; } \n";i+=".olControlPermalink { display: none !important; } \n";i+='.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';i+=".olControlMousePosition * { font-size: 10px !important; } \n";i+=".text-mouseposition-lonlat { color: #555; } \n";i+=".olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n";i+='#google-logo { background: url("'+g.contextPath+'/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';i+=".olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n";i+=".olControlScaleLineBottom { display: none; } \n";i+=".olControlScaleLineTop { font-weight: bold; } \n";i+=".x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n";i+=".x-mask-msg div { background-position: 11px center; } \n";i+=".x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n";i+=".gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n";i+=".gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n";i+='.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';i+=".x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n";i+=".x-menu-item-active .x-menu-item-link {	border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n";i+=".x-menu-item-link { padding: 4px 5px 4px 26px; } \n";i+=".x-menu-item-text { color: #111; } \n";i+=".disabled { opacity: 0.4; cursor: default !important; } \n";i+=".el-opacity-1 { opacity: 1 !important; } \n";i+=".el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n";i+=".el-fontsize-10 { font-size: 10px !important; } \n";i+=".gis-grid-row-icon-disabled * { cursor: default !important; } \n";i+=".gis-toolbar-btn-menu { margin-top: 4px; } \n";i+=".gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n";i+=".gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n";i+=".gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n";i+=".gis-menu-item-first.x-menu-item-active .x-menu-item-link {	border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n";i+=".gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n";i+='.gis-menu-item-icon-drill { \n background: url("'+g.contextPath+'/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';i+='.gis-menu-item-icon-float { background: url("'+g.contextPath+'/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';i+=".x-color-picker a { padding: 0; } \n";i+=".x-color-picker em span { width: 14px; height: 14px; } \n";Ext.util.CSS.createStyleSheet(i)};d=function(l){var n,j,m,i,k;n=function(){if(!Ext.isString(l.url)){alert("Invalid url ("+l.el+")");return}if(l.url.split("").pop()==="/"){l.url=l.url.substr(0,l.url.length-1)}if(!Ext.isString(l.el)){alert("Invalid html element id ("+l.el+")");return}l.id=l.id||l.uid;if(l.id&&!Ext.isString(l.id)){alert("Invalid map id ("+l.el+")");return}return true};j=function(){var o,r,q,p=Ext.get(k.el);o=Ext.create("Ext.panel.Panel",{renderTo:p,width:p.getWidth(),height:p.getHeight(),cls:"gis-plugin",layout:{type:"hbox",align:"stretch"},items:[{xtype:"gx_mappanel",map:k.olmap,bodyStyle:"border:0 none",width:p.getWidth()-(k.map.hideLegend?0:200),height:p.getHeight(),listeners:{added:function(){q=this}}},{xtype:"panel",layout:"anchor",bodyStyle:"border-top:0 none; border-bottom:0 none",width:k.map.hideLegend?0:200,preventHeader:true,defaults:{bodyStyle:"padding: 6px; border: 0 none",collapsible:true,collapsed:true,animCollapse:false},items:[{title:GIS.i18n.thematic_layer_1_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic1.legendPanel=this}}},{title:GIS.i18n.thematic_layer_2_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic2.legendPanel=this}}},{title:GIS.i18n.thematic_layer_3_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic3.legendPanel=this}}},{title:GIS.i18n.thematic_layer_4_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic4.legendPanel=this}}},{title:GIS.i18n.facility_layer_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.facility.legendPanel=this}}}],listeners:{added:function(){r=this}}}],listeners:{afterrender:function(){m()}}});o.centerRegion=q;o.eastRegion=r;return o};m=function(p){var o=Ext.query(".zoomInButton").length;for(var q=0;q<o;q++){Ext.query(".zoomInButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomin_24.png" />';Ext.query(".zoomOutButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomout_24.png" />';Ext.query(".zoomVisibleButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomvisible_24.png" />';Ext.query(".measureButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/measure_24.png" />'}if(Ext.isDefined(k.map.baseLayer)){var r=Ext.isString(k.map.baseLayer)?k.map.baseLayer.split(" ").join("").toLowerCase():k.map.baseLayer;if(!r||r==="none"||r==="off"){k.layer.googleStreets.setVisibility(false)}else{if(r==="gh"||r==="googlehybrid"){k.olmap.setBaseLayer(k.layer.googleHybrid)}else{if(r==="osm"||r==="openstreetmap"){k.olmap.setBaseLayer(k.layer.openStreetMap)}}}}};i=function(){if(!n()){return}c();k=GIS.core.getInstance(g);k.el=l.el;GIS.core.createSelectHandlers(k,k.layer.boundary);GIS.core.createSelectHandlers(k,k.layer.thematic1);GIS.core.createSelectHandlers(k,k.layer.thematic2);GIS.core.createSelectHandlers(k,k.layer.thematic3);GIS.core.createSelectHandlers(k,k.layer.thematic4);GIS.core.createSelectHandlers(k,k.layer.facility);k.map=l;k.viewport=j();k.olmap.mask=Ext.create("Ext.LoadMask",k.viewport.centerRegion.getEl(),{msg:"Loading"});GIS.core.MapLoader(k).load()}()};GIS.plugin.getMap=function(i){if(Ext.isString(i.url)&&i.url.split("").pop()==="/"){i.url=i.url.substr(0,i.url.length-1)}if(b){d(i)}else{f.push(i);if(!h){h=true;a(i.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getMap=GIS.plugin.getMap});
+Ext.onReady(function(){Ext.define("Ext.ux.button.ColorButton",{extend:"Ext.button.Button",alias:"widget.colorbutton",width:109,height:22,defaultValue:null,value:"f1f1f1",getValue:function(){return this.value},setValue:function(i){this.value=i;if(Ext.isDefined(this.getEl())){this.getEl().dom.style.background="#"+i}},reset:function(){this.setValue(this.defaultValue)},menu:{},menuHandler:function(){},initComponent:function(){var i=this;this.defaultValue=this.value;this.menu=Ext.create("Ext.menu.Menu",{showSeparator:false,items:{xtype:"colorpicker",closeAction:"hide",listeners:{select:function(k,j){i.setValue(j);i.menu.hide();i.menuHandler(k,j)}}}});this.callParent()},listeners:{render:function(){this.setValue(this.value)}}});Ext.define("Ext.ux.layout.component.form.MultiSelect",{extend:"Ext.layout.component.field.Field",alias:["layout.multiselectfield"],type:"multiselectfield",defaultHeight:200,sizeBodyContents:function(j,i){var k=this;if(!Ext.isNumber(i)){i=k.defaultHeight}k.owner.panel.setSize(j,i)}});Ext.define("Ext.ux.form.MultiSelect",{extend:"Ext.form.field.Base",alternateClassName:"Ext.ux.Multiselect",alias:["widget.multiselect","widget.multiselectfield"],uses:["Ext.view.BoundList","Ext.form.FieldSet","Ext.ux.layout.component.form.MultiSelect","Ext.view.DragZone","Ext.view.DropZone"],ddReorder:false,appendOnly:false,displayField:"text",allowBlank:true,minSelections:0,maxSelections:Number.MAX_VALUE,blankText:"This field is required",minSelectionsText:"Minimum {0} item(s) required",maxSelectionsText:"Maximum {0} item(s) allowed",delimiter:",",componentLayout:"multiselectfield",fieldBodyCls:Ext.baseCSSPrefix+"form-multiselect-body",initComponent:function(){var i=this;i.bindStore(i.store,true);if(i.store.autoCreated){i.valueField=i.displayField="field1";if(!i.store.expanded){i.displayField="field2"}}if(!Ext.isDefined(i.valueField)){i.valueField=i.displayField}i.callParent()},bindStore:function(i,k){var l=this,m=l.store,j=l.boundList;if(m&&!k&&m!==i&&m.autoDestroy){m.destroy()}l.store=i?Ext.data.StoreManager.lookup(i):null;if(j){j.bindStore(i||null)}},onRender:function(m,i){var n=this,j,l,k;n.callParent(arguments);l=n.boundList=Ext.create("Ext.view.BoundList",{multiSelect:true,store:n.store,displayField:n.displayField,border:false});k=l.getSelectionModel();n.mon(k,{selectionChange:n.onSelectionChange,scope:n});j=n.panel=Ext.create("Ext.panel.Panel",{title:n.listTitle,tbar:n.tbar,items:[l],renderTo:n.bodyEl,layout:"fit"});j.ownerCt=n;n.setRawValue(n.rawValue)},getSubTplMarkup:function(){return""},afterRender:function(){var i=this;i.callParent();if(i.ddReorder&&!i.dragGroup&&!i.dropGroup){i.dragGroup=i.dropGroup="MultiselectDD-"+Ext.id()}if(i.draggable||i.dragGroup){i.dragZone=Ext.create("Ext.view.DragZone",{view:i.boundList,ddGroup:i.dragGroup,dragText:"{0} Item{1}"})}if(i.droppable||i.dropGroup){i.dropZone=Ext.create("Ext.view.DropZone",{view:i.boundList,ddGroup:i.dropGroup,handleNodeDrop:function(p,o,j){var k=this.view,m=k.getStore(),l=p.records,n;p.view.store.remove(l);n=m.indexOf(o);if(j==="after"){n++}m.insert(n,l);k.getSelectionModel().select(l)}})}},onSelectionChange:function(){this.checkChange()},clearValue:function(){this.setValue([])},getSubmitValue:function(){var j=this,i=j.delimiter,k=j.getValue();return Ext.isString(i)?k.join(i):k},getRawValue:function(){var j=this,i=j.boundList;if(i){j.rawValue=Ext.Array.map(i.getSelectionModel().getSelection(),function(k){return k.get(j.valueField)})}return j.rawValue},setRawValue:function(k){var j=this,i=j.boundList,l;k=Ext.Array.from(k);j.rawValue=k;if(i){l=[];Ext.Array.forEach(k,function(o){var n,m=j.store.findRecord(j.valueField,o,n,n,true,true);if(m){l.push(m)}});i.getSelectionModel().select(l,false,true)}return k},valueToRaw:function(i){return i},isEqual:function(n,m){var k=Ext.Array.from,l,j;n=k(n);m=k(m);j=n.length;if(j!==m.length){return false}for(l=0;l<j;l++){if(m[l]!==n[l]){return false}}return true},getErrors:function(j){var i=this,k=Ext.String.format,m=i.callParent(arguments),l;j=Ext.Array.from(j||i.getValue());l=j.length;if(!i.allowBlank&&l<1){m.push(i.blankText)}if(l<this.minSelections){m.push(k(i.minSelectionsText,i.minSelections))}if(l>this.maxSelections){m.push(k(i.maxSelectionsText,i.maxSelections))}return m},onDisable:function(){this.callParent();this.disabled=true;this.updateReadOnly()},onEnable:function(){this.callParent();this.disabled=false;this.updateReadOnly()},setReadOnly:function(i){this.readOnly=i;this.updateReadOnly()},updateReadOnly:function(){var j=this,i=j.boundList,k=j.readOnly||j.disabled;if(i){i.getSelectionModel().setLocked(k)}},onDestroy:function(){Ext.destroyMembers(this,"panel","boundList","dragZone","dropZone");this.callParent()}});OpenLayers.Util.OSM={};OpenLayers.Util.OSM.MISSING_TILE_URL="http://www.openstreetmap.org/openlayers/img/404.png";OpenLayers.Util.OSM.originalOnImageLoadError=OpenLayers.Util.onImageLoadError;OpenLayers.Util.onImageLoadError=function(){if(this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)){this.src=OpenLayers.Util.OSM.MISSING_TILE_URL}else{if(this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)){}else{OpenLayers.Util.OSM.originalOnImageLoadError}}};OpenLayers.Layer.OSM.Mapnik=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png","http://b.tile.openstreetmap.org/${z}/${x}/${y}.png","http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.Mapnik"});OpenLayers.Layer.OSM.Osmarender=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:18,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.Osmarender"});OpenLayers.Layer.OSM.CycleMap=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(k,l){var i=["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"];l=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},l);var j=[k,i,l];OpenLayers.Layer.OSM.prototype.initialize.apply(this,j)},CLASS_NAME:"OpenLayers.Layer.OSM.CycleMap"});OpenLayers.Control.Circle=OpenLayers.Class(OpenLayers.Control,{feature:null,layer:null,radius:5,origin:null,sides:40,angle:null,snapAngle:null,dragControl:null,initialize:function(i){OpenLayers.Control.prototype.initialize.apply(this,arguments)},activate:function(){var j=OpenLayers.Control.prototype.activate.call(this);if(j){var i={displayInLayerSwitcher:false,calculateInRange:function(){return true}};this.map.addLayer(this.layer)}return j},deactivate:function(){var i=OpenLayers.Control.prototype.deactivate.call(this);if(i){if(this.layer.map!=null){this.layer.destroy(false);if(this.feature){this.feature.destroy()}}this.layer=null;this.feature=null}return i},createGeometry:function(){this.angle=Math.PI*((1/this.sides)-(1/2));if(this.snapAngle){this.angle+=this.snapAngle*(Math.PI/180)}this.feature.geometry=OpenLayers.Geometry.Polygon.createRegularPolygon(this.origin,this.radius,this.sides,this.snapAngle)},modifyGeometry:function(){var k,n,i,j;var m=this.feature.geometry.components[0];if(m.components.length!=(this.sides+1)){this.createGeometry();m=this.feature.geometry.components[0]}for(var l=0;l<this.sides;++l){j=m.components[l];k=this.angle+(l*2*Math.PI/this.sides);j.x=this.origin.x+(this.radius*Math.cos(k));j.y=this.origin.y+(this.radius*Math.sin(k));j.clearBounds()}},updateCircle:function(i,j){this.origin=new OpenLayers.Geometry.Point(i.lon,i.lat);this.radius=j*1;if(!this.feature){this.feature=new OpenLayers.Feature.Vector();this.createGeometry();this.layer.addFeatures([this.feature],{silent:true})}else{this.modifyGeometry()}this.layer.drawFeature(this.feature,this.style)},CLASS_NAME:"Meteorage.Circle"});OpenLayers.Control.newSelectFeature=OpenLayers.Class(OpenLayers.Control,{multipleKey:null,toggleKey:null,multiple:false,clickout:true,toggle:false,hover:false,onSelect:function(){},onUnselect:function(){},onHoverSelect:function(){},onHoverUnselect:function(){},onClickSelect:function(){},onClickUnselect:function(){},geometryTypes:null,layer:null,callbacks:null,selectStyle:null,renderIntent:"select",handler:null,initialize:function(k,j){OpenLayers.Control.prototype.initialize.apply(this,[j]);this.layer=k;this.callbacks=OpenLayers.Util.extend({click:this.clickFeature,clickout:this.clickoutFeature,over:this.overFeature,out:this.outFeature},this.callbacks);var i={geometryTypes:this.geometryTypes};this.handler=new OpenLayers.Handler.Feature(this,k,this.callbacks,i)},unselectAll:function(j){var l;for(var k=this.layer.selectedFeatures.length-1;k>=0;--k){l=this.layer.selectedFeatures[k];if(!j||j.except!=l){this.unselect(l,"click")}}},clickFeature:function(i){if((this.onSelect.name!=""||this.onClickSelect.name!="")&&!this.hover){var j=(OpenLayers.Util.indexOf(this.layer.selectedFeatures,i)>-1);if(j){if(this.toggleSelect()){this.unselect(i)}else{if(!this.multipleSelect()){this.unselectAll({except:i})}}}else{if(!this.multipleSelect()){this.unselectAll({except:i})}}this.select(i,"click")}},multipleSelect:function(){return this.multiple||this.handler.evt[this.multipleKey]},toggleSelect:function(){return this.toggle||this.handler.evt[this.toggleKey]},clickoutFeature:function(i){if(((this.onClickUnselect.name!=""||this.onHoverSelect.name=="")&&!this.hover)&&this.clickout){this.unselectAll()}},overFeature:function(i){if((this.onHoverSelect.name!=""||this.hover)&&(OpenLayers.Util.indexOf(this.layer.selectedFeatures,i)==-1)){this.select(i,"hover")}},outFeature:function(i){if(this.onHoverUnselect.name!=""||this.hover){this.unselect(i,"hover")}},select:function(k,i){this.layer.selectedFeatures.push(k);var j=this.selectStyle||this.renderIntent;this.layer.drawFeature(k,j);this.layer.events.triggerEvent("featureselected",{feature:k});switch(i){case"hover":this.onHoverSelect(k);break;case"click":if(this.onClickSelect.name!=""){this.onClickSelect(k)}else{if(this.onSelect.name!=""){this.onSelect(k)}}break;default:this.onSelect(k);break}},unselect:function(j,i){this.layer.drawFeature(j,"default");OpenLayers.Util.removeItem(this.layer.selectedFeatures,j);this.layer.events.triggerEvent("featureunselected",{feature:j});switch(i){case"hover":this.onHoverUnselect(j);break;case"click":if(this.onClickUnselect.name!=""){this.onClickUnselect(j)}else{if(this.onUnselect.name!=""){this.onUnselect(j)}}break;default:this.onUnselect(j);break}},setMap:function(i){this.handler.setMap(i);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.newSelectFeature"});Ext.define("GeoExt.data.LayerModel",{alternateClassName:"GeoExt.data.LayerRecord",extend:"Ext.data.Model",requires:["Ext.data.proxy.Memory","Ext.data.reader.Json"],alias:"model.gx_layer",statics:{createFromLayer:function(i){return this.proxy.reader.readRecords([i]).records[0]}},fields:["id",{name:"title",type:"string",mapping:"name"},{name:"legendURL",type:"string",mapping:"metadata.legendURL"},{name:"hideTitle",type:"bool",mapping:"metadata.hideTitle"},{name:"hideInLegend",type:"bool",mapping:"metadata.hideInLegend"}],proxy:{type:"memory",reader:{type:"json"}},getLayer:function(){return this.raw}});Ext.define("GeoExt.data.LayerStore",{requires:["GeoExt.data.LayerModel"],extend:"Ext.data.Store",model:"GeoExt.data.LayerModel",statics:{MAP_TO_STORE:1,STORE_TO_MAP:2},map:null,constructor:function(i){var l=this;i=Ext.apply({},i);var k=(GeoExt.MapPanel&&i.map instanceof GeoExt.MapPanel)?i.map.map:i.map;delete i.map;if(i.layers){i.data=i.layers}delete i.layers;var j={initDir:i.initDir};delete i.initDir;l.callParent([i]);if(k){this.bind(k,j)}},bind:function(k,j){var i=this;if(i.map){return}i.map=k;j=Ext.apply({},j);var m=j.initDir;if(j.initDir==undefined){m=GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP}var l=k.layers.slice(0);if(m&GeoExt.data.LayerStore.STORE_TO_MAP){i.each(function(n){i.map.addLayer(n.getLayer())},i)}if(m&GeoExt.data.LayerStore.MAP_TO_STORE){i.loadRawData(l,true)}k.events.on({changelayer:i.onChangeLayer,addlayer:i.onAddLayer,removelayer:i.onRemoveLayer,scope:i});i.on({load:i.onLoad,clear:i.onClear,add:i.onAdd,remove:i.onRemove,update:i.onUpdate,scope:i});i.data.on({replace:i.onReplace,scope:i});i.fireEvent("bind",i,k)},unbind:function(){var i=this;if(i.map){i.map.events.un({changelayer:i.onChangeLayer,addlayer:i.onAddLayer,removelayer:i.onRemoveLayer,scope:i});i.un("load",i.onLoad,i);i.un("clear",i.onClear,i);i.un("add",i.onAdd,i);i.un("remove",i.onRemove,i);i.data.un("replace",i.onReplace,i);i.map=null}},onChangeLayer:function(i){var k=i.layer;var m=this.findBy(function(o,n){return o.getLayer()===k});if(m>-1){var j=this.getAt(m);if(i.property==="order"){if(!this._adding&&!this._removing){var l=this.map.getLayerIndex(k);if(l!==m){this._removing=true;this.remove(j);delete this._removing;this._adding=true;this.insert(l,[j]);delete this._adding}}}else{if(i.property==="name"){j.set("title",k.name)}else{this.fireEvent("update",this,j,Ext.data.Record.EDIT)}}}},onAddLayer:function(i){var k=this;if(!k._adding){k._adding=true;var j=k.proxy.reader.read(i.layer);k.add(j.records);delete k._adding}},onRemoveLayer:function(j){if(this.map.unloadDestroy){if(!this._removing){var i=j.layer;this._removing=true;this.remove(this.getByLayer(i));delete this._removing}}else{this.unbind()}},onLoad:function(o,i,k){if(k){if(!Ext.isArray(i)){i=[i]}if(!this._addRecords){this._removing=true;for(var m=this.map.layers.length-1;m>=0;m--){this.map.removeLayer(this.map.layers[m])}delete this._removing}var j=i.length;if(j>0){var l=new Array(j);for(var n=0;n<j;n++){l[n]=i[n].getLayer()}this._adding=true;this.map.addLayers(l);delete this._adding}}delete this._addRecords},onClear:function(j){this._removing=true;for(var i=this.map.layers.length-1;i>=0;i--){this.map.removeLayer(this.map.layers[i])}delete this._removing},onAdd:function(i,j,m){if(!this._adding){this._adding=true;var k;for(var l=j.length-1;l>=0;--l){k=j[l].getLayer();this.map.addLayer(k);if(m!==this.map.layers.length-1){this.map.setLayerIndex(k,m)}}delete this._adding}},onRemove:function(i,j,l){if(!this._removing){var k=j.getLayer();if(this.map.getLayer(k.id)!=null){this._removing=true;this.removeMapLayer(j);delete this._removing}}},onUpdate:function(m,j,i){if(i===Ext.data.Record.EDIT){if(j.modified&&j.modified.title){var l=j.getLayer();var k=j.get("title");if(k!==l.name){l.setName(k)}}}},removeMapLayer:function(i){this.map.removeLayer(i.getLayer())},onReplace:function(k,j,i){this.removeMapLayer(j)},getByLayer:function(i){var j=this.findBy(function(k){return k.getLayer()===i});if(j>-1){return this.getAt(j)}},destroy:function(){var i=this;i.unbind();i.callParent()},loadRecords:function(j,i){if(i&&i.addRecords){this._addRecords=true}this.callParent(arguments)}});Ext.define("GeoExt.panel.Map",{extend:"Ext.panel.Panel",requires:["GeoExt.data.LayerStore"],alias:"widget.gx_mappanel",alternateClassName:"GeoExt.MapPanel",statics:{guess:function(){var i=Ext.ComponentQuery.query("gx_mappanel");return((i&&i.length>0)?i[0]:null)}},center:null,zoom:null,extent:null,prettyStateKeys:false,map:null,layers:null,stateEvents:["aftermapmove","afterlayervisibilitychange","afterlayeropacitychange","afterlayerorderchange","afterlayernamechange","afterlayeradd","afterlayerremove"],initComponent:function(){if(!(this.map instanceof OpenLayers.Map)){this.map=new OpenLayers.Map(Ext.applyIf(this.map||{},{allOverlays:true}))}var i=this.layers;if(!i||i instanceof Array){this.layers=Ext.create("GeoExt.data.LayerStore",{layers:i,map:this.map.layers.length>0?this.map:null})}if(Ext.isString(this.center)){this.center=OpenLayers.LonLat.fromString(this.center)}else{if(Ext.isArray(this.center)){this.center=new OpenLayers.LonLat(this.center[0],this.center[1])}}if(Ext.isString(this.extent)){this.extent=OpenLayers.Bounds.fromString(this.extent)}else{if(Ext.isArray(this.extent)){this.extent=OpenLayers.Bounds.fromArray(this.extent)}}this.callParent(arguments);this.on("resize",this.onResize,this);this.on("afterlayout",function(){if(typeof this.map.getViewport==="function"){this.items.each(function(j){if(typeof j.addToMapPanel==="function"){j.getEl().appendTo(this.map.getViewport())}},this)}},this);this.map.events.on({moveend:this.onMoveend,changelayer:this.onChangelayer,addlayer:this.onAddlayer,removelayer:this.onRemovelayer,scope:this})},onMoveend:function(i){this.fireEvent("aftermapmove",this,this.map,i)},onChangelayer:function(i){var j=this.map;if(i.property){if(i.property==="visibility"){this.fireEvent("afterlayervisibilitychange",this,j,i)}else{if(i.property==="order"){this.fireEvent("afterlayerorderchange",this,j,i)}else{if(i.property==="nathis"){this.fireEvent("afterlayernathischange",this,j,i)}else{if(i.property==="opacity"){this.fireEvent("afterlayeropacitychange",this,j,i)}}}}}},onAddlayer:function(){this.fireEvent("afterlayeradd")},onRemovelayer:function(){this.fireEvent("afterlayerremove")},onResize:function(){var i=this.map;if(this.body.dom!==i.div){i.render(this.body.dom);this.layers.bind(i);if(i.layers.length>0){this.setInitialExtent()}else{this.layers.on("add",this.setInitialExtent,this,{single:true})}}else{i.updateSize()}},setInitialExtent:function(){var i=this.map;if(!i.getCenter()){if(this.center||this.zoom){i.setCenter(this.center,this.zoom)}else{if(this.extent instanceof OpenLayers.Bounds){i.zoomToExtent(this.extent,true)}else{i.zoomToMaxExtent()}}}},getState:function(){var m=this,k=m.map,l=m.callParent(arguments)||{},i;if(!k){return}var j=k.getCenter();j&&Ext.applyIf(l,{x:j.lon,y:j.lat,zoom:k.getZoom()});m.layers.each(function(n){i=n.getLayer();layerId=this.prettyStateKeys?n.get("title"):n.get("id");l=m.addPropertyToState(l,"visibility_"+layerId,i.getVisibility());l=m.addPropertyToState(l,"opacity_"+layerId,(i.opacity===null)?1:i.opacity)},m);return l},applyState:function(r){var i=this;map=i.map;i.center=new OpenLayers.LonLat(r.x,r.y);i.zoom=r.zoom;var m,p,l,o,q,k;var n=map.layers;for(m=0,p=n.length;m<p;m++){l=n[m];o=i.prettyStateKeys?l.name:l.id;q=r["visibility_"+o];if(q!==undefined){q=(/^true$/i).test(q);if(l.isBaseLayer){if(q){map.setBaseLayer(l)}}else{l.setVisibility(q)}}k=r["opacity_"+o];if(k!==undefined){l.setOpacity(k)}}},onBeforeAdd:function(i){if(Ext.isFunction(i.addToMapPanel)){i.addToMapPanel(this)}this.callParent(arguments)},beforeDestroy:function(){if(this.map&&this.map.events){this.map.events.un({moveend:this.onMoveend,changelayer:this.onChangelayer,scope:this})}if(!this.initialConfig.map||!(this.initialConfig.map instanceof OpenLayers.Map)){if(this.map&&this.map.destroy){this.map.destroy()}}delete this.map;this.callParent(arguments)}});Ext.define("GeoExt.tree.Column",{extend:"Ext.tree.Column",alias:"widget.gx_treecolumn",initComponent:function(){var i=this;i.callParent();var j=i.renderer;this.renderer=function(l,p,q,m,k,o,r){var n=[j(l,p,q,m,k,o,r)];if(q.get("checkedGroup")){n[0]=n[0].replace(/class="([^-]+)-tree-checkbox([^"]+)?"/,'class="$1-tree-checkbox$2 gx-tree-radio"')}n.push('<div class="gx-tree-component gx-tree-component-off" id="tree-record-'+q.id+'"></div>');if(q.uiProvider&&q.uiProvider instanceof "string"){}return n.join("")}},defaultRenderer:function(i){return i}});Ext.define("GeoExt.tree.View",{extend:"Ext.tree.View",alias:"widget.gx_treeview",initComponent:function(){var i=this;i.on("itemupdate",this.onItem,this);i.on("itemadd",this.onItem,this);i.on("createchild",this.createChild,this);return i.callParent(arguments)},onItem:function(j,n,k,i){var l=this;if(!(j instanceof Array)){j=[j]}for(var m=0;m<j.length;m++){this.onNodeRendered(j[m])}},onNodeRendered:function(k){var i=this;var j=Ext.get("tree-record-"+k.id);if(!j){return}if(k.get("layer")){i.fireEvent("createchild",j,k)}if(k.hasChildNodes()){k.eachChild(function(l){i.onNodeRendered(l)},i)}},createChild:function(i,k){var j=k.get("component");if(j){cmpObj=Ext.ComponentManager.create(j);cmpObj.render(i);i.removeCls("gx-tree-component-off")}}});Ext.define("GeoExt.tree.LayerNode",{extend:"Ext.AbstractPlugin",alias:"plugin.gx_layer",init:function(i){this.target=i;var j=i.get("layer");i.set("checked",j.getVisibility());if(!i.get("checkedGroup")&&j.isBaseLayer){i.set("checkedGroup","gx_baselayer")}i.set("fixedText",!!i.text);i.set("leaf",true);if(!i.get("iconCls")){i.set("iconCls","gx-tree-layer-icon")}i.on("afteredit",this.onAfterEdit,this);j.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this})},onAfterEdit:function(k,j){var i=this;if(~Ext.Array.indexOf(j,"checked")){i.onCheckChange()}},onLayerVisibilityChanged:function(){if(!this._visibilityChanging){this.target.set("checked",this.target.get("layer").getVisibility())}},onCheckChange:function(){var k=this.target,i=this.target.get("checked");if(i!=k.get("layer").getVisibility()){k._visibilityChanging=true;var j=k.get("layer");if(i&&j.isBaseLayer&&j.map){j.map.setBaseLayer(j)}else{j.setVisibility(i)}delete k._visibilityChanging}}});Ext.define("GeoExt.tree.LayerLoader",{extend:"Ext.util.Observable",requires:["GeoExt.tree.LayerNode"],store:null,filter:function(i){return i.getLayer().displayInLayerSwitcher===true},baseAttrs:null,load:function(i){if(this.fireEvent("beforeload",this,i)){this.removeStoreHandlers();while(i.firstChild){i.removeChild(i.firstChild)}if(!this.store){this.store=GeoExt.MapPanel.guess().layers}this.store.each(function(j){this.addLayerNode(i,j)},this);this.addStoreHandlers(i);this.fireEvent("load",this,i)}},onStoreAdd:function(i,j,o,l){if(!this._reordering){var k=l.get("container").recordIndexToNodeIndex(o+j.length-1,l);for(var n=0,m=j.length;n<m;++n){this.addLayerNode(l,j[n],k)}}},onStoreRemove:function(j,i){if(!this._reordering){this.removeLayerNode(i,j)}},addLayerNode:function(l,j,i){i=i||0;if(this.filter(j)===true){var m=j.getLayer();var k=this.createNode({plugins:[{ptype:"gx_layer"}],layer:m,text:m.name,listeners:{move:this.onChildMove,scope:this}});if(i!==undefined){l.insertChild(i,k)}else{l.appendChild(k)}l.getChildAt(i).on("move",this.onChildMove,this)}},removeLayerNode:function(i,j){if(this.filter(j)===true){var k=i.findChildBy(function(l){return l.get("layer")==j.getLayer()});if(k){k.un("move",this.onChildMove,this);k.remove()}}},onChildMove:function(v,n,m,q){var p=this,r=p.store.getByLayer(v.get("layer")),w=m.get("container"),s=w.loader;p._reordering=true;if(s instanceof p.self&&p.store===s.store){s._reordering=true;p.store.remove(r);var x;if(m.childNodes.length>1){var o=(q===0)?q+1:q-1;x=p.store.findBy(function(i){return m.childNodes[o].get("layer")===i.getLayer()});if(q===0){x++}}else{if(n.parentNode===m.parentNode){var u=m;do{u=u.previousSibling}while(u&&!(u.get("container") instanceof w.self&&u.lastChild));if(u){x=p.store.findBy(function(i){return u.lastChild.get("layer")===i.getLayer()})}else{var t=m;do{t=t.nextSibling}while(t&&!(t.get("container") instanceof w.self&&t.firstChild));if(t){x=p.store.findBy(function(i){return t.firstChild.get("layer")===i.getLayer()})}x++}}}if(x!==undefined){p.store.insert(x,[r])}else{p.store.insert(oldRecordIndex,[r])}delete s._reordering}delete p._reordering},addStoreHandlers:function(i){if(!this._storeHandlers){this._storeHandlers={add:function(m,k,l){this.onStoreAdd(m,k,l,i)},remove:function(l,k){this.onStoreRemove(k,i)}};for(var j in this._storeHandlers){this.store.on(j,this._storeHandlers[j],this)}}},removeStoreHandlers:function(){if(this._storeHandlers){for(var i in this._storeHandlers){this.store.un(i,this._storeHandlers[i],this)}delete this._storeHandlers}},createNode:function(i){if(this.baseAttrs){Ext.apply(i,this.baseAttrs)}return i},destroy:function(){this.removeStoreHandlers()}});Ext.define("GeoExt.tree.LayerContainer",{extend:"Ext.AbstractPlugin",requires:["GeoExt.tree.LayerLoader"],alias:"plugin.gx_layercontainer",defaultText:"Layers",init:function(k){var i=this;var j=i.loader;i.loader=(j&&j instanceof GeoExt.tree.LayerLoader)?j:new GeoExt.tree.LayerLoader(j);k.set("container",i);if(!k.get("text")){k.set("text",i.defaultText);k.commit()}i.loader.load(k)},recordIndexToNodeIndex:function(p,l){var m=this;var i=m.loader.store;var n=i.getCount();var j=l.childNodes.length;var k=-1;for(var o=n-1;o>=0;--o){if(m.loader.filter(i.getAt(o))===true){++k;if(p===o||k>j-1){break}}}return k}});Ext.define("GeoExt.tree.BaseLayerContainer",{extend:"GeoExt.tree.LayerContainer",alias:"plugin.gx_baselayercontainer",defaultText:"Base Layers",init:function(k){var i=this;var j=i.loader;i.loader=Ext.applyIf(j||{},{baseAttrs:Ext.applyIf((j&&j.baseAttrs)||{},{iconCls:"gx-tree-baselayer-icon",checkedGroup:"baselayer"}),filter:function(m){var l=m.getLayer();return l.displayInLayerSwitcher===true&&l.isBaseLayer===true}});i.callParent(arguments)}});Ext.define("GeoExt.tree.Panel",{extend:"Ext.tree.Panel",alias:"widget.gx_treepanel",requires:["GeoExt.tree.Column","GeoExt.tree.View"],viewType:"gx_treeview",initComponent:function(){var i=this;if(!i.columns){if(i.initialConfig.hideHeaders===undefined){i.hideHeaders=true}i.addCls(Ext.baseCSSPrefix+"autowidth-table");i.columns=[{xtype:"gx_treecolumn",text:"Name",width:Ext.isIE6?null:10000,dataIndex:i.displayField}]}i.callParent()}});Ext.Ajax.method="GET";GIS={core:{instances:[]},i18n:{},isDebug:false,logg:[]};GIS.core.getOLMap=function(j){var k,i;i=function(m,o){var n,l;n=new OpenLayers.Control.Button({displayClass:"olControlButton",trigger:function(){o.call(j.olmap)}});l=new OpenLayers.Control.Panel({defaultControl:n});l.addControls([n]);k.addControl(l);l.div.className+=" "+m;l.div.childNodes[0].className+=" "+m+"Button"};k=new OpenLayers.Map({controls:[new OpenLayers.Control.Navigation({zoomWheelEnabled:true,documentDrag:true}),new OpenLayers.Control.MousePosition({prefix:'<span id="mouseposition" class="el-fontsize-10"><span class="text-mouseposition-lonlat">LON </span>',separator:'<span class="text-mouseposition-lonlat">,&nbsp;LAT </span>',suffix:'<div id="google-logo" name="http://www.google.com/intl/en-US_US/help/terms_maps.html"; onclick="window.open(Ext.get(this).dom.attributes.name.nodeValue);"></div></span>'}),new OpenLayers.Control.Permalink(),new OpenLayers.Control.ScaleLine({geodesic:true,maxWidth:170,minWidth:100})],displayProjection:new OpenLayers.Projection("EPSG:4326"),maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),mouseMove:{},relocate:{}});k.events.register("mousemove",null,function(l){j.olmap.mouseMove.x=l.clientX;j.olmap.mouseMove.y=l.clientY});k.zoomToVisibleExtent=function(){j.util.map.zoomToVisibleExtent(this)};k.closeAllLayers=function(){j.layer.event.core.reset();j.layer.facility.core.reset();j.layer.boundary.core.reset();j.layer.thematic1.core.reset();j.layer.thematic2.core.reset();j.layer.thematic3.core.reset();j.layer.thematic4.core.reset()};i("zoomIn",k.zoomIn);i("zoomOut",k.zoomOut);i("zoomVisible",k.zoomToVisibleExtent);i("measure",function(){GIS.core.MeasureWindow(j).show()});return k};GIS.core.getLayers=function(j){var o={},k,m=["1","2","3","4"];if(window.google){o.googleStreets=new OpenLayers.Layer.Google("Google Streets",{numZoomLevels:20,animationEnabled:true,layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.googleStreets.id="googleStreets";o.googleHybrid=new OpenLayers.Layer.Google("Google Hybrid",{type:google.maps.MapTypeId.HYBRID,numZoomLevels:20,animationEnabled:true,layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.googleHybrid.id="googleHybrid"}o.openStreetMap=new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap",{layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(i){if(i){this.layerOpacity=parseFloat(i)}this.setOpacity(this.layerOpacity)}});o.openStreetMap.id="openStreetMap";o.event=GIS.core.VectorLayer(j,"event",GIS.i18n.event_layer,{opacity:0.8});o.event.core=new mapfish.GeoStat.Event(j.olmap,{layer:o.event,gis:j});o.facility=GIS.core.VectorLayer(j,"facility",GIS.i18n.facility_layer,{opacity:1});o.facility.core=new mapfish.GeoStat.Facility(j.olmap,{layer:o.facility,gis:j});o.boundary=GIS.core.VectorLayer(j,"boundary",GIS.i18n.boundary_layer,{opacity:0.8});o.boundary.core=new mapfish.GeoStat.Boundary(j.olmap,{layer:o.boundary,gis:j});for(var l=0,n;l<m.length;l++){n=m[l];o["thematic"+n]=GIS.core.VectorLayer(j,"thematic"+n,GIS.i18n.thematic_layer+" "+n,{opacity:0.8});o["thematic"+n].layerCategory=j.conf.finals.layer.category_thematic,o["thematic"+n].core=new mapfish.GeoStat["Thematic"+n](j.olmap,{layer:o["thematic"+n],gis:j})}return o};GIS.core.createSelectHandlers=function(r,l){var t=!!GIS.app?(r.init.user.isAdmin?true:false):false,u={},n,i,k,j,m,q=r.conf.finals.dimension,s,p;i=function o(w){if(s){s.destroy()}s=Ext.create("Ext.window.Window",{cls:"gis-window-widget-feature gis-plugin",preventHeader:true,shadow:false,resizable:false,items:{html:w.attributes.label}});s.show();var z=r.viewport.eastRegion.getPosition()[0],y=r.viewport.centerRegion.getPosition()[0],x=y+((z-y)/2),v=r.viewport.centerRegion.getPosition()[1]+(GIS.app?32:0);s.setPosition(x-(s.getWidth()/2),v)};k=function o(v){s.destroy()};j=function o(D){var C,B,w,x,y,A=D.geometry.CLASS_NAME===r.conf.finals.openLayers.point_classname,z=D.attributes;B=function(){if(r.olmap.relocate.window){r.olmap.relocate.window.destroy()}r.olmap.relocate.window=Ext.create("Ext.window.Window",{title:"Relocate facility",layout:"fit",iconCls:"gis-window-title-icon-relocate",cls:"gis-container-default",setMinWidth:function(E){this.setWidth(this.getWidth()<E?E:this.getWidth())},items:{html:z.name,cls:"gis-container-inner"},bbar:["->",{xtype:"button",hideLabel:true,text:GIS.i18n.cancel,handler:function(){r.olmap.relocate.active=false;r.olmap.relocate.window.destroy();r.olmap.getViewport().style.cursor="auto"}}],listeners:{close:function(){r.olmap.relocate.active=false;r.olmap.getViewport().style.cursor="auto"}}});r.olmap.relocate.window.show();r.olmap.relocate.window.setMinWidth(220);r.util.gui.window.setPositionTopRight(r.olmap.relocate.window)};C=function(){Ext.Ajax.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getFacilityInfo.action",params:{id:z.id},success:function(F){var E=Ext.decode(F.responseText);if(l.infrastructuralWindow){l.infrastructuralWindow.destroy()}l.infrastructuralWindow=Ext.create("Ext.window.Window",{title:GIS.i18n.information,layout:"column",iconCls:"gis-window-title-icon-information",cls:"gis-container-default",width:460,height:400,period:null,items:[{cls:"gis-container-inner",columnWidth:0.4,bodyStyle:"padding-right:4px",items:function(){var G=[];if(z.name){G.push({html:GIS.i18n.name,cls:"gis-panel-html-title"},{html:z.name,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.pa){G.push({html:GIS.i18n.parent_unit,cls:"gis-panel-html-title"},{html:E.pa,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.ty){G.push({html:GIS.i18n.type,cls:"gis-panel-html-title"},{html:E.ty,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.co){G.push({html:GIS.i18n.code,cls:"gis-panel-html-title"},{html:E.co,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.ad){G.push({html:GIS.i18n.address,cls:"gis-panel-html-title"},{html:E.ad,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.em){G.push({html:GIS.i18n.email,cls:"gis-panel-html-title"},{html:E.em,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(E.pn){G.push({html:GIS.i18n.phone_number,cls:"gis-panel-html-title"},{html:E.pn,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}return G}()},{xtype:"form",cls:"gis-container-inner gis-form-widget",columnWidth:0.6,bodyStyle:"padding-left:4px",items:[{html:GIS.i18n.infrastructural_data,cls:"gis-panel-html-title"},{cls:"gis-panel-html-separator"},{xtype:"combo",fieldLabel:GIS.i18n.period,editable:false,valueField:"id",displayField:"name",forceSelection:true,width:255,labelWidth:70,store:r.store.infrastructuralPeriodsByType,lockPosition:false,listeners:{select:function(){n=this.getValue();l.widget.infrastructuralDataElementValuesStore.load({params:{periodId:n,organisationUnitId:z.internalId}})}}},{cls:"gis-panel-html-separator"},{xtype:"grid",cls:"gis-grid",height:300,width:255,scroll:"vertical",columns:[{id:"dataElementName",text:"Data element",dataIndex:"dataElementName",sortable:true,width:195},{id:"value",header:"Value",dataIndex:"value",sortable:true,width:60}],disableSelection:true,store:l.widget.infrastructuralDataElementValuesStore}]}],listeners:{show:function(){if(n){this.down("combo").setValue(n);infrastructuralDataElementValuesStore.load({params:{periodId:n,organisationUnitId:z.internalId}})}}}});l.infrastructuralWindow.show();r.util.gui.window.setPositionTopRight(l.infrastructuralWindow)}})};w=function(I,G,H){var F=Ext.clone(l.core.view),E;F.parentGraphMap={};F.parentGraphMap[I]=G;F.rows=[{dimension:q.organisationUnit.objectName,items:[{id:I},{id:"LEVEL-"+H}]}];if(F){E=l.core.getLoader();E.updateGui=true;E.zoomToVisibleExtent=true;E.hideMask=true;E.load(F)}};var v=[Ext.create("Ext.menu.Item",{text:"Float up",iconCls:"gis-menu-item-icon-float",cls:"gis-plugin",disabled:!z.hasCoordinatesUp,handler:function(){w(z.grandParentId,z.grandParentParentGraph,parseInt(z.level)-1)}}),Ext.create("Ext.menu.Item",{text:"Drill down",iconCls:"gis-menu-item-icon-drill",cls:"gis-menu-item-first gis-plugin",disabled:!z.hasCoordinatesDown,handler:function(){w(z.id,z.parentGraph,parseInt(z.level)+1)}})];if(t&&A){v.push({xtype:"menuseparator"});v.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.relocate,iconCls:"gis-menu-item-icon-relocate",disabled:!r.init.user.isAdmin,handler:function(E){r.olmap.relocate.active=true;r.olmap.relocate.feature=D;r.olmap.getViewport().style.cursor="crosshair";B()}}));v.push(Ext.create("Ext.menu.Item",{text:"Swap lon/lat",iconCls:"gis-menu-item-icon-relocate",disabled:!r.init.user.isAdmin,handler:function(E){var G=D.attributes.id,F=Ext.clone(D.geometry).transform("EPSG:900913","EPSG:4326");if(Ext.isNumber(F.x)&&Ext.isNumber(F.y)&&r.init.user.isAdmin){Ext.Ajax.request({url:r.init.contextPath+"/api/organisationUnits/"+G+".json?links=false",success:function(H){var I=Ext.decode(H.responseText);I.coordinates="["+F.y.toFixed(5)+","+F.x.toFixed(5)+"]";Ext.Ajax.request({url:r.init.contextPath+"/api/metaData?preheatCache=false",method:"POST",headers:{"Content-Type":"application/json"},params:Ext.encode({organisationUnits:[I]}),success:function(K){var J=D.geometry.x,L=D.geometry.y;delete D.geometry.bounds;D.geometry.x=L;D.geometry.y=J;l.redraw();console.log(D.attributes.name+" relocated to "+I.coordinates)}})}})}}}));v.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.show_information_sheet,iconCls:"gis-menu-item-icon-information",handler:function(E){if(r.store.infrastructuralPeriodsByType.isLoaded){C()}else{r.store.infrastructuralPeriodsByType.load({params:{name:r.init.systemSettings.infrastructuralPeriodType},callback:function(){C()}})}}}))}v[v.length-1].addCls("gis-menu-item-last");x=new Ext.menu.Menu({baseCls:"gis-plugin",shadow:false,showSeparator:false,defaults:{bodyStyle:"padding-right:6px"},items:v,listeners:{afterrender:function(){this.getEl().addCls("gis-toolbar-btn-menu")}}});x.showAt([r.olmap.mouseMove.x,r.olmap.mouseMove.y])};u={onHoverSelect:i,onHoverUnselect:k,onClickSelect:j};if(l.id==="event"){u.onClickSelect=function o(D){var z=["label","value","nameColumnMap","psi","ps","longitude","latitude","eventdate","ou","oucode","ouname"],x=D.attributes,v=x.nameColumnMap,y='<table class="padding1">',B=' style="font-weight:bold; padding-right:10px; vertical-align:top"',w=' style="max-width:170px"',A;y+="<tr><td"+B+">"+v.ou+"</td><td"+w+">"+x.ouname+"</td></tr>";y+="<tr><td"+B+">"+v.eventdate+"</td><td"+w+">"+x.eventdate+"</td></tr>";y+="<tr><td"+B+">"+v.longitude+"</td><td"+w+">"+x.longitude+"</td></tr>";y+="<tr><td"+B+">"+v.latitude+"</td><td"+w+">"+x.latitude+"</td></tr>";for(var C in x){if(x.hasOwnProperty(C)&&!Ext.Array.contains(z,C)){y+="<tr><td"+B+">"+v[C]+"</td><td>"+x[C]+"</td></tr>"}}y+="</table>";if(Ext.isObject(p)&&p.destroy){A=p.getPosition();p.destroy();p=null}p=Ext.create("Ext.window.Window",{title:"Event",layout:"fit",resizable:false,bodyStyle:"background-color:#fff; padding:5px",html:y,autoShow:true,listeners:{show:function(E){if(A){E.setPosition(A)}else{r.util.gui.window.setPositionTopRight(E)}},destroy:function(){p=null}}})}}m=new OpenLayers.Control.newSelectFeature(l,u);r.olmap.addControl(m);m.activate()};GIS.core.OrganisationUnitLevelStore=function(i){return Ext.create("Ext.data.Store",{fields:["id","name","level"],proxy:{type:"jsonp",url:i.init.contextPath+i.conf.finals.url.path_api+"organisationUnitLevels.jsonp?viewClass=detailed&links=false&paging=false",reader:{type:"json",root:"organisationUnitLevels"}},autoLoad:true,cmp:[],isLoaded:false,loadFn:function(j){if(this.isLoaded){j.call()}else{this.load(j)}},getRecordByLevel:function(j){return this.getAt(this.findExact("level",j))},listeners:{load:function(){if(!this.isLoaded){this.isLoaded=true;i.util.gui.combo.setQueryMode(this.cmp,"local")}this.sort("level","ASC")}}})};GIS.core.StyleMap=function(l,j){var k={fillOpacity:1,strokeColor:"#fff",strokeWidth:1},i={fillOpacity:0.9,strokeColor:"#fff",strokeWidth:1,cursor:"pointer"};if(l==="boundary"){k.fillOpacity=0;k.strokeColor="#000";k.strokeWidth=1;i.fillColor="#000";i.fillOpacity=0.15;i.strokeColor="#000";i.strokeWidth=1}if(j){k.label="${label}";k.fontFamily="arial,sans-serif,ubuntu,consolas";k.fontSize=j.fontSize?j.fontSize+"px":"13px";k.fontWeight=j.strong?"bold":"normal";k.fontStyle=j.italic?"italic":"normal";k.fontColor=j.color?(j.color.split("").shift()!=="#"?"#"+j.color:j.color):"#000000"}return new OpenLayers.StyleMap({"default":k,select:i})};GIS.core.VectorLayer=function(i,m,k,j){var l=new OpenLayers.Layer.Vector(k,{strategies:[new OpenLayers.Strategy.Refresh({force:true})],styleMap:GIS.core.StyleMap(m),visibility:false,displayInLayerSwitcher:false,layerType:i.conf.finals.layer.type_vector,layerOpacity:j?j.opacity||1:1,setLayerOpacity:function(n){if(n){this.layerOpacity=parseFloat(n)}this.setOpacity(this.layerOpacity)},hasLabels:false});l.id=m;return l};GIS.core.MeasureWindow=function(i){var k,j,l,n,m;m=new OpenLayers.StyleMap({"default":new OpenLayers.Style()});n=new OpenLayers.Control.Measure(OpenLayers.Handler.Path,{persist:true,immediate:true,handlerOption:{layerOptions:{styleMap:m}}});l=function(o){if(o.measure){j.setText(o.measure.toFixed(2)+" "+o.units)}};i.olmap.addControl(n);n.events.on({measurepartial:l,measure:l});n.geodesic=true;n.activate();j=Ext.create("Ext.form.Label",{style:"height: 20px",text:"0 km"});k=Ext.create("Ext.window.Window",{title:GIS.i18n.measure_distance,layout:"fit",cls:"gis-container-default gis-plugin",bodyStyle:"text-align: center",width:130,minWidth:130,resizable:false,items:j,listeners:{show:function(){var o=i.viewport.eastRegion.getPosition()[0]-this.getWidth()-3,p=i.viewport.centerRegion.getPosition()[1]+26;this.setPosition(o,p)},destroy:function(){n.deactivate();i.olmap.removeControl(n)}}});return k};GIS.core.MapLoader=function(j){var n,l,o,m,k=[],i;n=function(){Ext.data.JsonP.request({url:j.init.contextPath+j.conf.finals.url.path_api+"maps/"+j.map.id+".jsonp?viewClass=dimensional&links=false",success:function(v){if(Ext.isArray(v.mapViews)){for(var t=0,p;t<v.mapViews.length;t++){p=v.mapViews[t];if(p){if(Ext.isArray(p.columns)&&p.columns.length){for(var s=0,w;s<p.columns.length;s++){w=p.columns[s];if(Ext.isArray(w.items)&&w.items.length){for(var q=0,u;q<w.items.length;q++){u=w.items[q];u.id=u.id.replace(".","-")}}}}}}}j.map=v;l()},failure:function(){j.olmap.mask.hide();alert("Map id not recognized"+(j.el?" ("+j.el+")":""));return}})};l=function(){var q=j.map.mapViews,p;if(!(Ext.isArray(q)&&q.length)){j.olmap.mask.hide();alert(GIS.i18n.favorite_outdated_create_new);return}for(var r=0;r<q.length;r++){q[r]=j.api.layout.Layout(q[r])}q=Ext.Array.clean(q);if(!q.length){return}if(j.viewport&&j.viewport.favoriteWindow&&j.viewport.favoriteWindow.isVisible()){j.viewport.favoriteWindow.destroy()}j.olmap.closeAllLayers();for(var r=0,s;r<q.length;r++){s=q[r];p=j.layer[s.layer].core.getLoader();p.updateGui=!j.el;p.callBack=m;p.load(s)}};m=function(p){k.push(p);if(k.length===j.map.mapViews.length){o()}};o=function(){k=[];if(j.el){j.olmap.zoomToVisibleExtent()}else{if(j.map.longitude&&j.map.latitude&&j.map.zoom){j.olmap.setCenter(new OpenLayers.LonLat(j.map.longitude,j.map.latitude),j.map.zoom)}else{j.olmap.zoomToVisibleExtent()}}if(j.map.id&&j.viewport.shareButton){j.viewport.shareButton.enable()}if(GIS.isSessionStorage){j.util.layout.setSessionStorage("map",j.util.layout.getAnalytical())}j.olmap.mask.hide()};i={load:function(p){j.olmap.mask.show();if(j.map&&j.map.id){n()}else{if(p){j.map={mapViews:p}}l()}}};return i};GIS.core.LayerLoaderEvent=function(r,k){var j=k.map,l,n,m,i,q,o,p=r.conf.finals.dimension;n=function(s){m(s)};m=function(s){s=s||k.core.view;var w="?",v=[];w+="stage="+s.stage.id;w+="&startDate="+s.startDate;w+="&endDate="+s.endDate;if(Ext.isArray(s.organisationUnits)){for(var u=0;u<s.organisationUnits.length;u++){w+="&dimension=ou:"+s.organisationUnits[u].id}}for(var u=0,t;u<s.dataElements.length;u++){t=s.dataElements[u];w+="&dimension="+t.id;if(t.value){if(t.operator){w+=":"+t.operator}w+=":"+t.value}}Ext.data.JsonP.request({url:r.init.contextPath+"/api/analytics/events/query/"+s.program.id+".jsonp"+w,disableCaching:false,scope:this,success:function(y){var H=[],B=[],J=[],x,C,A=Ext.clone(y.metaData.names);for(var F=0;F<y.headers.length;F++){A[y.headers[F].name]=y.headers[F].column;if(y.headers[F].name==="longitude"){x=F}if(y.headers[F].name==="latitude"){C=F}}if(Ext.isArray(y.rows)&&y.rows.length){for(var F=0,I;F<y.rows.length;F++){I=y.rows[F];if(I[x]&&I[C]){J.push(I)}}}if(!J.length){alert("No coordinates found");j.mask.hide();return}A=Ext.clone(y.metaData.names);for(var F=0;F<y.headers.length;F++){A[y.headers[F].name]=y.headers[F].column}for(var F=0,I,E;F<J.length;F++){I=J[F];E={};for(var D=0;D<I.length;D++){E[y.headers[D].name]=I[D]}E[r.conf.finals.widget.value]=0;E.label=E.ouname;E.nameColumnMap=A;H.push(E)}for(var F=0,z,G;F<H.length;F++){z=H[F];G=r.util.map.getTransformedPointByXY(z.longitude,z.latitude);B.push(new OpenLayers.Feature.Vector(G,z))}k.removeFeatures(k.features);k.addFeatures(B);i(s)}})};i=function(s){s=s||k.core.view;var t={indicator:r.conf.finals.widget.value,method:2,numClasses:5,colors:k.core.getColors("000000","222222"),minSize:5,maxSize:5};k.core.view=s;k.core.applyClassification(t);q(s)};q=function(s){if(k.item){k.item.setValue(true,s.opacity)}else{k.setLayerOpacity(s.opacity)}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(s)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{r.map=null}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();n(s)},loadData:m,loadLegend:i};return o};GIS.core.LayerLoaderFacility=function(r,l){var j=l.map,m,o,n,i,k,q,p;m=function(u,x){var z=l.core.view,y,t,s,v;p.zoomToVisibleExtent=true;if(!z){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.rows[0];s=[];v=z.rows[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}p.zoomToVisibleExtent=false;if(u.organisationUnitGroupSet.id!==z.organisationUnitGroupSet.id){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}if(x){i(u);return r.conf.finals.widget.loadtype_legend}};o=function(s){var t=s.rows[0].items,v="";for(var u=0;u<t.length;u++){v+="ids="+t[u].id;v+=u!==t.length-1?"&":""}Ext.data.JsonP.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getGeoJsonFacilities.action?"+v,scope:this,disableCaching:false,success:function(y){var w=l.core.decode(y),z=new OpenLayers.Format.GeoJSON(),x=r.util.map.getTransformedFeatureArray(z.read(w));if(!Ext.isArray(x)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!x.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}l.core.featureStore.loadFeatures(x.slice(0));n(s,x)},failure:function(w){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};n=function(s,u){s=s||l.core.view;u=u||l.core.featureStore.features;for(var t=0;t<u.length;t++){u[t].attributes.label=u[t].attributes.name}l.removeFeatures(l.features);l.addFeatures(u);i(s)};i=function(s){s=s||l.core.view;var t=r.store.groupsByGroupSet;t.proxy.url=r.init.contextPath+r.conf.finals.url.path_module+"getOrganisationUnitGroupsByGroupSet.action?id="+s.organisationUnitGroupSet.id;t.load({scope:this,callback:function(){var u={indicator:s.organisationUnitGroupSet.id};l.core.view=s;l.core.applyClassification(u);k(s);q(s)}})};k=function(t){var s=t.areaRadius;if(l.circleLayer){l.circleLayer.deactivateControls();l.circleLayer=null}if(Ext.isDefined(s)&&s){l.circleLayer=GIS.app.CircleLayer(l.features,s);nissa=l.circleLayer}};q=function(s){r.viewport.eastRegion.doLayout();l.legendPanel.expand();if(l.item){l.item.setValue(true,s.opacity)}else{l.setLayerOpacity(s.opacity)}if(p.updateGui&&Ext.isObject(l.widget)){l.widget.setGui(s)}if(p.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(p.hideMask){j.mask.hide()}if(p.callBack){p.callBack(l)}else{r.map=null}};p={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();if(this.compare){m(s,true)}else{o(s)}},loadData:n,loadLegend:i};return p};GIS.core.LayerLoaderBoundary=function(q,k){var j=k.map,l,n,m,i,p,o;l=function(t,w){var y=k.core.view,x,s,r,u;if(!y){if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}x=[];s=t.rows[0];r=[];u=y.rows[0];if(s.items.length===u.items.length){for(var v=0;v<s.items.length;v++){x.push(s.items[v].id)}for(var v=0;v<u.items.length;v++){r.push(u.items[v].id)}if(Ext.Array.difference(x,r).length!==0){if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}}else{if(w){n(t)}return q.conf.finals.widget.loadtype_organisationunit}q.olmap.mask.hide()};n=function(r){var s=r.rows[0].items,u="";for(var t=0;t<s.length;t++){u+="ids="+s[t].id;u+=t!==s.length-1?"&":""}Ext.data.JsonP.request({url:q.init.contextPath+q.conf.finals.url.path_module+"getGeoJson.action?"+u,scope:this,disableCaching:false,success:function(x){var v=q.util.geojson.decode(x),y=new OpenLayers.Format.GeoJSON(),w=q.util.map.getTransformedFeatureArray(y.read(v));if(!Ext.isArray(w)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!w.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}k.core.featureStore.loadFeatures(w.slice(0));m(r,w)},failure:function(v){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};m=function(r,t){r=r||k.core.view;t=t||k.core.featureStore.features;for(var s=0;s<t.length;s++){t[s].attributes.label=t[s].attributes.name;t[s].attributes.value=0}k.removeFeatures(k.features);k.addFeatures(t);i(r)};i=function(r){r=r||k.core.view;var s={indicator:q.conf.finals.widget.value,method:2,numClasses:5,colors:k.core.getColors("000000","000000"),minSize:6,maxSize:6};if(r.labels){if(Ext.isObject(r.labels)){k.styleMap=GIS.core.StyleMap(k.id,r.labels)}else{k.styleMap=GIS.core.StyleMap(k.id,{fontSize:12,strong:false,italic:false,color:"#000"})}}k.core.view=r;k.core.applyClassification(s);p(r)};p=function(r){if(k.item){k.item.setValue(true,r.opacity)}else{k.setLayerOpacity(r.opacity)}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(r)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{q.map=null}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(r){q.olmap.mask.show();if(this.compare){l(r,true)}else{n(r)}},loadData:m,loadLegend:i};return o};GIS.core.LayerLoaderThematic=function(r,k){var j=k.map,l,n,m,i,q,o,p=r.conf.finals.dimension;l=function(u,x){var z=k.core.view,y,t,s,v;o.zoomToVisibleExtent=true;if(!z){if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.rows[0];s=[];v=z.rows[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){n(u)}return r.conf.finals.widget.loadtype_organisationunit}o.zoomToVisibleExtent=false;y=[];t=u.columns[0];s=[];v=z.columns[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.filters[0];s=[];v=z.filters[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}}else{if(x){m(u)}return r.conf.finals.widget.loadtype_organisationunit}if(x){o.zoomToVisibleExtent=false;i(u);return r.conf.finals.widget.loadtype_legend}};n=function(s){var t=s.rows[0].items,v="";for(var u=0;u<t.length;u++){v+="ids="+t[u].id;v+=u!==t.length-1?"&":""}Ext.data.JsonP.request({url:r.init.contextPath+r.conf.finals.url.path_module+"getGeoJson.action?"+v,scope:this,disableCaching:false,success:function(y){var w=r.util.geojson.decode(y),z=new OpenLayers.Format.GeoJSON(),x=r.util.map.getTransformedFeatureArray(z.read(w));if(!Ext.isArray(x)){j.mask.hide();alert(GIS.i18n.invalid_coordinates);return}if(!x.length){j.mask.hide();alert(GIS.i18n.no_valid_coordinates_found);return}k.core.featureStore.loadFeatures(x.slice(0));m(s,x)},failure:function(w){j.mask.hide();alert(GIS.i18n.coordinates_could_not_be_loaded)}})};m=function(z,u){var B;z=z||k.core.view;u=u||k.core.featureStore.features;var A=r.conf.finals.dimension,v="?",w=z.columns[0].items,s=z.columns[0].dimension===A.operand.objectName,t=z.filters[0].items,y=z.rows[0].items;v+="dimension=ou:";for(var x=0;x<y.length;x++){v+=y[x].id;v+=x<y.length-1?";":""}v+="&dimension=dx:";for(var x=0;x<w.length;x++){v+=s?w[x].id.split("-")[0]:w[x].id;v+=x<w.length-1?";":""}v+=s?"&dimension=co":"";v+="&filter=pe:";for(var x=0;x<t.length;x++){v+=t[x].id;v+=x<t.length-1?";":""}B=function(O){var H=r.api.response.Response(O),M={},E={},J,G,L,F=[],C,K=[];if(!H){j.mask.hide();return}for(var I=0;I<H.headers.length;I++){if(H.headers[I].name===A.organisationUnit.dimensionName){J=I}else{if(H.headers[I].name===A.value.dimensionName){L=I}}}for(var I=0,D;I<u.length;I++){var D=u[I].attributes.id;M[D]=true}for(var I=0;I<H.rows.length;I++){var D=H.rows[I][J],N=parseFloat(H.rows[I][L]);E[D]=N}for(var I=0;I<u.length;I++){var P=u[I],D=P.attributes.id;if(M.hasOwnProperty(D)&&E.hasOwnProperty(D)){P.attributes.value=E[D];P.attributes.label=P.attributes.name+" ("+P.attributes.value+")";F.push(P)}}k.removeFeatures(k.features);k.addFeatures(F);r.response=H;i(z)};if(Ext.isObject(GIS.app)){Ext.Ajax.request({url:r.init.contextPath+"/api/analytics.json"+v,disableCaching:false,failure:function(C){alert(C.responseText)},success:function(C){B(Ext.decode(C.responseText))}})}else{if(Ext.isObject(GIS.plugin)){Ext.data.JsonP.request({url:r.init.contextPath+"/api/analytics.jsonp"+v,disableCaching:false,scope:this,success:function(C){B(C)}})}}};i=function(u){var w,y,v;u=u||k.core.view;y=function(C){var A=Ext.Array.clean([].concat(u.columns||[],u.rows||[],u.filters||[])),B=C.metaData,H=B[p.period.objectName];for(var F=0,D;F<A.length;F++){D=A[F];for(var E=0,G;E<D.items.length;E++){G=D.items[E];if(G.id.indexOf("-")!==-1){var z=G.id.split("-");G.name=B.names[z[0]]+" "+B.names[z[1]]}else{G.name=B.names[G.id]}}}u.filters[0].items[0].name=B.names[H[H.length-1]]};v=function(){y(r.response);var z={indicator:r.conf.finals.widget.value,method:u.legendSet?mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:u.method,numClasses:u.classes,bounds:w,colors:k.core.getColors(u.colorLow,u.colorHigh),minSize:u.radiusLow,maxSize:u.radiusHigh};k.core.view=u;k.core.colorInterpolation=t;k.core.applyClassification(z);q(u)};if(u.labels){if(Ext.isObject(u.labels)){k.styleMap=GIS.core.StyleMap(k.id,u.labels)}else{k.styleMap=GIS.core.StyleMap(k.id,{fontSize:12,strong:false,italic:false,color:"#000"})}}if(u.legendSet){var w=[],t=[],x=[],s=[];Ext.Ajax.request({url:r.init.contextPath+r.conf.finals.url.path_api+"mapLegendSets/"+u.legendSet.id+".json?links=false&paging=false",scope:this,success:function(A){s=Ext.decode(A.responseText).mapLegends;Ext.Array.sort(s,function(C,B){return C.startValue-B.startValue});for(var z=0;z<s.length;z++){if(w[w.length-1]!==s[z].startValue){if(w.length!==0){t.push(new mapfish.ColorRgb(240,240,240));x.push("")}w.push(s[z].startValue)}t.push(new mapfish.ColorRgb());t[t.length-1].setFromHex(s[z].color);x.push(s[z].name);w.push(s[z].endValue)}u.legendSet.names=x;u.legendSet.bounds=w;u.legendSet.colors=t;v()}})}else{v()}};q=function(s){r.viewport.eastRegion.doLayout();k.legendPanel.expand();k.setLayerOpacity(s.opacity);if(k.item){k.item.setValue(true)}if(k.filterWindow&&k.filterWindow.isVisible()){k.filterWindow.filter()}if(o.updateGui&&Ext.isObject(k.widget)){k.widget.setGui(s)}if(o.zoomToVisibleExtent){j.zoomToVisibleExtent()}if(o.hideMask){j.mask.hide()}if(o.callBack){o.callBack(k)}else{r.map=null;if(r.viewport.shareButton){}}if(GIS.isSessionStorage){r.util.layout.setSessionStorage("map",r.util.layout.getAnalytical())}};o={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){r.olmap.mask.show();if(this.compare){l(s,true)}else{n(s)}},loadData:m,loadLegend:i};return o};GIS.core.getInstance=function(o){var l={},j={},m={},k={},n=[],i={};(function(){l.finals={url:{path_api:"/api/",path_module:"/dhis-web-mapping/",path_commons:"/dhis-web-commons-ajax-json/",organisationunitchildren_get:"getOrganisationUnitChildren.action",organisationunitgroup_getall:"organisationUnitGroups.json?paging=false&links=false",dataset_get:"dataSets.json?paging=false&links=false"},layer:{type_base:"base",type_vector:"vector",category_thematic:"thematic"},dimension:{data:{id:"data",value:"data",param:"dx",dimensionName:"dx",objectName:"dx"},category:{name:GIS.i18n.categories,dimensionName:"co",objectName:"co"},indicator:{id:"indicator",value:"indicators",param:"in",dimensionName:"dx",objectName:"in"},dataElement:{id:"dataElement",value:"dataElement",param:"de",dimensionName:"dx",objectName:"de"},operand:{id:"operand",value:"operand",param:"dc",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataSets",dimensionName:"dx",objectName:"ds"},period:{id:"period",value:"period",param:"pe",dimensionName:"pe",objectName:"pe"},organisationUnit:{id:"organisationUnit",value:"organisationUnit",param:"ou",dimensionName:"ou",objectName:"ou"},value:{id:"value",value:"value",param:"value",dimensionName:"value",objectName:"value"}},widget:{value:"value",legendtype_automatic:"automatic",legendtype_predefined:"predefined",symbolizer_color:"color",symbolizer_image:"image",loadtype_organisationunit:"organisationUnit",loadtype_data:"data",loadtype_legend:"legend"},openLayers:{point_classname:"OpenLayers.Geometry.Point"},mapfish:{classify_with_bounds:1,classify_by_equal_intervals:2,classify_by_quantils:3},root:{id:"root"}};l.layout={widget:{item_width:288,itemlabel_width:95,window_width:310},tool:{item_width:228,itemlabel_width:95,window_width:250},grid:{row_height:27}};l.period={periodTypes:[{id:"relativePeriods",name:GIS.i18n.relative},{id:"Daily",name:GIS.i18n.daily},{id:"Weekly",name:GIS.i18n.weekly},{id:"Monthly",name:GIS.i18n.monthly},{id:"BiMonthly",name:GIS.i18n.bimonthly},{id:"Quarterly",name:GIS.i18n.quarterly},{id:"SixMonthly",name:GIS.i18n.sixmonthly},{id:"SixMonthlyApril",name:GIS.i18n.sixmonthly_april},{id:"Yearly",name:GIS.i18n.yearly},{id:"FinancialOct",name:GIS.i18n.financial_oct},{id:"FinancialJuly",name:GIS.i18n.financial_july},{id:"FinancialApril",name:GIS.i18n.financial_april}],relativePeriods:[{id:"LAST_WEEK",name:GIS.i18n.last_week},{id:"LAST_MONTH",name:GIS.i18n.last_month},{id:"LAST_BIMONTH",name:GIS.i18n.last_bimonth},{id:"LAST_QUARTER",name:GIS.i18n.last_quarter},{id:"LAST_SIX_MONTH",name:GIS.i18n.last_sixmonth},{id:"LAST_FINANCIAL_YEAR",name:GIS.i18n.last_financial_year},{id:"THIS_YEAR",name:GIS.i18n.this_year},{id:"LAST_YEAR",name:GIS.i18n.last_year}],relativePeriodsMap:{LAST_WEEK:{id:"LAST_WEEK",name:GIS.i18n.last_week},LAST_MONTH:{id:"LAST_MONTH",name:GIS.i18n.last_month},LAST_BIMONTH:{id:"LAST_BIMONTH",name:GIS.i18n.last_bimonth},LAST_QUARTER:{id:"LAST_QUARTER",name:GIS.i18n.last_quarter},LAST_SIX_MONTH:{id:"LAST_SIX_MONTH",name:GIS.i18n.last_sixmonth},LAST_FINANCIAL_YEAR:{id:"LAST_FINANCIAL_YEAR",name:GIS.i18n.last_financial_year},THIS_YEAR:{id:"THIS_YEAR",name:GIS.i18n.this_year},LAST_YEAR:{id:"LAST_YEAR",name:GIS.i18n.last_year}},integratedRelativePeriodsMap:{LAST_WEEK:"LAST_WEEK",LAST_4_WEEKS:"LAST_WEEK",LAST_12_WEEKS:"LAST_WEEK",LAST_MONTH:"LAST_MONTH",LAST_3_MONTHS:"LAST_MONTH",LAST_12_MONTHS:"LAST_MONTH",LAST_BIMONTH:"LAST_BIMONTH",LAST_6_BIMONTHS:"LAST_BIMONTH",LAST_QUARTER:"LAST_QUARTER",LAST_4_QUARTERS:"LAST_QUARTER",LAST_SIX_MONTH:"LAST_SIX_MONTH",LAST_2_SIXMONTHS:"LAST_SIX_MONTH",LAST_FINANCIAL_YEAR:"LAST_FINANCIAL_YEAR",LAST_5_FINANCIAL_YEARS:"LAST_FINANCIAL_YEAR",THIS_YEAR:"THIS_YEAR",LAST_YEAR:"LAST_YEAR",LAST_5_YEARS:"LAST_YEAR"}}}());(function(){j.map={};j.map.getVisibleVectorLayers=function(){var r=[];for(var q=0,p;q<i.olmap.layers.length;q++){p=i.olmap.layers[q];if(p.layerType===l.finals.layer.type_vector&&p.visibility&&p.features.length){r.push(p)}}return r};j.map.getExtendedBounds=function(r){var q=null;if(r.length){q=r[0].getDataExtent();if(r.length>1){for(var p=1;p<r.length;p++){q.extend(r[p].getDataExtent())}}}return q};j.map.zoomToVisibleExtent=function(q){var p=j.map.getExtendedBounds(j.map.getVisibleVectorLayers(q));if(p){q.zoomToExtent(p)}};j.map.getTransformedFeatureArray=function(s){var p=new OpenLayers.Projection("EPSG:4326"),q=new OpenLayers.Projection("EPSG:900913");for(var r=0;r<s.length;r++){s[r].geometry.transform(p,q)}return s};j.geojson={};j.geojson.decode=function(r){var p={};p.type="FeatureCollection";p.crs={type:"EPSG",properties:{code:"4326"}};p.features=[];for(var q=0;q<r.geojson.length;q++){p.features.push({geometry:{type:parseInt(r.geojson[q].ty)===1?"MultiPolygon":"Point",coordinates:r.geojson[q].co},properties:{id:r.geojson[q].uid,internalId:r.geojson[q].iid,name:r.geojson[q].na,hasCoordinatesDown:r.geojson[q].hcd,hasCoordinatesUp:r.geojson[q].hcu,level:r.geojson[q].le,grandParentParentGraph:r.geojson[q].gppg,grandParentId:r.geojson[q].gpuid,parentGraph:r.geojson[q].parentGraph,parentId:r.geojson[q].pi,parentName:r.geojson[q].pn}})}return p};j.gui={};j.gui.combo={};j.gui.combo.setQueryMode=function(p,r){for(var q=0;q<p.length;q++){p[q].queryMode=r}};j.object={};j.object.sortObjectsByString=function(q,p){p=p||"name";q.sort(function(s,r){var u=s[p].toLowerCase(),t=r[p].toLowerCase();if(u<t){return -1}if(u>t){return 1}return 0});return q};j.object.getLength=function(p){var r=0;for(var q in p){if(p.hasOwnProperty(q)){r++}}return r}}());i.init=o;i.conf=l;i.util=j;(function(){var p=i.conf.finals.dimension;m.layout={};m.response={};m.layout.Record=function(r){var q={};return function(){if(!Ext.isObject(r)){console.log("Record config is not an object: "+r);return}if(!Ext.isString(r.id)){alert("Record id is not text: "+r);return}q.id=r.id.replace(".","-");if(Ext.isString(r.name)){q.name=r.name}return Ext.clone(q)}()};m.layout.Dimension=function(q){var r={};return function(){if(!Ext.isObject(q)){return}if(!Ext.isString(q.dimension)){console.log("Dimension name is not text: "+q);return}if(q.dimension!==l.finals.dimension.category.objectName){var s=[];if(!Ext.isArray(q.items)){console.log("Dimension items is not an array: "+q);return}for(var t=0;t<q.items.length;t++){record=m.layout.Record(q.items[t]);if(record){s.push(record)}}q.items=s;if(!q.items.length){console.log("Dimension has no valid items: "+q);return}}r.dimension=q.dimension;r.items=q.items;return Ext.clone(r)}()};m.layout.Layout=function(r){var r=Ext.clone(r),s={},q,t;q=function(x){var v=[];if(!(x&&Ext.isArray(x)&&x.length)){return}for(var u=0,w;u<x.length;u++){w=m.layout.Dimension(x[u]);if(w){v.push(w)}}x=v;return x.length?x:null};t=function(w){var y=Ext.Array.clean([].concat(w.columns||[],w.rows||[],w.filters||[])),A=l.period.integratedRelativePeriodsMap,v,B,u;for(var x=0,z;x<y.length;x++){z=y[x];if(z.dimension===p.indicator.objectName||z.dimension===p.dataElement.objectName||z.dimension===p.operand.objectName||z.dimension===p.dataSet.objectName){v=z}else{if(z.dimension===p.period.objectName){B=z}else{if(z.dimension===p.organisationUnit.objectName){u=z}}}}if(!u){alert("No organisation units specified");return}if(v){v.items=[v.items[0]]}if(B){B.items=[B.items[0]];B.items[0].id=A[B.items[0].id]?A[B.items[0].id]:B.items[0].id}w.columns=[v];w.rows=[u];w.filters=[B];return w};return function(){var A=[],z=[],C=l.finals.dimension,v=false,u=false,D=false;r=t(r);if(!r){return}r.columns=q(r.columns);r.rows=q(r.rows);r.filters=q(r.filters);if(!r.rows){console.log("Organisation unit dimension is invalid");return}for(var x=0,y,B=Ext.Array.clean([].concat(r.columns,r.rows,r.filters));x<B.length;x++){y=B[x];if(y){if(Ext.isString(y.dimension)){z.push(y.dimension)}if(y.dimension===C.organisationUnit.objectName&&Ext.isArray(y.items)){for(var w=0;w<y.items.length;w++){if(y.items[w].id==="USER_ORGUNIT"){v=true}else{if(y.items[w].id==="USER_ORGUNIT_CHILDREN"){u=true}else{if(y.items[w].id==="USER_ORGUNIT_GRANDCHILDREN"){D=true}}}}}}}s.columns=r.columns;s.rows=r.rows;s.filters=r.filters;s.layer=Ext.isString(r.layer)&&!Ext.isEmpty(r.layer)?r.layer:"thematic1";s.classes=Ext.isNumber(r.classes)&&!Ext.isEmpty(r.classes)?r.classes:5;s.method=Ext.isNumber(r.method)&&!Ext.isEmpty(r.method)?r.method:2;s.colorLow=Ext.isString(r.colorLow)&&!Ext.isEmpty(r.colorLow)?r.colorLow:"ff0000";s.colorHigh=Ext.isString(r.colorHigh)&&!Ext.isEmpty(r.colorHigh)?r.colorHigh:"00ff00";s.radiusLow=Ext.isNumber(r.radiusLow)&&!Ext.isEmpty(r.radiusLow)?r.radiusLow:5;s.radiusHigh=Ext.isNumber(r.radiusHigh)&&!Ext.isEmpty(r.radiusHigh)?r.radiusHigh:15;s.opacity=Ext.isNumber(r.opacity)&&!Ext.isEmpty(r.opacity)?r.opacity:0.8;s.userOrganisationUnit=v;s.userOrganisationUnitChildren=u;s.userOrganisationUnitGrandChildren=D;s.parentGraphMap=Ext.isObject(r.parentGraphMap)?r.parentGraphMap:null;s.legendSet=r.legendSet;s.labels=r.labels;s.organisationUnitGroupSet=r.organisationUnitGroupSet;s.areaRadius=r.areaRadius;return s}()};m.response.Header=function(q){var r={};return function(){if(!Ext.isObject(q)){console.log("Header is not an object: "+q);return}if(!Ext.isString(q.name)){console.log("Header name is not text: "+q);return}if(!Ext.isBoolean(q.meta)){console.log("Header meta is not boolean: "+q);return}r.name=q.name;r.meta=q.meta;return Ext.clone(r)}()};m.response.Response=function(r){var q={};return function(){var t=[];if(!(r&&Ext.isObject(r))){alert("Data response invalid");return false}if(!(r.headers&&Ext.isArray(r.headers))){alert("Data response invalid");return false}for(var s=0,u;s<r.headers.length;s++){u=m.response.Header(r.headers[s]);if(u){t.push(u)}}r.headers=t;if(!r.headers.length){alert("No valid response headers");return}if(!(Ext.isArray(r.rows)&&r.rows.length>0)){alert("No values found");return false}if(r.headers.length!==r.rows[0].length){alert("Data invalid");return false}q.headers=r.headers;q.metaData=r.metaData;q.width=r.width;q.height=r.height;q.rows=r.rows;return q}()}}());(function(){k.organisationUnitLevels=GIS.core.OrganisationUnitLevelStore(i)}());i.api=m;i.store=k;i.olmap=GIS.core.getOLMap(i);i.layer=GIS.core.getLayers(i);i.thematicLayers=[i.layer.thematic1,i.layer.thematic2,i.layer.thematic3,i.layer.thematic4];if(window.google){n.push(i.layer.googleStreets,i.layer.googleHybrid)}n.push(i.layer.openStreetMap,i.layer.thematic4,i.layer.thematic3,i.layer.thematic2,i.layer.thematic1,i.layer.boundary,i.layer.facility,i.layer.event);i.olmap.addLayers(n);GIS.core.instances.push(i);e=i.layer.event;return i};(function(){window.mapfish={_scriptName:"MapFish.js",_getScriptLocation:function(){if(window.gMfLocation){return window.gMfLocation}var t="";var u=mapfish._scriptName;var q=document.getElementsByTagName("script");for(var s=0;s<q.length;s++){var v=q[s].getAttribute("src");if(v){var r=v.lastIndexOf(u);if((r>-1)&&(r+u.length==v.length)){t=v.slice(0,-u.length);break}}}return t}};var o=new Array("core/Color.js","core/GeoStat.js","core/GeoStat/Boundary.js","core/GeoStat/Thematic1.js","core/GeoStat/Thematic2.js","core/GeoStat/Facility.js","core/GeoStat/Symbol.js","core/Util.js");var p="";var n=mapfish._getScriptLocation();for(var j=0;j<o.length;j++){if(/MSIE/.test(navigator.userAgent)||/Safari/.test(navigator.userAgent)){var m="<script src='"+n+o[j]+"'><\/script>";p+=m}else{var l=document.createElement("script");l.src=n+o[j];var k=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;k.appendChild(l)}}if(p){}mapfish.Color=OpenLayers.Class({getColorRgb:function(){}});mapfish.ColorRgb=OpenLayers.Class(mapfish.Color,{redLevel:null,greenLevel:null,blueLevel:null,initialize:function(r,q,i){this.redLevel=r;this.greenLevel=q;this.blueLevel=i},equals:function(i){return i.redLevel==this.redLevel&&i.greenLevel==this.greenLevel&&i.blueLevel==this.blueLevel},getColorRgb:function(){return this},getRgbArray:function(){return[this.redLevel,this.greenLevel,this.blueLevel]},hex2rgbArray:function(q){if(q.charAt(0)=="#"){q=q.substr(1)}var r=[parseInt(q.substring(0,2),16),parseInt(q.substring(2,4),16),parseInt(q.substring(4,6),16)];for(var s=0;s<r.length;s++){if(r[s]<0||r[s]>255){OpenLayers.Console.error("Invalid rgb hex color string: rgbHexString")}}return r},setFromHex:function(i){var q=this.hex2rgbArray(i);this.redLevel=q[0];this.greenLevel=q[1];this.blueLevel=q[2]},setFromRgb:function(q){var i=dojo.colorFromString(q);this.redLevel=i.r;this.greenLevel=i.g;this.blueLevel=i.b},toHexString:function(){var s=this.toHex(this.redLevel);var q=this.toHex(this.greenLevel);var i=this.toHex(this.blueLevel);return"#"+s+q+i},toHex:function(u){var r="0123456789ABCDEF";if(u<0||u>255){var t="Invalid decimal value for color level";OpenLayers.Console.error(t)}var s=Math.floor(u/16);var q=u%16;return r.charAt(s)+r.charAt(q)},CLASS_NAME:"mapfish.ColorRgb"});mapfish.ColorRgb.getColorsArrayByRgbInterpolation=function(y,t,v){var z=[];var r=y.getColorRgb();var q=t.getColorRgb();var x=r.getRgbArray();var w=q.getRgbArray();if(v==1){return[r]}for(var u=0;u<v;u++){var s=[];s[0]=x[0]+u*(w[0]-x[0])/(v-1);s[1]=x[1]+u*(w[1]-x[1])/(v-1);s[2]=x[2]+u*(w[2]-x[2])/(v-1);z[u]=new mapfish.ColorRgb(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]))}return z};mapfish.Util={};mapfish.Util.sum=function(s){for(var q=0,r=0;q<s.length;r+=s[q++]){}return r};mapfish.Util.max=function(i){return Math.max.apply({},i)};mapfish.Util.min=function(i){return Math.min.apply({},i)};mapfish.Util.getIconUrl=function(q,i){if(!i.layer){OpenLayers.Console.warn("Missing required layer option in mapfish.Util.getIconUrl");return""}if(!i.rule){i.rule=i.layer}if(q.indexOf("?")<0){q+="?"}else{if(q.lastIndexOf("&")!=(q.length-1)){if(q.indexOf("?")!=(q.length-1)){q+="&"}}}var i=OpenLayers.Util.extend({layer:"",rule:"",service:"WMS",version:"1.1.1",request:"GetLegendGraphic",format:"image/png",width:16,height:16},i);i=OpenLayers.Util.upperCaseObject(i);return q+OpenLayers.Util.getParameterString(i)};mapfish.Util.arrayEqual=function(r,q){if(r==null||q==null){return false}if(typeof(r)!="object"||typeof(q)!="object"){return false}if(r.length!=q.length){return false}for(var s=0;s<r.length;s++){if(typeof(r[s])!=typeof(q[s])){return false}if(r[s]!=q[s]){return false}}return true};mapfish.Util.isIE7=function(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie 7")>-1};mapfish.Util.relativeToAbsoluteURL=function(q){if(/^\w+:/.test(q)||!q){return q}var i=location.protocol+"//"+location.host;if(q.indexOf("/")==0){return i+q}var r=location.pathname.replace(/\/[^\/]*$/,"");return i+r+"/"+q};mapfish.Util.fixArray=function(i){if(i==""||i==null){return[]}else{if(i instanceof Array){return i}else{return i.split(",")}}};mapfish.GeoStat=OpenLayers.Class({layer:null,format:null,url:null,requestSuccess:function(i){},requestFailure:function(i){},indicator:null,defaultSymbolizer:{},legendDiv:null,initialize:function(r,i){this.map=r;this.addOptions(i);if(!this.layer){var q=new OpenLayers.Layer.Vector("geostat",{displayInLayerSwitcher:false,visibility:false});r.addLayer(q);this.layer=q}this.setUrl(this.url);this.legendDiv=Ext.get(i.legendDiv)},setUrl:function(i){this.url=i;if(this.url){OpenLayers.Request.GET({url:this.url,scope:this,success:this.requestSuccess,failure:this.requestFailure})}},getColors:function(i,r){var s=new mapfish.ColorRgb(),q=new mapfish.ColorRgb();s.setFromHex(i);q.setFromHex(r);return[s,q]},addOptions:function(i){if(i){if(!this.options){this.options={}}OpenLayers.Util.extend(this.options,i);OpenLayers.Util.extend(this,i)}},extendStyle:function(s,r,i){var q=this.layer.styleMap.styles["default"];if(s){q.rules=s}if(r){q.setDefaultStyle(OpenLayers.Util.applyDefaults(r,q.defaultStyle))}if(i){if(!q.context){q.context={}}OpenLayers.Util.extend(q.context,i)}},applyClassification:function(i){this.layer.renderer.clear();this.layer.redraw();this.updateLegend();this.layer.setVisibility(true)},showDetails:function(i){},hideDetails:function(i){},CLASS_NAME:"mapfish.GeoStat"});mapfish.GeoStat.Distribution=OpenLayers.Class({labelGenerator:function(q,s,t){var i=parseFloat(q.lowerBound).toFixed(1),r=parseFloat(q.upperBound).toFixed(1);return i+" - "+r+"&nbsp;&nbsp;("+q.nbVal+")"},values:null,nbVal:null,minVal:null,maxVal:null,initialize:function(i,q){OpenLayers.Util.extend(this,q);this.values=i;this.nbVal=i.length;this.minVal=this.nbVal?mapfish.Util.min(this.values):0;this.maxVal=this.nbVal?mapfish.Util.max(this.values):0},classifyWithBounds:function(q){var z=[];var w=[];var y=[];for(var v=0;v<this.values.length;v++){y.push(this.values[v])}y.sort(function(A,i){return A-i});var x=q.length-1;for(var u=0;u<x;u++){w[u]=0}for(var t=0;t<x-1;t){if(y[0]<q[t+1]){w[t]=w[t]+1;y.shift()}else{t++}}w[x-1]=this.nbVal-mapfish.Util.sum(w);for(var s=0;s<x;s++){z[s]=new mapfish.GeoStat.Bin(w[s],q[s],q[s+1],s==(x-1));var r=this.labelGenerator||this.defaultLabelGenerator;z[s].label=r(z[s],s,x)}return new mapfish.GeoStat.Classification(z)},classifyByEqIntervals:function(s){var r=[];for(var q=0;q<=s;q++){r[q]=this.minVal+q*(this.maxVal-this.minVal)/s}return this.classifyWithBounds(r)},classifyByQuantils:function(u){var i=this.values;i.sort(function(w,v){return w-v});var t=Math.round(this.values.length/u);var s=[];var r=(t===0)?0:t;if(i.length>0){s[0]=i[0];for(j=1;j<u;j++){s[j]=i[r];r+=t}s.push(i[i.length-1])}for(var q=0;q<s.length;q++){s[q]=parseFloat(s[q])}return this.classifyWithBounds(s)},sturgesRule:function(){return Math.floor(1+3.3*Math.log(this.nbVal,10))},classify:function(s,r,i){var q=null;if(!r){r=this.sturgesRule()}switch(parseFloat(s)){case mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:q=this.classifyWithBounds(i);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS:q=this.classifyByEqIntervals(r);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS:q=this.classifyByQuantils(r);break;default:OpenLayers.Console.error("Unsupported or invalid classification method")}return q},CLASS_NAME:"mapfish.GeoStat.Distribution"});mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS=1;mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS=2;mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS=3;mapfish.GeoStat.Bin=OpenLayers.Class({label:null,nbVal:null,lowerBound:null,upperBound:null,isLast:false,initialize:function(r,s,q,i){this.nbVal=r;this.lowerBound=s;this.upperBound=q;this.isLast=i},CLASS_NAME:"mapfish.GeoStat.Bin"});mapfish.GeoStat.Classification=OpenLayers.Class({bins:[],initialize:function(i){this.bins=i},getBoundsArray:function(){var r=[];for(var q=0;q<this.bins.length;q++){r.push(this.bins[q].lowerBound)}if(this.bins.length>0){r.push(this.bins[this.bins.length-1].upperBound)}return r},CLASS_NAME:"mapfish.GeoStat.Classification"});mapfish.GeoStat.Event=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:4,maxSize:4,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderEvent(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},getLegendConfig:function(){return},getImageLegendConfig:function(){return},updateOptions:function(q){var i=OpenLayers.Util.extend({},this.options);this.addOptions(q);if(q){this.setClassification()}},createColorInterpolation:function(){var i=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],i)},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;this.classification=t.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(q){this.updateOptions(q);var v=OpenLayers.Function.bind(function(w){var x=w.attributes[this.indicator];var i=(x-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return i||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:v});var t=this.classification.getBoundsArray();var u=new Array(t.length-1);for(var r=0;r<t.length-1;r++){var s=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:t[r],upperBoundary:t[r+1]})});u[r]=s}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){},CLASS_NAME:"mapfish.GeoStat.Event"});mapfish.GeoStat.Boundary=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderBoundary(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},getLegendConfig:function(){return},getImageLegendConfig:function(){return},updateOptions:function(q){var i=OpenLayers.Util.extend({},this.options);this.addOptions(q);if(q){this.setClassification()}},createColorInterpolation:function(){var i=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],i)},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;this.classification=t.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(q){this.updateOptions(q);var v=OpenLayers.Function.bind(function(w){var x=w.attributes[this.indicator];var i=(x-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return i||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:v});var t=this.classification.getBoundsArray();var u=new Array(t.length-1);for(var r=0;r<t.length-1;r++){var s=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:t[r],upperBoundary:t[r+1]})});u[r]=s}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){},CLASS_NAME:"mapfish.GeoStat.Boundary"});mapfish.GeoStat.Facility=OpenLayers.Class(mapfish.GeoStat,{classification:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(q,i){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderFacility(this.gis,this.layer)},decode:function(v){var t,u,q,r={type:"FeatureCollection",crs:{type:"EPSG",properties:{code:"4326"}},features:[]};for(var s=0;s<v.geojson.length;s++){q=v.geojson[s];t={geometry:{type:parseInt(q.ty)===1?"MultiPolygon":"Point",coordinates:q.co},properties:{id:q.uid,internalId:q.iid,name:q.na}};t.properties=Ext.Object.merge(t.properties,q.groupSets);r.features.push(t)}return r},reset:function(){this.layer.destroyFeatures();this.layer.legendPanel.update("");this.layer.legendPanel.collapse();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(i,q){i=i||this.view;i.organisationUnitGroupSet=q.organisationUnitGroupSet||i.organisationUnitGroupSet;i.organisationUnitLevel=q.organisationUnitLevel||i.organisationUnitLevel;i.parentOrganisationUnit=q.parentOrganisationUnit||i.parentOrganisationUnit;i.parentLevel=q.parentLevel||i.parentLevel;i.parentGraph=q.parentGraph||i.parentGraph;i.opacity=q.opacity||i.opacity;return i},updateOptions:function(i){this.addOptions(i)},applyClassification:function(r){this.updateOptions(r);var q=this.gis.store.groupsByGroupSet.data.items;var u=new Array(q.length);for(var s=0;s<q.length;s++){var t=new OpenLayers.Rule({symbolizer:{pointRadius:8,externalGraphic:"../../images/orgunitgroup/"+q[s].data.symbol},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:this.indicator,value:q[s].data.name})});u[s]=t}this.extendStyle(u);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var s=document.createElement("div"),t=document.createElement("div"),q=this.gis.store.groupsByGroupSet.data.items;for(var r=0;r<q.length;r++){t=document.createElement("div");t.style.backgroundImage="url(../../images/orgunitgroup/"+q[r].data.symbol+")";t.style.backgroundRepeat="no-repeat";t.style.width="21px";t.style.height="16px";t.style.marginBottom="2px";t.style.cssFloat="left";s.appendChild(t);t=document.createElement("div");t.innerHTML=q[r].data.name;t.style.height="16px";t.style.lineHeight="17px";s.appendChild(t);t=document.createElement("div");t.style.clear="left";s.appendChild(t)}this.layer.legendPanel.update(s.outerHTML)},CLASS_NAME:"mapfish.GeoStat.Facility"});mapfish.GeoStat.createThematic=function(i){mapfish.GeoStat[i]=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,bounds:null,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(r){if(r&&r.length){var s=[];for(var q=0;q<r.length;q++){s.push([r[q].attributes.id,r[q].attributes.name])}this.loadData(s);this.sortStore();this.features=r}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(r,q){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderThematic(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();this.featureStore.loadFeatures(this.layer.features.slice(0));this.layer.legendPanel.update("");this.layer.legendPanel.collapse();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(q,r){q=q||this.view;q.valueType=r.valueType||q.valueType;q.indicatorGroup=r.indicatorGroup||q.indicatorGroup;q.indicator=r.indicator||q.indicator;q.dataElementGroup=r.dataElementGroup||q.dataElementGroup;q.dataElement=r.dataElement||q.dataElement;q.periodType=r.periodType||q.periodType;q.period=r.period||q.period;q.legendType=r.legendType||q.legendType;q.legendSet=r.legendSet||q.legendSet;q.classes=r.classes||q.classes;q.method=r.method||q.method;q.colorLow=r.colorLow||q.colorLow;q.colorHigh=r.colorHigh||q.colorHigh;q.radiusLow=r.radiusLow||q.radiusLow;q.radiusHigh=r.radiusHigh||q.radiusHigh;q.organisationUnitLevel=r.organisationUnitLevel||q.organisationUnitLevel;q.parentOrganisationUnit=r.parentOrganisationUnit||q.parentOrganisationUnit;q.parentLevel=r.parentLevel||q.parentLevel;q.parentGraph=r.parentGraph||q.parentGraph;q.opacity=r.opacity||q.opacity;return q},getImageLegendConfig:function(){var t=this.classification.bins,r=this.colorInterpolation,q=[];for(var s=0;s<t.length;s++){q.push({color:r[s].toHexString(),label:t[s].lowerBound.toFixed(1)+" - "+t[s].upperBound.toFixed(1)+" ("+t[s].nbVal+")"})}return q},updateOptions:function(r){var q=OpenLayers.Util.extend({},this.options);this.addOptions(r);if(r){this.setClassification()}},createColorInterpolation:function(){var q=this.classification.bins.length;if(!this.view.legendSet){this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],q)}},setClassification:function(){var r=[];for(var s=0;s<this.layer.features.length;s++){r.push(this.layer.features[s].attributes[this.indicator])}var q={labelGenerator:this.options.labelGenerator};var t=new mapfish.GeoStat.Distribution(r,q);this.minVal=t.minVal;this.maxVal=t.maxVal;if(this.view.legendType===this.gis.conf.finals.widget.legendtype_predefined){if(this.bounds[0]>this.minVal){this.bounds.unshift(this.minVal);this.colorInterpolation.unshift(new mapfish.ColorRgb(240,240,240))}if(this.bounds[this.bounds.length-1]<this.maxVal){this.bounds.push(this.maxVal);this.colorInterpolation.push(new mapfish.ColorRgb(240,240,240))}}this.classification=t.classify(this.method,this.numClasses,this.bounds);this.createColorInterpolation()},applyClassification:function(q,s){this.updateOptions(q,s);var w=OpenLayers.Function.bind(function(y){var z=y.attributes[this.indicator];var x=(z-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return x||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:w});var u=this.classification.getBoundsArray();var v=new Array(u.length-1);for(var r=0;r<u.length-1;r++){var t=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[r].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:u[r],upperBoundary:u[r+1]})});v[r]=t}this.extendStyle(v);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var r=document.createElement("div"),t,s;t=document.createElement("div");t.style.height="14px";t.style.overflow="hidden";t.title=this.view.columns[0].items[0].name;t.innerHTML=this.view.columns[0].items[0].name;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t);t=document.createElement("div");t.style.height="14px";t.style.overflow="hidden";t.title=this.view.filters[0].items[0].name;t.innerHTML=this.view.filters[0].items[0].name;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t);t=document.createElement("div");t.style.width="1px";t.style.height="5px";r.appendChild(t);if(this.view.legendSet){for(var q=0;q<this.classification.bins.length;q++){t=document.createElement("div");t.style.backgroundColor=this.colorInterpolation[q].toHexString();t.style.width="30px";t.style.height=this.view.legendSet.names[q]?"25px":"20px";t.style.cssFloat="left";t.style.marginRight="8px";r.appendChild(t);t=document.createElement("div");t.style.lineHeight=this.view.legendSet.names[q]?"12px":"7px";t.innerHTML='<b style="color:#222; font-size:10px !important">'+(this.view.legendSet.names[q]||"")+"</b><br/>"+this.classification.bins[q].label;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t)}}else{for(var q=0;q<this.classification.bins.length;q++){t=document.createElement("div");t.style.backgroundColor=this.colorInterpolation[q].toHexString();t.style.width="30px";t.style.height="15px";t.style.cssFloat="left";t.style.marginRight="8px";r.appendChild(t);t=document.createElement("div");t.innerHTML=this.classification.bins[q].label;r.appendChild(t);t=document.createElement("div");t.style.clear="left";r.appendChild(t)}}this.layer.legendPanel.update(r.outerHTML)},CLASS_NAME:"mapfish.GeoStat."+i})};mapfish.GeoStat.createThematic("Thematic1");mapfish.GeoStat.createThematic("Thematic2");mapfish.GeoStat.createThematic("Thematic3");mapfish.GeoStat.createThematic("Thematic4")}());var g={user:{}},f=[],h=false,b=false,a,c,d;GIS.i18n={facility_layer_legend:"Facility layer legend",thematic_layer_1_legend:"Thematic layer 1 legend",thematic_layer_2_legend:"Thematic layer 2 legend",thematic_layer_3_legend:"Thematic layer 3 legend",thematic_layer_4_legend:"Thematic layer 4 legend",measure_distance:"Measure distance"};GIS.plugin={};a=function(j){var o=false,n=[],m=0,l;l=function(){if(++m===n.length){b=true;for(var p=0;p<f.length;p++){d(f[p])}f=[]}};n.push({url:j+"/api/system/context.jsonp",success:function(i){g.contextPath=i.contextPath;l()}});n.push({url:j+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(p){var i=p.organisationUnits[0];g.user.ou=i.id;g.user.ouc=Ext.Array.pluck(i.children,"id");l()}});n.push({url:j+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){g.legendSets=i.mapLegendSets;l()}});n.push({url:j+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){g.dimensions=i.dimensions;l()}});for(var k=0;k<n.length;k++){Ext.data.JsonP.request(n[k])}};c=function(){var i=".gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n";i+=".x-panel-body { font-size: 11px; } \n";i+=".x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n";i+=".gis-container-default .x-window-body { padding: 5px; background: #fff; } \n";i+=".olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n";i+='.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';i+=".olControlPanel.zoomIn { right: 72px; } \n";i+=".olControlPanel.zoomIn .olControlButtonItemActive { border-bottom-left-radius: 2px; } \n";i+=".olControlPanel.zoomOut { right: 48px; } \n";i+=".olControlPanel.zoomVisible { right: 24px; } \n";i+=".olControlPermalink { display: none !important; } \n";i+='.olControlMousePosition { background: #fff !important; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 2px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.2px; -webkit-text-stroke-color: #555; } \n';i+=".olControlMousePosition * { font-size: 10px !important; } \n";i+=".text-mouseposition-lonlat { color: #555; } \n";i+=".olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n";i+='#google-logo { background: url("'+g.contextPath+'/dhis-web-mapping/app/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';i+=".olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n";i+=".olControlScaleLineBottom { display: none; } \n";i+=".olControlScaleLineTop { font-weight: bold; } \n";i+=".x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n";i+=".x-mask-msg div { background-position: 11px center; } \n";i+=".x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n";i+=".gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n";i+=".gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n";i+='.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 5px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';i+=".x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n";i+=".x-menu-item-active .x-menu-item-link {	border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n";i+=".x-menu-item-link { padding: 4px 5px 4px 26px; } \n";i+=".x-menu-item-text { color: #111; } \n";i+=".disabled { opacity: 0.4; cursor: default !important; } \n";i+=".el-opacity-1 { opacity: 1 !important; } \n";i+=".el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n";i+=".el-fontsize-10 { font-size: 10px !important; } \n";i+=".gis-grid-row-icon-disabled * { cursor: default !important; } \n";i+=".gis-toolbar-btn-menu { margin-top: 4px; } \n";i+=".gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n";i+=".gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n";i+=".gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n";i+=".gis-menu-item-first.x-menu-item-active .x-menu-item-link {	border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n";i+=".gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n";i+='.gis-menu-item-icon-drill { \n background: url("'+g.contextPath+'/dhis-web-mapping/app/images/drill_16.png") no-repeat; } \n';i+='.gis-menu-item-icon-float { background: url("'+g.contextPath+'/dhis-web-mapping/app/images/float_16.png") no-repeat; } \n';i+=".x-color-picker a { padding: 0; } \n";i+=".x-color-picker em span { width: 14px; height: 14px; } \n";Ext.util.CSS.createStyleSheet(i)};d=function(l){var n,j,m,i,k;n=function(){if(!Ext.isString(l.url)){alert("Invalid url ("+l.el+")");return}if(l.url.split("").pop()==="/"){l.url=l.url.substr(0,l.url.length-1)}if(!Ext.isString(l.el)){alert("Invalid html element id ("+l.el+")");return}l.id=l.id||l.uid;if(l.id&&!Ext.isString(l.id)){alert("Invalid map id ("+l.el+")");return}return true};j=function(){var o,r,q,p=Ext.get(k.el);o=Ext.create("Ext.panel.Panel",{renderTo:p,width:p.getWidth(),height:p.getHeight(),cls:"gis-plugin",layout:{type:"hbox",align:"stretch"},items:[{xtype:"gx_mappanel",map:k.olmap,bodyStyle:"border:0 none",width:p.getWidth()-(k.map.hideLegend?0:200),height:p.getHeight(),listeners:{added:function(){q=this}}},{xtype:"panel",layout:"anchor",bodyStyle:"border-top:0 none; border-bottom:0 none",width:k.map.hideLegend?0:200,preventHeader:true,defaults:{bodyStyle:"padding: 6px; border: 0 none",collapsible:true,collapsed:true,animCollapse:false},items:[{title:GIS.i18n.thematic_layer_1_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic1.legendPanel=this}}},{title:GIS.i18n.thematic_layer_2_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic2.legendPanel=this}}},{title:GIS.i18n.thematic_layer_3_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic3.legendPanel=this}}},{title:GIS.i18n.thematic_layer_4_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.thematic4.legendPanel=this}}},{title:GIS.i18n.facility_layer_legend,bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){k.layer.facility.legendPanel=this}}}],listeners:{added:function(){r=this}}}],listeners:{afterrender:function(){m()}}});o.centerRegion=q;o.eastRegion=r;return o};m=function(p){var o=Ext.query(".zoomInButton").length;for(var q=0;q<o;q++){Ext.query(".zoomInButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomin_24.png" />';Ext.query(".zoomOutButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomout_24.png" />';Ext.query(".zoomVisibleButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/zoomvisible_24.png" />';Ext.query(".measureButton")[q].innerHTML='<img src="'+k.init.contextPath+'/dhis-web-mapping/app/images/measure_24.png" />'}if(Ext.isDefined(k.map.baseLayer)){var r=Ext.isString(k.map.baseLayer)?k.map.baseLayer.split(" ").join("").toLowerCase():k.map.baseLayer;if(!r||r==="none"||r==="off"){k.layer.googleStreets.setVisibility(false)}else{if(r==="gh"||r==="googlehybrid"){k.olmap.setBaseLayer(k.layer.googleHybrid)}else{if(r==="osm"||r==="openstreetmap"){k.olmap.setBaseLayer(k.layer.openStreetMap)}}}}};i=function(){if(!n()){return}c();k=GIS.core.getInstance(g);k.el=l.el;GIS.core.createSelectHandlers(k,k.layer.boundary);GIS.core.createSelectHandlers(k,k.layer.thematic1);GIS.core.createSelectHandlers(k,k.layer.thematic2);GIS.core.createSelectHandlers(k,k.layer.thematic3);GIS.core.createSelectHandlers(k,k.layer.thematic4);GIS.core.createSelectHandlers(k,k.layer.facility);k.map=l;k.viewport=j();k.olmap.mask=Ext.create("Ext.LoadMask",k.viewport.centerRegion.getEl(),{msg:"Loading"});GIS.core.MapLoader(k).load()}()};GIS.plugin.getMap=function(i){if(Ext.isString(i.url)&&i.url.split("").pop()==="/"){i.url=i.url.substr(0,i.url.length-1)}if(b){d(i)}else{f.push(i);if(!h){h=true;a(i.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getMap=GIS.plugin.getMap});

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js	2014-01-03 19:36:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js	2014-02-08 18:09:18 +0000
@@ -1,1 +1,1 @@
-Ext.onReady(function(){Ext.Ajax.method="GET";PT={};PT.instances=[];PT.i18n={};PT.isDebug=false;PT.isSessionStorage=("sessionStorage" in window&&window.sessionStorage!==null);PT.getCore=function(m){var i={},k={},j={},g={},h={},l;(function(){i.finals={url:{path_module:"/dhis-web-pivot/",organisationunitchildren_get:"getOrganisationUnitChildren.action"},dimension:{data:{value:"data",name:PT.i18n.data,dimensionName:"dx",objectName:"dx",warning:{filter:"..."}},category:{name:PT.i18n.categories,dimensionName:"co",objectName:"co"},indicator:{value:"indicators",name:PT.i18n.indicators,dimensionName:"dx",objectName:"in"},dataElement:{value:"dataElements",name:PT.i18n.data_elements,dimensionName:"dx",objectName:"de"},operand:{value:"operand",name:"Operand",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataSets",name:PT.i18n.data_sets,dimensionName:"dx",objectName:"ds"},period:{value:"period",name:PT.i18n.periods,dimensionName:"pe",objectName:"pe"},fixedPeriod:{value:"periods"},relativePeriod:{value:"relativePeriods"},organisationUnit:{value:"organisationUnits",name:PT.i18n.organisation_units,dimensionName:"ou",objectName:"ou"},dimension:{value:"dimension"},value:{value:"value"}},root:{id:"root"}};l=i.finals.dimension;l.objectNameMap={};l.objectNameMap[l.data.objectName]=l.data;l.objectNameMap[l.indicator.objectName]=l.indicator;l.objectNameMap[l.dataElement.objectName]=l.dataElement;l.objectNameMap[l.operand.objectName]=l.operand;l.objectNameMap[l.dataSet.objectName]=l.dataSet;l.objectNameMap[l.category.objectName]=l.category;l.objectNameMap[l.period.objectName]=l.period;l.objectNameMap[l.organisationUnit.objectName]=l.organisationUnit;l.objectNameMap[l.dimension.objectName]=l.dimension;i.period={periodTypes:[{id:"Daily",name:PT.i18n.daily},{id:"Weekly",name:PT.i18n.weekly},{id:"Monthly",name:PT.i18n.monthly},{id:"BiMonthly",name:PT.i18n.bimonthly},{id:"Quarterly",name:PT.i18n.quarterly},{id:"SixMonthly",name:PT.i18n.sixmonthly},{id:"Yearly",name:PT.i18n.yearly},{id:"FinancialOct",name:PT.i18n.financial_oct},{id:"FinancialJuly",name:PT.i18n.financial_july},{id:"FinancialApril",name:PT.i18n.financial_april}]};i.layout={west_width:424,west_fieldset_width:416,west_width_padding:4,west_fill:2,west_fill_accordion_indicator:59,west_fill_accordion_dataelement:59,west_fill_accordion_dataset:33,west_fill_accordion_period:296,west_fill_accordion_organisationunit:62,west_maxheight_accordion_indicator:400,west_maxheight_accordion_dataelement:400,west_maxheight_accordion_dataset:400,west_maxheight_accordion_period:513,west_maxheight_accordion_organisationunit:900,west_maxheight_accordion_group:340,west_maxheight_accordion_options:449,west_scrollbarheight_accordion_indicator:300,west_scrollbarheight_accordion_dataelement:300,west_scrollbarheight_accordion_dataset:300,west_scrollbarheight_accordion_period:450,west_scrollbarheight_accordion_organisationunit:450,west_scrollbarheight_accordion_group:300,east_tbar_height:31,east_gridcolumn_height:30,form_label_width:55,window_favorite_ypos:100,window_confirm_width:250,window_share_width:500,grid_favorite_width:420,grid_row_height:27,treepanel_minheight:135,treepanel_maxheight:400,treepanel_fill_default:310,treepanel_toolbar_menu_width_group:140,treepanel_toolbar_menu_width_level:120,multiselect_minheight:100,multiselect_maxheight:250,multiselect_fill_default:345,multiselect_fill_reportingrates:315};i.pivot={digitGroupSeparator:{comma:",",space:" "},displayDensity:{compact:"3px",normal:"5px",comfortable:"10px"},fontSize:{small:"10px",normal:"11px",large:"13px"}}}());(function(){k.layout={};k.layout.Record=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Record: config is not an object: "+n);return}if(!Ext.isString(n.id)){alert("Record: id is not text: "+n);return}n.id=n.id.replace(".","-");return n}()};k.layout.Dimension=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Dimension: config is not an object: "+n);return}if(!Ext.isString(n.dimension)){console.log("Dimension: name is not a string: "+n);return}if(n.dimension!==i.finals.dimension.category.objectName){var o=[];if(!Ext.isArray(n.items)){console.log("Dimension: items is not an array: "+n);return}for(var p=0;p<n.items.length;p++){o.push(k.layout.Record(n.items[p]))}n.items=Ext.Array.clean(o);if(!n.items.length){console.log("Dimension: has no valid items: "+n);return}}return n}()};k.layout.Layout=function(o){var o=Ext.clone(o),p={},n,q;n=function(s){var s=Ext.clone(s);if(!(s&&Ext.isArray(s)&&s.length)){return}for(var r=0;r<s.length;r++){s[r]=k.layout.Dimension(s[r])}s=Ext.Array.clean(s);return s.length?s:null};q=function(){var t=i.finals.dimension,s,u={};if(!p){return}s=Ext.Array.clean([].concat(p.columns||[],p.rows||[],p.filters||[]));for(var r=0;r<s.length;r++){u[s[r].dimension]=s[r]}if(p.filters&&p.filters.length){for(var r=0;r<p.filters.length;r++){if(p.filters[r].dimension===t.indicator.objectName){h.message.alert(PT.i18n.indicators_cannot_be_specified_as_filter||"Indicators cannot be specified as filter");return}if(p.filters[r].dimension===t.category.objectName){h.message.alert(PT.i18n.categories_cannot_be_specified_as_filter||"Categories cannot be specified as filter");return}if(p.filters[r].dimension===t.dataSet.objectName){h.message.alert(PT.i18n.data_sets_cannot_be_specified_as_filter||"Data sets cannot be specified as filter");return}}}if(u[t.operand.objectName]&&u[t.indicator.objectName]){h.message.alert("Indicators and detailed data elements cannot be specified together");return}if(u[t.operand.objectName]&&u[t.dataElement.objectName]){h.message.alert("Detailed data elements and totals cannot be specified together");return}if(u[t.operand.objectName]&&u[t.dataSet.objectName]){h.message.alert("Data sets and detailed data elements cannot be specified together");return}if(u[t.operand.objectName]&&u[t.category.objectName]){h.message.alert("Categories and detailed data elements cannot be specified together");return}return true};return function(){var r=[],t=i.finals.dimension;if(!(o&&Ext.isObject(o))){alert("Layout: config is not an object ("+m.el+")");return}o.columns=n(o.columns);o.rows=n(o.rows);o.filters=n(o.filters);if(!(o.columns||o.rows)){alert(PT.i18n.at_least_one_dimension_must_be_specified_as_row_or_column);return}for(var s=0,u=Ext.Array.clean([].concat(o.columns||[],o.rows||[],o.filters||[]));s<u.length;s++){if(k.layout.Dimension(u[s])){r.push(u[s].dimension)}}if(!Ext.Array.contains(r,t.period.objectName)){alert(PT.i18n.at_least_one_period_must_be_specified_as_column_row_or_filter);return}if(o.id){p.id=o.id}if(o.name){p.name=o.name}p.columns=o.columns;p.rows=o.rows;p.filters=o.filters;p.showTotals=Ext.isBoolean(o.totals)?o.totals:(Ext.isBoolean(o.showTotals)?o.showTotals:true);p.showSubTotals=Ext.isBoolean(o.subtotals)?o.subtotals:(Ext.isBoolean(o.showSubTotals)?o.showSubTotals:true);p.hideEmptyRows=Ext.isBoolean(o.hideEmptyRows)?o.hideEmptyRows:false;p.showHierarchy=Ext.isBoolean(o.showHierarchy)?o.showHierarchy:false;p.displayDensity=Ext.isString(o.displayDensity)&&!Ext.isEmpty(o.displayDensity)?o.displayDensity:"normal";p.fontSize=Ext.isString(o.fontSize)&&!Ext.isEmpty(o.fontSize)?o.fontSize:"normal";p.digitGroupSeparator=Ext.isString(o.digitGroupSeparator)&&!Ext.isEmpty(o.digitGroupSeparator)?o.digitGroupSeparator:"space";p.legendSet=Ext.isObject(o.legendSet)&&Ext.isString(o.legendSet.id)?o.legendSet:null;p.parentGraphMap=Ext.isObject(o.parentGraphMap)?o.parentGraphMap:null;p.sorting=Ext.isObject(o.sorting)&&Ext.isString(o.sorting.id)&&Ext.isString(o.sorting.direction)?o.sorting:null;p.reportingPeriod=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramReportingPeriod)?o.reportParams.paramReportingPeriod:(Ext.isBoolean(o.reportingPeriod)?o.reportingPeriod:false);p.organisationUnit=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramOrganisationUnit)?o.reportParams.paramOrganisationUnit:(Ext.isBoolean(o.organisationUnit)?o.organisationUnit:false);p.parentOrganisationUnit=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramParentOrganisationUnit)?o.reportParams.paramParentOrganisationUnit:(Ext.isBoolean(o.parentOrganisationUnit)?o.parentOrganisationUnit:false);p.regression=Ext.isBoolean(o.regression)?o.regression:false;p.cumulative=Ext.isBoolean(o.cumulative)?o.cumulative:false;p.sortOrder=Ext.isNumber(o.sortOrder)?o.sortOrder:0;p.topLimit=Ext.isNumber(o.topLimit)?o.topLimit:0;if(!q()){return}return p}()};k.response={};k.response.Header=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Header: config is not an object: "+n);return}if(!Ext.isString(n.name)){console.log("Header: name is not a string: "+n);return}if(!Ext.isBoolean(n.meta)){console.log("Header: meta is not boolean: "+n);return}return n}()};k.response.Response=function(n){var n=Ext.clone(n);return function(){if(!(n&&Ext.isObject(n))){console.log("Response: config is not an object");return}if(!(n.headers&&Ext.isArray(n.headers))){console.log("Response: headers is not an array");return}for(var o=0,p;o<n.headers.length;o++){n.headers[o]=k.response.Header(n.headers[o])}n.headers=Ext.Array.clean(n.headers);if(!n.headers.length){console.log("Response: no valid headers");return}if(!(Ext.isArray(n.rows)&&n.rows.length>0)){alert("No values found");return}if(n.headers.length!==n.rows[0].length){console.log("Response: headers.length !== rows[0].length")}return n}()}}());(function(){j.prototype={};j.prototype.array={};j.prototype.array.getLength=function(o,n){if(!Ext.isArray(o)){if(!n){console.log("support.prototype.array.getLength: not an array")}return null}return o.length};j.prototype.array.sort=function(p,o,n){if(!j.prototype.array.getLength(p)){return}n=n||"name";p.sort(function(r,q){if(Ext.isObject(r)&&Ext.isObject(q)&&n){r=r[n];q=q[n]}if(Ext.isString(r)&&Ext.isString(q)){r=r.toLowerCase();q=q.toLowerCase();if(o==="DESC"){return r<q?1:(r>q?-1:0)}else{return r<q?-1:(r>q?1:0)}}else{if(Ext.isNumber(r)&&Ext.isNumber(q)){return o==="DESC"?q-r:r-q}}return -1});return p};j.prototype.object={};j.prototype.object.getLength=function(n,q){if(!Ext.isObject(n)){if(!q){console.log("support.prototype.object.getLength: not an object")}return null}var p=0;for(var o in n){if(n.hasOwnProperty(o)){p++}}return p};j.prototype.object.hasObject=function(o,r,q){if(!j.prototype.object.getLength(o)){return null}for(var p in o){var n=o[p];if(o.hasOwnProperty(p)&&n[r]===q){return true}}return null};j.prototype.str={};j.prototype.str.replaceAll=function(p,o,n){return p.replace(new RegExp(o,"g"),n)};j.prototype.str.toggleDirection=function(n){return n==="DESC"?"ASC":"DESC"};j.prototype.number={};j.prototype.number.getNumberOfDecimals=function(n){var o=new String(n);return(o.indexOf(".")>-1)?(o.length-o.indexOf(".")-1):0};j.prototype.number.roundIf=function(p,n){p=parseFloat(p);n=parseFloat(n);if(Ext.isNumber(p)&&Ext.isNumber(n)){var o=j.prototype.number.getNumberOfDecimals(p);return o>n?Ext.Number.toFixed(p,n):p}return p};j.prototype.number.prettyPrint=function(n,o){o=o||"space";if(o==="none"){return n}return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,i.pivot.digitGroupSeparator[o])};j.color={};j.color.hexToRgb=function(p){var o=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,n;p=p.replace(o,function(s,u,t,q){return u+u+t+t+q+q});n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(p);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null}}());(function(){g.layout={};g.layout.cleanDimensionArray=function(o){if(!j.prototype.array.getLength(o)){return null}var p=[];for(var n=0;n<o.length;n++){p.push(k.layout.Dimension(o[n]))}p=Ext.Array.clean(p);return p.length?p:null};g.layout.sortDimensionArray=function(q,p){if(!j.prototype.array.getLength(q,true)){return null}q=g.layout.cleanDimensionArray(q);if(!q){console.log("service.layout.sortDimensionArray: no valid dimensions");return null}p=p||"dimensionName";Ext.Array.sort(q,function(s,r){if(s[p]<r[p]){return -1}if(s[p]>r[p]){return 1}return 0});for(var o=0,n;o<q.length;o++){j.prototype.array.sort(q[o].items,"ASC","id");if(j.prototype.array.getLength(q[o].ids)){j.prototype.array.sort(q[o].ids)}}return q};g.layout.getObjectNameDimensionMapFromDimensionArray=function(q){var p={};if(!j.prototype.array.getLength(q)){return null}for(var n=0,o;n<q.length;n++){o=k.layout.Dimension(q[n]);if(o){p[o.dimension]=o}}return j.prototype.object.getLength(p)?p:null};g.layout.getObjectNameDimensionItemsMapFromDimensionArray=function(q){var p={};if(!j.prototype.array.getLength(q)){return null}for(var n=0,o;n<q.length;n++){o=k.layout.Dimension(q[n]);if(o){p[o.dimension]=o.items}}return j.prototype.object.getLength(p)?p:null};g.layout.getItemName=function(t,p,u,s){var o=p.metaData,q="";if(g.layout.isHierarchy(t,p,u)){var n=Ext.Array.clean(o.ouHierarchy[u].split("/"));n.shift();for(var r=0;r<n.length;r++){q+=(s?'<span class="text-weak">':"")+o.names[n[r]]+(s?"</span>":"")+" / "}}q+=o.names[u];return q};g.layout.getExtendedLayout=function(s){var s=Ext.clone(s),u;u={columns:[],rows:[],filters:[],columnObjectNames:[],columnDimensionNames:[],rowObjectNames:[],rowDimensionNames:[],axisDimensions:[],axisObjectNames:[],axisDimensionNames:[],sortedAxisDimensionNames:[],filterDimensions:[],filterObjectNames:[],filterDimensionNames:[],sortedFilterDimensions:[],dimensions:[],objectNames:[],dimensionNames:[],objectNameDimensionsMap:{},objectNameItemsMap:{},objectNameIdsMap:{},dimensionNameDimensionsMap:{},dimensionNameItemsMap:{},dimensionNameIdsMap:{},dimensionNameSortedIdsMap:{},sortableIdObjects:[]};Ext.applyIf(u,s);if(s.columns){for(var q=0,r,t,n;q<s.columns.length;q++){r=s.columns[q];t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.columns.push(n);u.columnObjectNames.push(n.objectName);u.columnDimensionNames.push(n.dimensionName);u.axisDimensions.push(n);u.axisObjectNames.push(n.objectName);u.axisDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}if(s.rows){for(var q=0,r,t,n;q<s.rows.length;q++){r=Ext.clone(s.rows[q]);t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.rows.push(n);u.rowObjectNames.push(n.objectName);u.rowDimensionNames.push(n.dimensionName);u.axisDimensions.push(n);u.axisObjectNames.push(n.objectName);u.axisDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}if(s.filters){for(var q=0,r,t,n;q<s.filters.length;q++){r=s.filters[q];t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.filters.push(n);u.filterDimensions.push(n);u.filterObjectNames.push(n.objectName);u.filterDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}u.legendSet=s.legendSet?m.idLegendSetMap[s.legendSet.id]:null;if(s.legendSet){u.legendSet=m.idLegendSetMap[s.legendSet.id];j.prototype.array.sort(u.legendSet.mapLegends,"ASC","startValue")}u.axisDimensionNames=Ext.Array.unique(u.axisDimensionNames);u.filterDimensionNames=Ext.Array.unique(u.filterDimensionNames);u.columnDimensionNames=Ext.Array.unique(u.columnDimensionNames);u.rowDimensionNames=Ext.Array.unique(u.rowDimensionNames);u.filterDimensionNames=Ext.Array.unique(u.filterDimensionNames);u.sortedAxisDimensionNames=Ext.clone(u.axisDimensionNames).sort();u.sortedFilterDimensions=g.layout.sortDimensionArray(Ext.clone(u.filterDimensions));u.dimensions=[].concat(u.axisDimensions,u.filterDimensions);u.objectNames=[].concat(u.axisObjectNames,u.filterObjectNames);u.dimensionNames=[].concat(u.axisDimensionNames,u.filterDimensionNames);for(var q=0,o;q<u.dimensionNames.length;q++){o=u.dimensionNames[q];u.dimensionNameDimensionsMap[o]=[];u.dimensionNameItemsMap[o]=[];u.dimensionNameIdsMap[o]=[]}for(var q=0,n;q<u.dimensions.length;q++){n=u.dimensions[q];u.dimensionNameDimensionsMap[n.dimensionName].push(n);u.dimensionNameItemsMap[n.dimensionName]=u.dimensionNameItemsMap[n.dimensionName].concat(n.items);u.dimensionNameIdsMap[n.dimensionName]=u.dimensionNameIdsMap[n.dimensionName].concat(n.ids)}for(var v in u.dimensionNameIdsMap){if(u.dimensionNameIdsMap.hasOwnProperty(v)){u.dimensionNameSortedIdsMap[v]=Ext.clone(u.dimensionNameIdsMap[v]).sort()}}u.tableUuid=m.el+"_"+Ext.data.IdGenerator.get("uuid").generate();return u};g.layout.getSyncronizedXLayout=function(o,n){var q,r,p=Ext.Array.clean([].concat(o.columns||[],o.rows||[],o.filters||[]));q=function(t){var s;s=function(v){var w;v=Ext.clone(v);for(var u=0;u<v.length;u++){if(v[u].dimension===t){w=v[u]}}if(w){Ext.Array.remove(v,w)}return v};if(o.columns){o.columns=s(o.columns)}if(o.rows){o.rows=s(o.rows)}if(o.filters){o.filters=s(o.filters)}};r=function(){var t=[];for(var s=0;s<n.headers.length;s++){t.push(n.headers[s].name)}return t};return function(){var t=r(),O=o.objectNameDimensionsMap[l.organisationUnit.objectName],z=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT"),Q=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT_CHILDREN"),N=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT_GRANDCHILDREN"),s=function(){if(O&&Ext.isArray(O.ids)){for(var S=0;S<O.ids.length;S++){if(O.ids[S].substr(0,5)==="LEVEL"){return true}}}return false}(),B=function(){if(O&&Ext.isArray(O.ids)){for(var S=0;S<O.ids.length;S++){if(O.ids[S].substr(0,8)==="OU_GROUP"){return true}}}return false}(),y=l.category.objectName,v=l.organisationUnit.objectName,R;for(var J=0,H,A,C;J<p.length;J++){H=p[J];H.items=[];A=n.metaData[H.objectName];if(H.dimensionName===v){if(z||Q||N){var M,x,E;if(z){M=[{id:m.user.ou,name:g.layout.getItemName(o,n,m.user.ou,false)}]}if(Q){x=[];for(var G=0;G<m.user.ouc.length;G++){x.push({id:m.user.ouc[G],name:g.layout.getItemName(o,n,m.user.ouc[G],false)})}j.prototype.array.sort(x)}if(N){var u=[].concat(m.user.ou,m.user.ouc),w=n.metaData[v];E=[];for(var G=0,D;G<w.length;G++){D=w[G];if(!Ext.Array.contains(u,D)){E.push({id:D,name:g.layout.getItemName(o,n,D,false)})}}j.prototype.array.sort(E)}H.items=[].concat(M||[],x||[],E||[])}else{if(s||B){for(var G=0,w=n.metaData[v],D;G<w.length;G++){D=w[G];H.items.push({id:D,name:g.layout.getItemName(o,n,D,false)})}j.prototype.array.sort(H.items)}else{H.items=Ext.clone(o.dimensionNameItemsMap[H.dimensionName])}}}else{if(Ext.isArray(A)&&A.length){var F=Ext.clone(n.metaData[H.dimensionName]);for(var G=0;G<F.length;G++){H.items.push({id:F[G],name:n.metaData.names[F[G]]})}}else{H.items=Ext.clone(o.objectNameItemsMap[H.objectName])}}}for(var J=0,K;J<o.axisDimensionNames.length;J++){K=o.axisDimensionNames[J];if(!Ext.Array.contains(t,K)){q(K)}}R=k.layout.Layout(o);if(R){p=Ext.Array.clean([].concat(R.columns||[],R.rows||[],R.filters||[]));for(var J=0,I=n.metaData.names,L;J<p.length;J++){L=p[J].items;if(Ext.isArray(L)&&L.length){for(var G=0,P;G<L.length;G++){P=L[G];if(Ext.isObject(P)&&Ext.isString(I[P.id])&&!Ext.isString(P.name)){P.name=I[P.id]||""}}}}return g.layout.getExtendedLayout(R)}return null}()};g.layout.getExtendedAxis=function(z,L,Z){var t,r,A=[],y=1,I,q,E=[],Y=[],s=[],D=[],w=[],x=[],N=[],u={};if(Z==="col"){t=Ext.clone(z.columnDimensionNames);r="colSpan"}else{if(Z==="row"){t=Ext.clone(z.rowDimensionNames);r="rowSpan"}}if(!(Ext.isArray(t)&&t.length)){return}for(var U=0;U<t.length;U++){A.push({dimensionName:t[U]})}q=function(){var n=[];for(var aa=0;aa<A.length;aa++){n.push(L.nameHeaderMap[A[aa].dimensionName].ids)}return n}();I=q.length;for(var U=0,K;U<I;U++){K=q[U].length;E.push(K);y=y*K;Y.push(y)}for(var U=0;U<I;U++){if(E[U]===1){if(U===0){s.push(y)}else{if(z.hideEmptyRows&&Z==="row"){s.push(y/Y[U])}else{s.push(s[0])}}}else{s.push(y/Y[U])}}D.push(q[0]);if(I.length>1){for(var U=1,W,O;U<I;U++){W=[];O=E[U]===1?E[0]:Y[U-1];for(var S=0;S<O;S++){W=W.concat(q[U])}D.push(W)}}for(var U=0,v,P,B,T;U<I;U++){v=[];P=q[U];B=s[U];T=y/(B*P.length);for(var S=0;S<T;S++){for(var R=0;R<P.length;R++){for(var Q=0;Q<B;Q++){v.push(P[R])}}}w.push(v)}for(var U=0,H;U<y;U++){H="";for(var S=0;S<I;S++){H+=w[S][U]}if(H){x.push(H)}}for(var U=0,F;U<w.length;U++){F=[];for(var S=0,p;S<w[U].length;S++){p={id:w[U][S],uuid:Ext.data.IdGenerator.get("uuid").generate(),dim:U,axis:Z};if(U===w.length-1){p.leaf=true}F.push(p)}N.push(F)}for(var U=0;U<N.length;U++){for(var S=0,p,X=0,o;S<N[U].length;S++){p=N[U][S];if(X===0){p[r]=s[U];p.children=p.leaf?0:s[U];p.oldest=true;if(U===0){p.root=true}o=p}p.oldestSibling=o;if(++X===s[U]){X=0}}}if(I>1){for(var U=1,F;U<I;U++){F=N[U];for(var S=0,X=0,B=s[U-1];S<F.length;S++){F[S].parent=N[U-1][S]}}}if(N.length){var B=I>1?j.prototype.array.sort(Ext.clone(s))[1]:y,J=N[N.length-1];for(var U=0,V,C,p,G=[];U<J.length;U++){V=J[U];G.push(V.uuid);C=[];p=V;while(p.parent){p=p.parent;C.push(p.oldestSibling.uuid)}V.uuids=Ext.clone(C);if(G.length===B){for(var S=(U-B)+1,V;S<=U;S++){V=J[S];V.uuids=V.uuids.concat(Ext.clone(G))}G=[]}}}for(var U=0;U<N.length;U++){for(var S=0,M;S<N[U].length;S++){M=N[U][S];u[M.uuid]=M}}return{type:Z,items:A,xItems:{unique:q,gui:D,all:w},objects:{all:N},ids:x,span:s,dims:I,size:y,uuidObjectMap:u}};g.layout.isHierarchy=function(o,n,p){return o.showHierarchy&&Ext.isObject(n.metaData.ouHierarchy)&&n.metaData.ouHierarchy.hasOwnProperty(p)};g.layout.layout2plugin=function(r){var r=Ext.clone(r),q=Ext.Array.clean([].concat(r.columns||[],r.rows||[],r.filters||[]));if(Ext.isString(r.id)){return{id:r.id}}for(var o=0,s,p;o<q.length;o++){s=q[o];delete s.id;delete s.ids;delete s.type;delete s.dimensionName;delete s.objectName;for(var n=0,p;n<s.items.length;n++){p=s.items[n];delete p.name;delete p.code;delete p.created;delete p.lastUpdated}}if(r.showTotals){delete r.showTotals}if(r.showSubTotals){delete r.showSubTotals}if(!r.hideEmptyRows){delete r.hideEmptyRows}if(!r.showHierarchy){delete r.showHierarchy}if(r.displayDensity==="normal"){delete r.displayDensity}if(r.fontSize==="normal"){delete r.fontSize}if(r.digitGroupSeparator==="space"){delete r.digitGroupSeparator}if(!r.legendSet){delete r.legendSet}if(!r.sorting){delete r.sorting}delete r.parentGraphMap;delete r.reportingPeriod;delete r.organisationUnit;delete r.parentOrganisationUnit;delete r.regression;delete r.cumulative;delete r.sortOrder;delete r.topLimit;return r};g.response={};g.response.getExtendedResponse=function(o,n){var p=[];n.nameHeaderMap={};n.idValueMap={};(function(){for(var q=0,r;q<n.headers.length;q++){r=n.headers[q];r.index=q;if(r.meta){r.ids=Ext.clone(o.dimensionNameIdsMap[r.name])||[];r.size=r.ids.length;p=p.concat(r.ids)}}for(var q=0,r;q<n.headers.length;q++){r=n.headers[q];n.nameHeaderMap[r.name]=r}}());(function(){for(var q=0,s,r;q<p.length;q++){s=p[q];if(s.indexOf("-")!==-1){r=s.split("-");n.metaData.names[s]=n.metaData.names[r[0]]+" "+n.metaData.names[r[1]]}}}());(function(){var v=n.nameHeaderMap[i.finals.dimension.value.value].index,r=n.nameHeaderMap[i.finals.dimension.category.dimensionName],z=l.data.dimensionName,w=l.category.dimensionName,t=o.axisDimensionNames,x=[];for(var u=0;u<t.length;u++){x.push(n.nameHeaderMap[t[u]].index);if(r&&!Ext.Array.contains(t,w)&&t[u]===z){x.push(r.index)}}for(var u=0,y,q;u<n.rows.length;u++){y=n.rows[u];q="";for(var s=0;s<x.length;s++){q+=y[x[s]]}n.idValueMap[q]=y[v]}}());return n}}());(function(){h.mask={};h.mask.show=function(n,o){if(!Ext.isObject(n)){console.log("support.gui.mask.show: component not an object");return null}o=o||"Loading..";if(Ext.isObject(n.mask)&&n.mask.destroy){n.mask.destroy();n.mask=null}n.mask=new Ext.create("Ext.LoadMask",n,{shadow:false,message:o,style:"box-shadow:0",bodyStyle:"box-shadow:0"});n.mask.show()};h.mask.hide=function(n){if(!Ext.isObject(n)){console.log("support.gui.mask.hide: component not an object");return null}if(n.mask){n.mask.destroy();n.mask=null}};h.message={};h.message.alert=function(n){console.log(n)};h.analytics={};h.analytics.getParamString=function(A,q){var u=q?A.sortedAxisDimensionNames:A.axisDimensionNames,B=q?A.sortedFilterDimensions:A.filterDimensions,n=q?A.dimensionNameSortedIdsMap:A.dimensionNameIdsMap,r="?",p=false,o=A.dimensionNameItemsMap,C=l.indicator.dimensionName,z=l.category.dimensionName;for(var v=0,s,y;v<u.length;v++){s=u[v];r+="dimension="+s;y=Ext.clone(n[s]);if(s===C){for(var t=0,x;t<y.length;t++){x=y[t].indexOf("-");if(x>0){p=true;y[t]=y[t].substr(0,x)}}y=Ext.Array.unique(y)}if(s!==z){r+=":"+y.join(";")}if(v<(u.length-1)){r+="&"}}if(p){r+="&dimension="+i.finals.dimension.category.dimensionName}if(Ext.isArray(B)&&B.length){for(var v=0,w;v<B.length;v++){w=B[v];r+="&filter="+w.dimensionName+":"+w.ids.join(";")}}if(A.showHierarchy){r+="&hierarchyMeta=true"}return r};h.analytics.validateUrl=function(o){var p;if(Ext.isIE){p="Too many items selected (url has "+o.length+" characters). Internet Explorer accepts maximum 2048 characters."}else{var n=o.length>8000?"8000":(o.length>4000?"4000":"2000");p="Too many items selected (url has "+o.length+" characters). Please reduce to less than "+n+" characters."}p+="\n\nHint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.";alert(p)};h.pivot={};h.pivot.getHtml=function(C,p,I,B){var v,D,n,o,F,s,q,u,z,E,K,t=function(L){if(!L){return null}var M=L.xItems.unique;if(M){return M.length<2?1:(L.size/M[0].length)}return null},H=t(I),A=t(B),y=[],J=[],r=[],x={},w=Ext.isObject(C.legendSet)&&Ext.isArray(C.legendSet.mapLegends)&&C.legendSet.mapLegends.length,G;v=function(L,M){M=M||2;return parseFloat(j.prototype.number.roundIf(L,2)).toString()};D=function(O,X){var U,V,R,S,M,N,Z,L=Ext.isObject(O)&&Ext.isString(O.type)&&O.type.substr(0,5)==="value"&&!O.empty,T=Ext.isObject(O)&&Ext.isString(O.type)&&O.type==="value"&&!O.empty,Y="",Q="";if(!Ext.isObject(O)){return""}if(L&&C.legendSet){var W=parseFloat(O.value);V=C.legendSet.mapLegends;for(var P=0;P<V.length;P++){if(Ext.Number.constrain(W,V[P].startValue,V[P].endValue)===W){U=V[P].color}}}R=O.colSpan?'colspan="'+O.colSpan+'" ':"";S=O.rowSpan?'rowspan="'+O.rowSpan+'" ':"";M=O.collapsed?"":O.htmlValue||O.value||"";M=O.type!=="dimension"?j.prototype.number.prettyPrint(M,C.digitGroupSeparator):M;N=i.pivot.displayDensity[O.displayDensity]||i.pivot.displayDensity[C.displayDensity];Z=i.pivot.fontSize[O.fontSize]||i.pivot.fontSize[C.fontSize];Y+=O.hidden?" td-hidden":"";Y+=O.collapsed?" td-collapsed":"";Y+=T?" pointer":"";Y+=U?" legend":(O.cls?" "+O.cls:"");if(Ext.isString(X)){Y+=" td-sortable";C.sortableIdObjects.push({id:X,uuid:O.uuid})}Q+="<td "+(O.uuid?('id="'+O.uuid+'" '):"");Q+=' class="'+Y+'" '+R+S;if(U){Q+=">";Q+='<div class="legendCt">';Q+='<div class="number '+O.cls+'" style="padding:'+N+"; padding-right:3px; font-size:"+Z+'">'+M+"</div>";Q+='<div class="arrowCt '+O.cls+'">';Q+='<div class="arrow" style="border-bottom:8px solid transparent; border-right:8px solid '+U+'">&nbsp;</div>';Q+="</div></div></div></td>"}else{Q+='style="padding:'+N+"; font-size:"+Z+';">'+M+"</td>"}return Q};n=function(L){return !!C.showSubTotals&&L&&L.dims>1};o=function(){return !!C.showTotals};doSortableColumnHeaders=function(){return(B&&B.dims===1)};F=function(){var T=[],L;L=function(){return(I&&B)?D({cls:"pivot-dim-empty cursor-default",colSpan:B.dims,rowSpan:I.dims,htmlValue:"&nbsp;"}):""};if(!(I&&Ext.isObject(I))){return T}for(var Q=0,S;Q<I.dims;Q++){S=[];if(Q===0){S.push(L())}for(var O=0,P,M=0,R,N;O<I.size;O++){M++;P=I.objects.all[Q][O];P.type="dimension";P.cls="pivot-dim";P.noBreak=false;P.hidden=!(P.rowSpan||P.colSpan);P.htmlValue=g.layout.getItemName(C,p,P.id,true);if(Q===I.dims-1&&doSortableColumnHeaders()){R=I.ids[O].split("-").join("")}S.push(D(P,R));if(Q===0&&M===I.span[Q]&&n(I)){S.push(D({type:"dimensionSubtotal",cls:"pivot-dim-subtotal cursor-default",rowSpan:I.dims,htmlValue:"&nbsp;"}));M=0}if(Q===0&&(O===I.size-1)&&o()){N=doSortableColumnHeaders()?"total_":null;S.push(D({uuid:Ext.data.IdGenerator.get("uuid").generate(),type:"dimensionTotal",cls:"pivot-dim-total",rowSpan:I.dims,htmlValue:"Total"},N))}}T.push(S)}return T};s=function(){var aA=[],X=[],al,R=[],af=[],ab,ad=I?I.size:1,an=B?B.size:1,ae;ae=function(aB){if(!aB.children){aB.collapsed=true;if(aB.parent){aB.parent.oldestSibling.children--}}if(aB.parent){ae(aB.parent.oldestSibling)}};if(B){for(var aw=0,Z;aw<B.size;aw++){Z=[];for(var av=0,P,ap;av<B.dims;av++){P=B.objects.all[av][aw];P.type="dimension";P.cls="pivot-dim td-nobreak"+(g.layout.isHierarchy(C,p,P.id)?" align-left":"");P.noBreak=true;P.hidden=!(P.rowSpan||P.colSpan);P.htmlValue=g.layout.getItemName(C,p,P.id,true);Z.push(P)}X.push(Z)}}for(var aw=0,N,Q,at=Ext.clone(p.idValueMap);aw<an;aw++){N=[];Q=[];for(var av=0,aj,aq,ay,L,S,M;av<ad;av++){L=false;M=[];aj=(I?j.prototype.str.replaceAll(I.ids[av],"-",""):"")+(B?j.prototype.str.replaceAll(B.ids[aw],"-",""):"");S=Ext.data.IdGenerator.get("uuid").generate();if(I){M=M.concat(I.objects.all[I.dims-1][av].uuids)}if(B){M=M.concat(B.objects.all[B.dims-1][aw].uuids)}if(at[aj]){aq=parseFloat(at[aj]);ay=aq.toString()}else{aq=0;ay="&nbsp;";L=true}N.push(aq);Q.push({uuid:S,type:"value",cls:"pivot-value"+(L?" cursor-default":""),value:aq,htmlValue:ay,empty:L,uuids:M});x[S]=M}y.push(N);J.push(Q)}if(I&&o()){for(var aw=0,L=[],ai=0;aw<J.length;aw++){for(av=0,P;av<J[aw].length;av++){P=J[aw][av];L.push(P.empty);ai+=P.value}R.push({type:"valueTotal",cls:"pivot-value-total",value:ai,htmlValue:Ext.Array.contains(L,false)?v(ai):"",empty:!Ext.Array.contains(L,false)});if(doSortableColumnHeaders()){var W="total_"+B.ids[aw],aa=!Ext.Array.contains(L,false);p.idValueMap[W]=aa?null:ai}L=[];ai=0}}if(I&&B){if(C.hideEmptyRows){for(var aw=0,am,O,ac;aw<J.length;aw++){am=J[aw];O=!Ext.Array.contains(Ext.Array.pluck(am,"empty"),false);if(O){for(var av=0;av<am.length;av++){am[av].collapsed=true}if(o()){R[aw].collapsed=true}ac=X[aw][B.dims-1];ae(ac)}}}}al=Ext.clone(J);if(n(I)){var ag=[];for(var aw=0,Z,V,Y;aw<al.length;aw++){Z=[];V=0;Y=0;for(var av=0,ah,az=[],L=[];av<al[aw].length;av++){ah=al[aw][av];V+=ah.value;L.push(!!ah.empty);az.push(!!ah.collapsed);Y++;Z.push(ah);if(Y===H){var aa=!Ext.Array.contains(L,false);Z.push({type:"valueSubtotal",cls:"pivot-value-subtotal"+(aa?" cursor-default":""),value:V,htmlValue:aa?"&nbsp;":v(V),empty:aa,collapsed:!Ext.Array.contains(az,false)});Y=0;V=0;L=[];az=[]}}ag.push(Z)}al=ag}if(n(B)){var ak=[],ag=[],ax=[],au;au=function(aE){var aD=[];for(var aB=0,aC;aB<B.dims;aB++){aC={};aC.type="dimensionSubtotal";aC.cls="pivot-dim-subtotal cursor-default";aC.collapsed=Ext.Array.contains(aE,true);if(aB===0){aC.htmlValue="&nbsp;";aC.colSpan=B.dims}else{aC.hidden=true}aD.push(aC)}return aD};for(var aw=0,Z,az=[];aw<X.length;aw++){ak.push(X[aw]);az.push(!!X[aw][0].collapsed);if(!Ext.isArray(X[aw+1])||!!X[aw+1][0].root){ak.push(au(az));az=[]}}for(var aw=0;aw<ak.length;aw++){ag.push([])}for(var aw=0;aw<al[0].length;aw++){for(var av=0,T=0,ao=0,U=0,L=[],az,ah;av<al.length;av++){ah=al[av][aw];ag[ao++].push(ah);U+=ah.value;L.push(!!ah.empty);T++;if(X[av][0].root){az=!!X[av][0].collapsed}if(!Ext.isArray(X[av+1])||X[av+1][0].root){var aa=!Ext.Array.contains(L,false);ag[ao++].push({type:ah.type==="value"?"valueSubtotal":"valueSubtotalTotal",value:U,htmlValue:aa?"&nbsp;":v(U),collapsed:az,cls:(ah.type==="value"?"pivot-value-subtotal":"pivot-value-subtotal-total")+(aa?" cursor-default":"")});T=0;U=0;L=[]}}}for(var aw=0,P,az=[],L=[],U=0,ar=0;aw<R.length;aw++){P=R[aw];ax.push(P);az.push(!!P.collapsed);L.push(!!P.empty);U+=P.value;ar++;if(ar===B.span[0]){var aa=!Ext.Array.contains(L,false);ax.push({type:"valueTotalSubgrandtotal",cls:"pivot-value-total-subgrandtotal"+(aa?" cursor-default":""),value:U,htmlValue:aa?"&nbsp;":v(U),empty:aa,collapsed:!Ext.Array.contains(az,false)});az=[];L=[];U=0;ar=0}}X=ak;al=ag;R=ax}for(var aw=0,Z;aw<al.length;aw++){Z=[];if(B){Z=Z.concat(X[aw])}Z=Z.concat(al[aw]);if(I){Z=Z.concat(R[aw])}af.push(Z)}for(var aw=0,Z;aw<af.length;aw++){Z=[];for(var av=0;av<af[aw].length;av++){Z.push(D(af[aw][av]))}aA.push(Z)}return aA};u=function(){var S=[];if(B&&o()){var V;for(var N=0,R=0,Q=[];N<J[0].length;N++){for(var L=0,M;L<J.length;L++){M=J[L][N];R+=M.value;Q.push(!!M.empty)}r.push({type:"valueTotal",value:R,htmlValue:Ext.Array.contains(Q,false)?v(R):"",empty:!Ext.Array.contains(Q,false),cls:"pivot-value-total"});R=0;Q=[]}V=Ext.clone(r);if(I&&n(I)){var O=[];for(var N=0,U,P=0,Q=[],T=0;N<V.length;N++){U=V[N];O.push(U);P+=U.value;Q.push(!!U.empty);T++;if(T===H){O.push({type:"valueTotalSubgrandtotal",value:P,htmlValue:Ext.Array.contains(Q,false)?v(P):"",empty:!Ext.Array.contains(Q,false),cls:"pivot-value-total-subgrandtotal"});P=0;T=0}}V=O}for(var N=0;N<V.length;N++){S.push(D(V[N]))}}return S};z=function(){var N=0,O=[],L=[];if(o()){for(var M=0,P;M<r.length;M++){P=r[M];N+=P.value;O.push(P.empty)}if(I&&B){L.push(D({type:"valueGrandTotal",cls:"pivot-value-grandtotal",value:N,htmlValue:Ext.Array.contains(O,false)?v(N):"",empty:!Ext.Array.contains(O,false)}))}}return L};E=function(){var N,M=u(),O=z(),P,L=[];if(o()){if(B){N=[D({type:"dimensionSubtotal",cls:"pivot-dim-total",colSpan:B.dims,htmlValue:"Total"})]}P=[].concat(N||[],Ext.clone(M)||[],Ext.clone(O)||[]);L.push(P)}return L};K=function(){var M='<table id="'+C.tableUuid+'" class="pivot">';for(var L=0;L<G.length;L++){M+="<tr>"+G[L].join("")+"</tr>"}return M+="</table>"};return function(){G=Ext.Array.clean([].concat(F()||[],s()||[],E()||[]));return{html:K(G),uuidDimUuidsMap:x}}()}}());(function(){if(Ext.isArray(m.dimensions)){j.prototype.array.sort(m.dimensions);for(var n=0,o;n<m.dimensions.length;n++){o=m.dimensions[n];o.dimensionName=o.id;o.objectName=i.finals.dimension.dimension.objectName;i.finals.dimension.objectNameMap[o.id]=o}}j.prototype.array.sort(m.user.ouc);m.idLegendSetMap={};for(var n=0,p;n<m.legendSets.length;n++){p=m.legendSets[n];m.idLegendSetMap[p.id]=p}}());return{conf:i,api:k,support:j,service:g,web:h,init:m}};css="table.pivot { \n font-family: arial,sans-serif,ubuntu,consolas; \n } \n";css+=".td-nobreak { \n white-space: nowrap; \n } \n";css+=".td-hidden { \n display: none; \n } \n";css+=".td-collapsed { \n display: none; \n } \n";css+="table.pivot { \n border-collapse: collapse; \n border-spacing: 0px; \n border: 0 none; \n } \n";css+=".pivot td { \n padding: 5px; \n border: \n 1px solid #b2b2b2; \n } \n";css+=".pivot-dim { \n background-color: #dae6f8; \n text-align: center; \n } \n";css+=".pivot-dim.highlighted { \n	background-color: #c5d8f6; \n } \n";css+=".pivot-dim-subtotal { \n background-color: #cad6e8; \n text-align: center; \n } \n";css+=".pivot-dim-total { \n background-color: #bac6d8; \n text-align: center; \n } \n";css+=".pivot-dim-total.highlighted { \n background-color: #adb8c9; \n } \n";css+=".pivot-dim-empty { \n background-color: #dae6f8; \n text-align: center; \n } \n";css+=".pivot-value { \n background-color: #fff; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-subtotal { \n background-color: #f4f4f4; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-subtotal-total { \n background-color: #e7e7e7; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-total { \n background-color: #e4e4e4; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-total-subgrandtotal { \n background-color: #d8d8d8; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-grandtotal { \n background-color: #c8c8c8; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".x-mask-msg { \n padding: 0; \n	border: 0 none; \n background-image: none; \n background-color: transparent; \n } \n";css+=".x-mask-msg div { \n background-position: 11px center; \n } \n";css+=".x-mask-msg .x-mask-loading { \n border: 0 none; \n	background-color: #000; \n color: #fff; \n border-radius: 2px; \n padding: 12px 14px 12px 30px; \n opacity: 0.65; \n } \n";css+=".pivot td.legend { \n padding: 0; \n } \n";css+=".pivot div.legendCt { \n display: table; \n float: right; \n width: 100%; \n } \n";css+=".pivot div.arrowCt { \n display: table-cell; \n vertical-align: top; \n width: 8px; \n } \n";css+=".pivot div.arrow { \n width: 0; \n height: 0; \n } \n";css+=".pivot div.number { \n display: table-cell; \n } \n",css+=".pivot div.legendColor { \n display: table-cell; \n width: 2px; \n } \n";css+=".pointer { \n cursor: pointer; \n } \n";css+='.td-sortable { \n background-image: url("http://dhis2-cdn.org/v214/plugin/images/arrowupdown.png";); \n background-repeat: no-repeat; \n background-position: right center; \n padding-right: 15px !important; \n } \n';Ext.util.CSS.createStyleSheet(css);PT.plugin={};var e={user:{}},d=[],f=false,b=false,a,c;a=function(g){var m=false,l=[],k=0,j;j=function(){if(++k===l.length){b=true;for(var n=0;n<d.length;n++){c(d[n])}d=[]}};l.push({url:g+"/api/system/context.jsonp",success:function(i){e.contextPath=i.contextPath;j()}});l.push({url:g+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(n){var i=n.organisationUnits[0];e.user.ou=i.id;e.user.ouc=Ext.Array.pluck(i.children,"id");j()}});l.push({url:g+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){e.legendSets=i.mapLegendSets;j()}});l.push({url:g+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){e.dimensions=i.dimensions;j()}});for(var h=0;h<l.length;h++){Ext.data.JsonP.request(l[h])}};c=function(j){var l,i,h,g,k={core:{},app:{}};l=function(m){if(!Ext.isObject(m)){console.log("Report table configuration is not an object");return}if(!Ext.isString(m.el)){console.log("No valid element id provided");return}m.id=m.id||m.uid;return true};i=function(q){var r=k.core.init,p=k.core.api,o=k.core.support,m=k.core.service,n=k.core.web;n.events=n.events||{};n.events.setColumnHeaderMouseHandlers=function(t,s){if(Ext.isArray(t.sortableIdObjects)){for(var u=0,w,v;u<t.sortableIdObjects.length;u++){w=t.sortableIdObjects[u];v=Ext.get(w.uuid);v.dom.xLayout=t;v.dom.response=s;v.dom.metaDataId=w.id;v.dom.onColumnHeaderMouseClick=n.events.onColumnHeaderMouseClick;v.dom.onColumnHeaderMouseOver=n.events.onColumnHeaderMouseOver;v.dom.onColumnHeaderMouseOut=n.events.onColumnHeaderMouseOut;v.dom.setAttribute("onclick","this.onColumnHeaderMouseClick(this.xLayout, this.response, this.metaDataId)");v.dom.setAttribute("onmouseover","this.onColumnHeaderMouseOver(this)");v.dom.setAttribute("onmouseout","this.onColumnHeaderMouseOut(this)")}}};n.events.onColumnHeaderMouseClick=function(t,s,u){if(t.sorting&&t.sorting.id===u){t.sorting.direction=o.prototype.str.toggleDirection(t.sorting.direction)}else{t.sorting={id:u,direction:"DESC"}}k.core.web.pivot.sort(t,s,u)};n.events.onColumnHeaderMouseOver=function(s){Ext.get(s).addCls("pointer highlighted")};n.events.onColumnHeaderMouseOut=function(s){Ext.get(s).removeCls("pointer highlighted")};n.pivot=n.pivot||{};n.pivot.loadTable=function(s){if(!Ext.isString(s)){alert("Invalid report table id");return}Ext.data.JsonP.request({url:r.contextPath+"/api/reportTables/"+s+".jsonp?viewClass=dimensional&links=false",failure:function(t){window.open(r.contextPath+"/api/reportTables/"+s+".json?viewClass=dimensional&links=false","_blank")},success:function(u){var t=p.layout.Layout(u);if(t){n.pivot.getData(t,true)}}})};n.pivot.getData=function(t,u){var s,v;if(!t){return}s=m.layout.getExtendedLayout(t);v=n.analytics.getParamString(s,true);n.mask.show(k.app.centerRegion);Ext.data.JsonP.request({url:r.contextPath+"/api/analytics.jsonp"+v,timeout:60000,headers:{"Content-Type":"application/json",Accepts:"application/json"},disableCaching:false,failure:function(w){n.mask.hide(k.app.centerRegion);window.open(r.contextPath+"/api/analytics.json"+v,"_blank")},success:function(x){var w=p.response.Response(x);if(!w){n.mask.hide(k.app.centerRegion);return}s=m.layout.getSyncronizedXLayout(s,w);if(!s){n.mask.hide(k.app.centerRegion);return}k.app.paramString=v;n.pivot.createTable(t,s,w,u)}})};n.pivot.createTable=function(x,u,t,y){var z,w,s,v;if(!u){u=m.layout.getExtendedLayout(x)}z=m.response.getExtendedResponse(u,t);w=m.layout.getExtendedAxis(u,z,"col");s=m.layout.getExtendedAxis(u,z,"row");v=n.pivot.getHtml(u,z,w,s);k.app.centerRegion.update(v.html);k.app.layout=x;k.app.xLayout=u;k.app.response=t;k.app.xResponse=z;k.app.uuidDimUuidsMap=v.uuidDimUuidsMap;k.app.uuidObjectMap=Ext.applyIf((w?w.uuidObjectMap:{}),(s?s.uuidObjectMap:{}));n.events.setColumnHeaderMouseHandlers(u,t);n.mask.hide(k.app.centerRegion)};n.pivot.sort=function(y,u,s){var y=Ext.clone(y),u=Ext.clone(u),w=y.rows[0],t=u.idValueMap,z=y.sorting?y.sorting.direction:"DESC",x;w.ids=[];for(var v=0,C,B,A;v<w.items.length;v++){C=w.items[v];B=s+C.id;A=parseFloat(t[B]);C.value=Ext.isNumber(A)?A:(Number.MAX_VALUE*-1)}o.prototype.array.sort(w.items,z,"value");for(var v=0;v<w.items.length;v++){w.ids.push(w.items[v].id)}x=p.layout.Layout(y);n.pivot.createTable(x,null,u,false)}};h=function(){return{centerRegion:Ext.get(j.el)}};g=function(){if(!l(j)){return}k.core=PT.getCore(Ext.clone(e));i(k);k.app.viewport=h();k.app.centerRegion=k.app.viewport.centerRegion;if(j.id){k.core.web.pivot.loadTable(j.id)}else{layout=k.core.api.layout.Layout(j);if(!layout){return}k.core.web.pivot.getData(layout)}}()};PT.plugin.getTable=function(g){if(Ext.isString(g.url)&&g.url.split("").pop()==="/"){g.url=g.url.substr(0,g.url.length-1)}if(b){c(g)}else{d.push(g);if(!f){f=true;a(g.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getTable=PT.plugin.getTable});
+Ext.onReady(function(){Ext.Ajax.method="GET";PT={};PT.instances=[];PT.i18n={};PT.isDebug=false;PT.isSessionStorage=("sessionStorage" in window&&window.sessionStorage!==null);PT.getCore=function(m){var i={},k={},j={},g={},h={},l;(function(){i.finals={url:{path_module:"/dhis-web-pivot/",organisationunitchildren_get:"getOrganisationUnitChildren.action"},dimension:{data:{value:"data",name:PT.i18n.data,dimensionName:"dx",objectName:"dx",warning:{filter:"..."}},category:{name:PT.i18n.categories,dimensionName:"co",objectName:"co"},indicator:{value:"indicators",name:PT.i18n.indicators,dimensionName:"dx",objectName:"in"},dataElement:{value:"dataElements",name:PT.i18n.data_elements,dimensionName:"dx",objectName:"de"},operand:{value:"operand",name:"Operand",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataSets",name:PT.i18n.data_sets,dimensionName:"dx",objectName:"ds"},period:{value:"period",name:PT.i18n.periods,dimensionName:"pe",objectName:"pe"},fixedPeriod:{value:"periods"},relativePeriod:{value:"relativePeriods"},organisationUnit:{value:"organisationUnits",name:PT.i18n.organisation_units,dimensionName:"ou",objectName:"ou"},dimension:{value:"dimension"},value:{value:"value"}},root:{id:"root"}};l=i.finals.dimension;l.objectNameMap={};l.objectNameMap[l.data.objectName]=l.data;l.objectNameMap[l.indicator.objectName]=l.indicator;l.objectNameMap[l.dataElement.objectName]=l.dataElement;l.objectNameMap[l.operand.objectName]=l.operand;l.objectNameMap[l.dataSet.objectName]=l.dataSet;l.objectNameMap[l.category.objectName]=l.category;l.objectNameMap[l.period.objectName]=l.period;l.objectNameMap[l.organisationUnit.objectName]=l.organisationUnit;l.objectNameMap[l.dimension.objectName]=l.dimension;i.period={periodTypes:[{id:"Daily",name:PT.i18n.daily},{id:"Weekly",name:PT.i18n.weekly},{id:"Monthly",name:PT.i18n.monthly},{id:"BiMonthly",name:PT.i18n.bimonthly},{id:"Quarterly",name:PT.i18n.quarterly},{id:"SixMonthly",name:PT.i18n.sixmonthly},{id:"SixMonthlyApril",name:PT.i18n.sixmonthly_april},{id:"Yearly",name:PT.i18n.yearly},{id:"FinancialOct",name:PT.i18n.financial_oct},{id:"FinancialJuly",name:PT.i18n.financial_july},{id:"FinancialApril",name:PT.i18n.financial_april}]};i.layout={west_width:424,west_fieldset_width:416,west_width_padding:4,west_fill:2,west_fill_accordion_indicator:59,west_fill_accordion_dataelement:59,west_fill_accordion_dataset:33,west_fill_accordion_period:296,west_fill_accordion_organisationunit:62,west_maxheight_accordion_indicator:400,west_maxheight_accordion_dataelement:400,west_maxheight_accordion_dataset:400,west_maxheight_accordion_period:513,west_maxheight_accordion_organisationunit:900,west_maxheight_accordion_group:340,west_maxheight_accordion_options:449,west_scrollbarheight_accordion_indicator:300,west_scrollbarheight_accordion_dataelement:300,west_scrollbarheight_accordion_dataset:300,west_scrollbarheight_accordion_period:450,west_scrollbarheight_accordion_organisationunit:450,west_scrollbarheight_accordion_group:300,east_tbar_height:31,east_gridcolumn_height:30,form_label_width:55,window_favorite_ypos:100,window_confirm_width:250,window_share_width:500,grid_favorite_width:420,grid_row_height:27,treepanel_minheight:135,treepanel_maxheight:400,treepanel_fill_default:310,treepanel_toolbar_menu_width_group:140,treepanel_toolbar_menu_width_level:120,multiselect_minheight:100,multiselect_maxheight:250,multiselect_fill_default:345,multiselect_fill_reportingrates:315};i.pivot={digitGroupSeparator:{comma:",",space:" "},displayDensity:{compact:"3px",normal:"5px",comfortable:"10px"},fontSize:{small:"10px",normal:"11px",large:"13px"}}}());(function(){k.layout={};k.layout.Record=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Record: config is not an object: "+n);return}if(!Ext.isString(n.id)){alert("Record: id is not text: "+n);return}n.id=n.id.replace(".","-");return n}()};k.layout.Dimension=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Dimension: config is not an object: "+n);return}if(!Ext.isString(n.dimension)){console.log("Dimension: name is not a string: "+n);return}if(n.dimension!==i.finals.dimension.category.objectName){var o=[];if(!Ext.isArray(n.items)){console.log("Dimension: items is not an array: "+n);return}for(var p=0;p<n.items.length;p++){o.push(k.layout.Record(n.items[p]))}n.items=Ext.Array.clean(o);if(!n.items.length){console.log("Dimension: has no valid items: "+n);return}}return n}()};k.layout.Layout=function(o){var o=Ext.clone(o),p={},n,q;n=function(s){var s=Ext.clone(s);if(!(s&&Ext.isArray(s)&&s.length)){return}for(var r=0;r<s.length;r++){s[r]=k.layout.Dimension(s[r])}s=Ext.Array.clean(s);return s.length?s:null};q=function(){var t=i.finals.dimension,s,u={};if(!p){return}s=Ext.Array.clean([].concat(p.columns||[],p.rows||[],p.filters||[]));for(var r=0;r<s.length;r++){u[s[r].dimension]=s[r]}if(p.filters&&p.filters.length){for(var r=0;r<p.filters.length;r++){if(p.filters[r].dimension===t.indicator.objectName){h.message.alert(PT.i18n.indicators_cannot_be_specified_as_filter||"Indicators cannot be specified as filter");return}if(p.filters[r].dimension===t.category.objectName){h.message.alert(PT.i18n.categories_cannot_be_specified_as_filter||"Categories cannot be specified as filter");return}if(p.filters[r].dimension===t.dataSet.objectName){h.message.alert(PT.i18n.data_sets_cannot_be_specified_as_filter||"Data sets cannot be specified as filter");return}}}if(u[t.operand.objectName]&&u[t.indicator.objectName]){h.message.alert("Indicators and detailed data elements cannot be specified together");return}if(u[t.operand.objectName]&&u[t.dataElement.objectName]){h.message.alert("Detailed data elements and totals cannot be specified together");return}if(u[t.operand.objectName]&&u[t.dataSet.objectName]){h.message.alert("Data sets and detailed data elements cannot be specified together");return}if(u[t.operand.objectName]&&u[t.category.objectName]){h.message.alert("Categories and detailed data elements cannot be specified together");return}return true};return function(){var r=[],t=i.finals.dimension;if(!(o&&Ext.isObject(o))){alert("Layout: config is not an object ("+m.el+")");return}o.columns=n(o.columns);o.rows=n(o.rows);o.filters=n(o.filters);if(!(o.columns||o.rows)){alert(PT.i18n.at_least_one_dimension_must_be_specified_as_row_or_column);return}for(var s=0,u=Ext.Array.clean([].concat(o.columns||[],o.rows||[],o.filters||[]));s<u.length;s++){if(k.layout.Dimension(u[s])){r.push(u[s].dimension)}}if(!Ext.Array.contains(r,t.period.objectName)){alert(PT.i18n.at_least_one_period_must_be_specified_as_column_row_or_filter);return}if(o.id){p.id=o.id}if(o.name){p.name=o.name}p.columns=o.columns;p.rows=o.rows;p.filters=o.filters;p.showTotals=Ext.isBoolean(o.totals)?o.totals:(Ext.isBoolean(o.showTotals)?o.showTotals:true);p.showSubTotals=Ext.isBoolean(o.subtotals)?o.subtotals:(Ext.isBoolean(o.showSubTotals)?o.showSubTotals:true);p.hideEmptyRows=Ext.isBoolean(o.hideEmptyRows)?o.hideEmptyRows:false;p.showHierarchy=Ext.isBoolean(o.showHierarchy)?o.showHierarchy:false;p.displayDensity=Ext.isString(o.displayDensity)&&!Ext.isEmpty(o.displayDensity)?o.displayDensity:"normal";p.fontSize=Ext.isString(o.fontSize)&&!Ext.isEmpty(o.fontSize)?o.fontSize:"normal";p.digitGroupSeparator=Ext.isString(o.digitGroupSeparator)&&!Ext.isEmpty(o.digitGroupSeparator)?o.digitGroupSeparator:"space";p.legendSet=Ext.isObject(o.legendSet)&&Ext.isString(o.legendSet.id)?o.legendSet:null;p.parentGraphMap=Ext.isObject(o.parentGraphMap)?o.parentGraphMap:null;p.sorting=Ext.isObject(o.sorting)&&Ext.isString(o.sorting.id)&&Ext.isString(o.sorting.direction)?o.sorting:null;p.reportingPeriod=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramReportingPeriod)?o.reportParams.paramReportingPeriod:(Ext.isBoolean(o.reportingPeriod)?o.reportingPeriod:false);p.organisationUnit=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramOrganisationUnit)?o.reportParams.paramOrganisationUnit:(Ext.isBoolean(o.organisationUnit)?o.organisationUnit:false);p.parentOrganisationUnit=Ext.isObject(o.reportParams)&&Ext.isBoolean(o.reportParams.paramParentOrganisationUnit)?o.reportParams.paramParentOrganisationUnit:(Ext.isBoolean(o.parentOrganisationUnit)?o.parentOrganisationUnit:false);p.regression=Ext.isBoolean(o.regression)?o.regression:false;p.cumulative=Ext.isBoolean(o.cumulative)?o.cumulative:false;p.sortOrder=Ext.isNumber(o.sortOrder)?o.sortOrder:0;p.topLimit=Ext.isNumber(o.topLimit)?o.topLimit:0;if(!q()){return}return p}()};k.response={};k.response.Header=function(n){var n=Ext.clone(n);return function(){if(!Ext.isObject(n)){console.log("Header: config is not an object: "+n);return}if(!Ext.isString(n.name)){console.log("Header: name is not a string: "+n);return}if(!Ext.isBoolean(n.meta)){console.log("Header: meta is not boolean: "+n);return}return n}()};k.response.Response=function(n){var n=Ext.clone(n);return function(){if(!(n&&Ext.isObject(n))){console.log("Response: config is not an object");return}if(!(n.headers&&Ext.isArray(n.headers))){console.log("Response: headers is not an array");return}for(var o=0,p;o<n.headers.length;o++){n.headers[o]=k.response.Header(n.headers[o])}n.headers=Ext.Array.clean(n.headers);if(!n.headers.length){console.log("Response: no valid headers");return}if(!(Ext.isArray(n.rows)&&n.rows.length>0)){alert("No values found");return}if(n.headers.length!==n.rows[0].length){console.log("Response: headers.length !== rows[0].length")}return n}()}}());(function(){j.prototype={};j.prototype.array={};j.prototype.array.getLength=function(o,n){if(!Ext.isArray(o)){if(!n){console.log("support.prototype.array.getLength: not an array")}return null}return o.length};j.prototype.array.sort=function(p,o,n){if(!j.prototype.array.getLength(p)){return}n=n||"name";p.sort(function(r,q){if(Ext.isObject(r)&&Ext.isObject(q)&&n){r=r[n];q=q[n]}if(Ext.isString(r)&&Ext.isString(q)){r=r.toLowerCase();q=q.toLowerCase();if(o==="DESC"){return r<q?1:(r>q?-1:0)}else{return r<q?-1:(r>q?1:0)}}else{if(Ext.isNumber(r)&&Ext.isNumber(q)){return o==="DESC"?q-r:r-q}}return -1});return p};j.prototype.object={};j.prototype.object.getLength=function(n,q){if(!Ext.isObject(n)){if(!q){console.log("support.prototype.object.getLength: not an object")}return null}var p=0;for(var o in n){if(n.hasOwnProperty(o)){p++}}return p};j.prototype.object.hasObject=function(o,r,q){if(!j.prototype.object.getLength(o)){return null}for(var p in o){var n=o[p];if(o.hasOwnProperty(p)&&n[r]===q){return true}}return null};j.prototype.str={};j.prototype.str.replaceAll=function(p,o,n){return p.replace(new RegExp(o,"g"),n)};j.prototype.str.toggleDirection=function(n){return n==="DESC"?"ASC":"DESC"};j.prototype.number={};j.prototype.number.getNumberOfDecimals=function(n){var o=new String(n);return(o.indexOf(".")>-1)?(o.length-o.indexOf(".")-1):0};j.prototype.number.roundIf=function(p,n){p=parseFloat(p);n=parseFloat(n);if(Ext.isNumber(p)&&Ext.isNumber(n)){var o=j.prototype.number.getNumberOfDecimals(p);return o>n?Ext.Number.toFixed(p,n):p}return p};j.prototype.number.prettyPrint=function(n,o){o=o||"space";if(o==="none"){return n}return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,i.pivot.digitGroupSeparator[o])};j.color={};j.color.hexToRgb=function(p){var o=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,n;p=p.replace(o,function(s,u,t,q){return u+u+t+t+q+q});n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(p);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null}}());(function(){g.layout={};g.layout.cleanDimensionArray=function(o){if(!j.prototype.array.getLength(o)){return null}var p=[];for(var n=0;n<o.length;n++){p.push(k.layout.Dimension(o[n]))}p=Ext.Array.clean(p);return p.length?p:null};g.layout.sortDimensionArray=function(q,p){if(!j.prototype.array.getLength(q,true)){return null}q=g.layout.cleanDimensionArray(q);if(!q){console.log("service.layout.sortDimensionArray: no valid dimensions");return null}p=p||"dimensionName";Ext.Array.sort(q,function(s,r){if(s[p]<r[p]){return -1}if(s[p]>r[p]){return 1}return 0});for(var o=0,n;o<q.length;o++){j.prototype.array.sort(q[o].items,"ASC","id");if(j.prototype.array.getLength(q[o].ids)){j.prototype.array.sort(q[o].ids)}}return q};g.layout.getObjectNameDimensionMapFromDimensionArray=function(q){var p={};if(!j.prototype.array.getLength(q)){return null}for(var n=0,o;n<q.length;n++){o=k.layout.Dimension(q[n]);if(o){p[o.dimension]=o}}return j.prototype.object.getLength(p)?p:null};g.layout.getObjectNameDimensionItemsMapFromDimensionArray=function(q){var p={};if(!j.prototype.array.getLength(q)){return null}for(var n=0,o;n<q.length;n++){o=k.layout.Dimension(q[n]);if(o){p[o.dimension]=o.items}}return j.prototype.object.getLength(p)?p:null};g.layout.getItemName=function(t,p,u,s){var o=p.metaData,q="";if(g.layout.isHierarchy(t,p,u)){var n=Ext.Array.clean(o.ouHierarchy[u].split("/"));n.shift();for(var r=0;r<n.length;r++){q+=(s?'<span class="text-weak">':"")+o.names[n[r]]+(s?"</span>":"")+" / "}}q+=o.names[u];return q};g.layout.getExtendedLayout=function(s){var s=Ext.clone(s),u;u={columns:[],rows:[],filters:[],columnObjectNames:[],columnDimensionNames:[],rowObjectNames:[],rowDimensionNames:[],axisDimensions:[],axisObjectNames:[],axisDimensionNames:[],sortedAxisDimensionNames:[],filterDimensions:[],filterObjectNames:[],filterDimensionNames:[],sortedFilterDimensions:[],dimensions:[],objectNames:[],dimensionNames:[],objectNameDimensionsMap:{},objectNameItemsMap:{},objectNameIdsMap:{},dimensionNameDimensionsMap:{},dimensionNameItemsMap:{},dimensionNameIdsMap:{},dimensionNameSortedIdsMap:{},sortableIdObjects:[]};Ext.applyIf(u,s);if(s.columns){for(var q=0,r,t,n;q<s.columns.length;q++){r=s.columns[q];t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.columns.push(n);u.columnObjectNames.push(n.objectName);u.columnDimensionNames.push(n.dimensionName);u.axisDimensions.push(n);u.axisObjectNames.push(n.objectName);u.axisDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}if(s.rows){for(var q=0,r,t,n;q<s.rows.length;q++){r=Ext.clone(s.rows[q]);t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.rows.push(n);u.rowObjectNames.push(n.objectName);u.rowDimensionNames.push(n.dimensionName);u.axisDimensions.push(n);u.axisObjectNames.push(n.objectName);u.axisDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}if(s.filters){for(var q=0,r,t,n;q<s.filters.length;q++){r=s.filters[q];t=r.items;n={};n.dimension=r.dimension;n.objectName=r.dimension;n.dimensionName=l.objectNameMap[r.dimension].dimensionName;if(t){n.items=t;n.ids=[];for(var p=0;p<t.length;p++){n.ids.push(t[p].id)}}u.filters.push(n);u.filterDimensions.push(n);u.filterObjectNames.push(n.objectName);u.filterDimensionNames.push(l.objectNameMap[n.objectName].dimensionName);u.objectNameDimensionsMap[n.objectName]=n;u.objectNameItemsMap[n.objectName]=n.items;u.objectNameIdsMap[n.objectName]=n.ids}}u.legendSet=s.legendSet?m.idLegendSetMap[s.legendSet.id]:null;if(s.legendSet){u.legendSet=m.idLegendSetMap[s.legendSet.id];j.prototype.array.sort(u.legendSet.mapLegends,"ASC","startValue")}u.axisDimensionNames=Ext.Array.unique(u.axisDimensionNames);u.filterDimensionNames=Ext.Array.unique(u.filterDimensionNames);u.columnDimensionNames=Ext.Array.unique(u.columnDimensionNames);u.rowDimensionNames=Ext.Array.unique(u.rowDimensionNames);u.filterDimensionNames=Ext.Array.unique(u.filterDimensionNames);u.sortedAxisDimensionNames=Ext.clone(u.axisDimensionNames).sort();u.sortedFilterDimensions=g.layout.sortDimensionArray(Ext.clone(u.filterDimensions));u.dimensions=[].concat(u.axisDimensions,u.filterDimensions);u.objectNames=[].concat(u.axisObjectNames,u.filterObjectNames);u.dimensionNames=[].concat(u.axisDimensionNames,u.filterDimensionNames);for(var q=0,o;q<u.dimensionNames.length;q++){o=u.dimensionNames[q];u.dimensionNameDimensionsMap[o]=[];u.dimensionNameItemsMap[o]=[];u.dimensionNameIdsMap[o]=[]}for(var q=0,n;q<u.dimensions.length;q++){n=u.dimensions[q];u.dimensionNameDimensionsMap[n.dimensionName].push(n);u.dimensionNameItemsMap[n.dimensionName]=u.dimensionNameItemsMap[n.dimensionName].concat(n.items);u.dimensionNameIdsMap[n.dimensionName]=u.dimensionNameIdsMap[n.dimensionName].concat(n.ids)}for(var v in u.dimensionNameIdsMap){if(u.dimensionNameIdsMap.hasOwnProperty(v)){u.dimensionNameSortedIdsMap[v]=Ext.clone(u.dimensionNameIdsMap[v]).sort()}}u.tableUuid=m.el+"_"+Ext.data.IdGenerator.get("uuid").generate();return u};g.layout.getSyncronizedXLayout=function(o,n){var q,r,p=Ext.Array.clean([].concat(o.columns||[],o.rows||[],o.filters||[]));q=function(t){var s;s=function(v){var w;v=Ext.clone(v);for(var u=0;u<v.length;u++){if(v[u].dimension===t){w=v[u]}}if(w){Ext.Array.remove(v,w)}return v};if(o.columns){o.columns=s(o.columns)}if(o.rows){o.rows=s(o.rows)}if(o.filters){o.filters=s(o.filters)}};r=function(){var t=[];for(var s=0;s<n.headers.length;s++){t.push(n.headers[s].name)}return t};return function(){var t=r(),O=o.objectNameDimensionsMap[l.organisationUnit.objectName],z=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT"),Q=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT_CHILDREN"),N=O&&Ext.Array.contains(O.ids,"USER_ORGUNIT_GRANDCHILDREN"),s=function(){if(O&&Ext.isArray(O.ids)){for(var S=0;S<O.ids.length;S++){if(O.ids[S].substr(0,5)==="LEVEL"){return true}}}return false}(),B=function(){if(O&&Ext.isArray(O.ids)){for(var S=0;S<O.ids.length;S++){if(O.ids[S].substr(0,8)==="OU_GROUP"){return true}}}return false}(),y=l.category.objectName,v=l.organisationUnit.objectName,R;for(var J=0,H,A,C;J<p.length;J++){H=p[J];H.items=[];A=n.metaData[H.objectName];if(H.dimensionName===v){if(z||Q||N){var M,x,E;if(z){M=[{id:m.user.ou,name:g.layout.getItemName(o,n,m.user.ou,false)}]}if(Q){x=[];for(var G=0;G<m.user.ouc.length;G++){x.push({id:m.user.ouc[G],name:g.layout.getItemName(o,n,m.user.ouc[G],false)})}j.prototype.array.sort(x)}if(N){var u=[].concat(m.user.ou,m.user.ouc),w=n.metaData[v];E=[];for(var G=0,D;G<w.length;G++){D=w[G];if(!Ext.Array.contains(u,D)){E.push({id:D,name:g.layout.getItemName(o,n,D,false)})}}j.prototype.array.sort(E)}H.items=[].concat(M||[],x||[],E||[])}else{if(s||B){for(var G=0,w=n.metaData[v],D;G<w.length;G++){D=w[G];H.items.push({id:D,name:g.layout.getItemName(o,n,D,false)})}j.prototype.array.sort(H.items)}else{H.items=Ext.clone(o.dimensionNameItemsMap[H.dimensionName])}}}else{if(Ext.isArray(A)&&A.length){var F=Ext.clone(n.metaData[H.dimensionName]);for(var G=0;G<F.length;G++){H.items.push({id:F[G],name:n.metaData.names[F[G]]})}}else{H.items=Ext.clone(o.objectNameItemsMap[H.objectName])}}}for(var J=0,K;J<o.axisDimensionNames.length;J++){K=o.axisDimensionNames[J];if(!Ext.Array.contains(t,K)){q(K)}}R=k.layout.Layout(o);if(R){p=Ext.Array.clean([].concat(R.columns||[],R.rows||[],R.filters||[]));for(var J=0,I=n.metaData.names,L;J<p.length;J++){L=p[J].items;if(Ext.isArray(L)&&L.length){for(var G=0,P;G<L.length;G++){P=L[G];if(Ext.isObject(P)&&Ext.isString(I[P.id])&&!Ext.isString(P.name)){P.name=I[P.id]||""}}}}return g.layout.getExtendedLayout(R)}return null}()};g.layout.getExtendedAxis=function(z,L,Z){var t,r,A=[],y=1,I,q,E=[],Y=[],s=[],D=[],w=[],x=[],N=[],u={};if(Z==="col"){t=Ext.clone(z.columnDimensionNames);r="colSpan"}else{if(Z==="row"){t=Ext.clone(z.rowDimensionNames);r="rowSpan"}}if(!(Ext.isArray(t)&&t.length)){return}for(var U=0;U<t.length;U++){A.push({dimensionName:t[U]})}q=function(){var n=[];for(var aa=0;aa<A.length;aa++){n.push(L.nameHeaderMap[A[aa].dimensionName].ids)}return n}();I=q.length;for(var U=0,K;U<I;U++){K=q[U].length;E.push(K);y=y*K;Y.push(y)}for(var U=0;U<I;U++){if(E[U]===1){if(U===0){s.push(y)}else{if(z.hideEmptyRows&&Z==="row"){s.push(y/Y[U])}else{s.push(s[0])}}}else{s.push(y/Y[U])}}D.push(q[0]);if(I.length>1){for(var U=1,W,O;U<I;U++){W=[];O=E[U]===1?E[0]:Y[U-1];for(var S=0;S<O;S++){W=W.concat(q[U])}D.push(W)}}for(var U=0,v,P,B,T;U<I;U++){v=[];P=q[U];B=s[U];T=y/(B*P.length);for(var S=0;S<T;S++){for(var R=0;R<P.length;R++){for(var Q=0;Q<B;Q++){v.push(P[R])}}}w.push(v)}for(var U=0,H;U<y;U++){H="";for(var S=0;S<I;S++){H+=w[S][U]}if(H){x.push(H)}}for(var U=0,F;U<w.length;U++){F=[];for(var S=0,p;S<w[U].length;S++){p={id:w[U][S],uuid:Ext.data.IdGenerator.get("uuid").generate(),dim:U,axis:Z};if(U===w.length-1){p.leaf=true}F.push(p)}N.push(F)}for(var U=0;U<N.length;U++){for(var S=0,p,X=0,o;S<N[U].length;S++){p=N[U][S];if(X===0){p[r]=s[U];p.children=p.leaf?0:s[U];p.oldest=true;if(U===0){p.root=true}o=p}p.oldestSibling=o;if(++X===s[U]){X=0}}}if(I>1){for(var U=1,F;U<I;U++){F=N[U];for(var S=0,X=0,B=s[U-1];S<F.length;S++){F[S].parent=N[U-1][S]}}}if(N.length){var B=I>1?j.prototype.array.sort(Ext.clone(s))[1]:y,J=N[N.length-1];for(var U=0,V,C,p,G=[];U<J.length;U++){V=J[U];G.push(V.uuid);C=[];p=V;while(p.parent){p=p.parent;C.push(p.oldestSibling.uuid)}V.uuids=Ext.clone(C);if(G.length===B){for(var S=(U-B)+1,V;S<=U;S++){V=J[S];V.uuids=V.uuids.concat(Ext.clone(G))}G=[]}}}for(var U=0;U<N.length;U++){for(var S=0,M;S<N[U].length;S++){M=N[U][S];u[M.uuid]=M}}return{type:Z,items:A,xItems:{unique:q,gui:D,all:w},objects:{all:N},ids:x,span:s,dims:I,size:y,uuidObjectMap:u}};g.layout.isHierarchy=function(o,n,p){return o.showHierarchy&&Ext.isObject(n.metaData.ouHierarchy)&&n.metaData.ouHierarchy.hasOwnProperty(p)};g.layout.layout2plugin=function(r){var r=Ext.clone(r),q=Ext.Array.clean([].concat(r.columns||[],r.rows||[],r.filters||[]));if(Ext.isString(r.id)){return{id:r.id}}for(var o=0,s,p;o<q.length;o++){s=q[o];delete s.id;delete s.ids;delete s.type;delete s.dimensionName;delete s.objectName;for(var n=0,p;n<s.items.length;n++){p=s.items[n];delete p.name;delete p.code;delete p.created;delete p.lastUpdated}}if(r.showTotals){delete r.showTotals}if(r.showSubTotals){delete r.showSubTotals}if(!r.hideEmptyRows){delete r.hideEmptyRows}if(!r.showHierarchy){delete r.showHierarchy}if(r.displayDensity==="normal"){delete r.displayDensity}if(r.fontSize==="normal"){delete r.fontSize}if(r.digitGroupSeparator==="space"){delete r.digitGroupSeparator}if(!r.legendSet){delete r.legendSet}if(!r.sorting){delete r.sorting}delete r.parentGraphMap;delete r.reportingPeriod;delete r.organisationUnit;delete r.parentOrganisationUnit;delete r.regression;delete r.cumulative;delete r.sortOrder;delete r.topLimit;return r};g.response={};g.response.getExtendedResponse=function(o,n){var p=[];n.nameHeaderMap={};n.idValueMap={};(function(){for(var q=0,r;q<n.headers.length;q++){r=n.headers[q];r.index=q;if(r.meta){r.ids=Ext.clone(o.dimensionNameIdsMap[r.name])||[];r.size=r.ids.length;p=p.concat(r.ids)}}for(var q=0,r;q<n.headers.length;q++){r=n.headers[q];n.nameHeaderMap[r.name]=r}}());(function(){for(var q=0,s,r;q<p.length;q++){s=p[q];if(s.indexOf("-")!==-1){r=s.split("-");n.metaData.names[s]=n.metaData.names[r[0]]+" "+n.metaData.names[r[1]]}}}());(function(){var v=n.nameHeaderMap[i.finals.dimension.value.value].index,r=n.nameHeaderMap[i.finals.dimension.category.dimensionName],z=l.data.dimensionName,w=l.category.dimensionName,t=o.axisDimensionNames,x=[];for(var u=0;u<t.length;u++){x.push(n.nameHeaderMap[t[u]].index);if(r&&!Ext.Array.contains(t,w)&&t[u]===z){x.push(r.index)}}for(var u=0,y,q;u<n.rows.length;u++){y=n.rows[u];q="";for(var s=0;s<x.length;s++){q+=y[x[s]]}n.idValueMap[q]=y[v]}}());return n}}());(function(){h.mask={};h.mask.show=function(n,o){if(!Ext.isObject(n)){console.log("support.gui.mask.show: component not an object");return null}o=o||"Loading..";if(Ext.isObject(n.mask)&&n.mask.destroy){n.mask.destroy();n.mask=null}n.mask=new Ext.create("Ext.LoadMask",n,{shadow:false,message:o,style:"box-shadow:0",bodyStyle:"box-shadow:0"});n.mask.show()};h.mask.hide=function(n){if(!Ext.isObject(n)){console.log("support.gui.mask.hide: component not an object");return null}if(n.mask){n.mask.destroy();n.mask=null}};h.message={};h.message.alert=function(n){console.log(n)};h.analytics={};h.analytics.getParamString=function(A,q){var u=q?A.sortedAxisDimensionNames:A.axisDimensionNames,B=q?A.sortedFilterDimensions:A.filterDimensions,n=q?A.dimensionNameSortedIdsMap:A.dimensionNameIdsMap,r="?",p=false,o=A.dimensionNameItemsMap,C=l.indicator.dimensionName,z=l.category.dimensionName;for(var v=0,s,y;v<u.length;v++){s=u[v];r+="dimension="+s;y=Ext.clone(n[s]);if(s===C){for(var t=0,x;t<y.length;t++){x=y[t].indexOf("-");if(x>0){p=true;y[t]=y[t].substr(0,x)}}y=Ext.Array.unique(y)}if(s!==z){r+=":"+y.join(";")}if(v<(u.length-1)){r+="&"}}if(p){r+="&dimension="+i.finals.dimension.category.dimensionName}if(Ext.isArray(B)&&B.length){for(var v=0,w;v<B.length;v++){w=B[v];r+="&filter="+w.dimensionName+":"+w.ids.join(";")}}if(A.showHierarchy){r+="&hierarchyMeta=true"}return r};h.analytics.validateUrl=function(o){var p;if(Ext.isIE){p="Too many items selected (url has "+o.length+" characters). Internet Explorer accepts maximum 2048 characters."}else{var n=o.length>8000?"8000":(o.length>4000?"4000":"2000");p="Too many items selected (url has "+o.length+" characters). Please reduce to less than "+n+" characters."}p+="\n\nHint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.";alert(p)};h.pivot={};h.pivot.getHtml=function(C,p,I,B){var v,D,n,o,F,s,q,u,z,E,K,t=function(L){if(!L){return null}var M=L.xItems.unique;if(M){return M.length<2?1:(L.size/M[0].length)}return null},H=t(I),A=t(B),y=[],J=[],r=[],x={},w=Ext.isObject(C.legendSet)&&Ext.isArray(C.legendSet.mapLegends)&&C.legendSet.mapLegends.length,G;v=function(L,M){M=M||2;return parseFloat(j.prototype.number.roundIf(L,2)).toString()};D=function(O,X){var U,V,R,S,M,N,Z,L=Ext.isObject(O)&&Ext.isString(O.type)&&O.type.substr(0,5)==="value"&&!O.empty,T=Ext.isObject(O)&&Ext.isString(O.type)&&O.type==="value"&&!O.empty,Y="",Q="";if(!Ext.isObject(O)){return""}if(L&&C.legendSet){var W=parseFloat(O.value);V=C.legendSet.mapLegends;for(var P=0;P<V.length;P++){if(Ext.Number.constrain(W,V[P].startValue,V[P].endValue)===W){U=V[P].color}}}R=O.colSpan?'colspan="'+O.colSpan+'" ':"";S=O.rowSpan?'rowspan="'+O.rowSpan+'" ':"";M=O.collapsed?"":O.htmlValue||O.value||"";M=O.type!=="dimension"?j.prototype.number.prettyPrint(M,C.digitGroupSeparator):M;N=i.pivot.displayDensity[O.displayDensity]||i.pivot.displayDensity[C.displayDensity];Z=i.pivot.fontSize[O.fontSize]||i.pivot.fontSize[C.fontSize];Y+=O.hidden?" td-hidden":"";Y+=O.collapsed?" td-collapsed":"";Y+=T?" pointer":"";Y+=U?" legend":(O.cls?" "+O.cls:"");if(Ext.isString(X)){Y+=" td-sortable";C.sortableIdObjects.push({id:X,uuid:O.uuid})}Q+="<td "+(O.uuid?('id="'+O.uuid+'" '):"");Q+=' class="'+Y+'" '+R+S;if(U){Q+=">";Q+='<div class="legendCt">';Q+='<div class="number '+O.cls+'" style="padding:'+N+"; padding-right:3px; font-size:"+Z+'">'+M+"</div>";Q+='<div class="arrowCt '+O.cls+'">';Q+='<div class="arrow" style="border-bottom:8px solid transparent; border-right:8px solid '+U+'">&nbsp;</div>';Q+="</div></div></div></td>"}else{Q+='style="padding:'+N+"; font-size:"+Z+';">'+M+"</td>"}return Q};n=function(L){return !!C.showSubTotals&&L&&L.dims>1};o=function(){return !!C.showTotals};doSortableColumnHeaders=function(){return(B&&B.dims===1)};F=function(){var T=[],L;L=function(){return(I&&B)?D({cls:"pivot-dim-empty cursor-default",colSpan:B.dims,rowSpan:I.dims,htmlValue:"&nbsp;"}):""};if(!(I&&Ext.isObject(I))){return T}for(var Q=0,S;Q<I.dims;Q++){S=[];if(Q===0){S.push(L())}for(var O=0,P,M=0,R,N;O<I.size;O++){M++;P=I.objects.all[Q][O];P.type="dimension";P.cls="pivot-dim";P.noBreak=false;P.hidden=!(P.rowSpan||P.colSpan);P.htmlValue=g.layout.getItemName(C,p,P.id,true);if(Q===I.dims-1&&doSortableColumnHeaders()){R=I.ids[O].split("-").join("")}S.push(D(P,R));if(Q===0&&M===I.span[Q]&&n(I)){S.push(D({type:"dimensionSubtotal",cls:"pivot-dim-subtotal cursor-default",rowSpan:I.dims,htmlValue:"&nbsp;"}));M=0}if(Q===0&&(O===I.size-1)&&o()){N=doSortableColumnHeaders()?"total_":null;S.push(D({uuid:Ext.data.IdGenerator.get("uuid").generate(),type:"dimensionTotal",cls:"pivot-dim-total",rowSpan:I.dims,htmlValue:"Total"},N))}}T.push(S)}return T};s=function(){var aA=[],X=[],al,R=[],af=[],ab,ad=I?I.size:1,an=B?B.size:1,ae;ae=function(aB){if(!aB.children){aB.collapsed=true;if(aB.parent){aB.parent.oldestSibling.children--}}if(aB.parent){ae(aB.parent.oldestSibling)}};if(B){for(var aw=0,Z;aw<B.size;aw++){Z=[];for(var av=0,P,ap;av<B.dims;av++){P=B.objects.all[av][aw];P.type="dimension";P.cls="pivot-dim td-nobreak"+(g.layout.isHierarchy(C,p,P.id)?" align-left":"");P.noBreak=true;P.hidden=!(P.rowSpan||P.colSpan);P.htmlValue=g.layout.getItemName(C,p,P.id,true);Z.push(P)}X.push(Z)}}for(var aw=0,N,Q,at=Ext.clone(p.idValueMap);aw<an;aw++){N=[];Q=[];for(var av=0,aj,aq,ay,L,S,M;av<ad;av++){L=false;M=[];aj=(I?j.prototype.str.replaceAll(I.ids[av],"-",""):"")+(B?j.prototype.str.replaceAll(B.ids[aw],"-",""):"");S=Ext.data.IdGenerator.get("uuid").generate();if(I){M=M.concat(I.objects.all[I.dims-1][av].uuids)}if(B){M=M.concat(B.objects.all[B.dims-1][aw].uuids)}if(at[aj]){aq=parseFloat(at[aj]);ay=aq.toString()}else{aq=0;ay="&nbsp;";L=true}N.push(aq);Q.push({uuid:S,type:"value",cls:"pivot-value"+(L?" cursor-default":""),value:aq,htmlValue:ay,empty:L,uuids:M});x[S]=M}y.push(N);J.push(Q)}if(I&&o()){for(var aw=0,L=[],ai=0;aw<J.length;aw++){for(av=0,P;av<J[aw].length;av++){P=J[aw][av];L.push(P.empty);ai+=P.value}R.push({type:"valueTotal",cls:"pivot-value-total",value:ai,htmlValue:Ext.Array.contains(L,false)?v(ai):"",empty:!Ext.Array.contains(L,false)});if(doSortableColumnHeaders()){var W="total_"+B.ids[aw],aa=!Ext.Array.contains(L,false);p.idValueMap[W]=aa?null:ai}L=[];ai=0}}if(I&&B){if(C.hideEmptyRows){for(var aw=0,am,O,ac;aw<J.length;aw++){am=J[aw];O=!Ext.Array.contains(Ext.Array.pluck(am,"empty"),false);if(O){for(var av=0;av<am.length;av++){am[av].collapsed=true}if(o()){R[aw].collapsed=true}ac=X[aw][B.dims-1];ae(ac)}}}}al=Ext.clone(J);if(n(I)){var ag=[];for(var aw=0,Z,V,Y;aw<al.length;aw++){Z=[];V=0;Y=0;for(var av=0,ah,az=[],L=[];av<al[aw].length;av++){ah=al[aw][av];V+=ah.value;L.push(!!ah.empty);az.push(!!ah.collapsed);Y++;Z.push(ah);if(Y===H){var aa=!Ext.Array.contains(L,false);Z.push({type:"valueSubtotal",cls:"pivot-value-subtotal"+(aa?" cursor-default":""),value:V,htmlValue:aa?"&nbsp;":v(V),empty:aa,collapsed:!Ext.Array.contains(az,false)});Y=0;V=0;L=[];az=[]}}ag.push(Z)}al=ag}if(n(B)){var ak=[],ag=[],ax=[],au;au=function(aE){var aD=[];for(var aB=0,aC;aB<B.dims;aB++){aC={};aC.type="dimensionSubtotal";aC.cls="pivot-dim-subtotal cursor-default";aC.collapsed=Ext.Array.contains(aE,true);if(aB===0){aC.htmlValue="&nbsp;";aC.colSpan=B.dims}else{aC.hidden=true}aD.push(aC)}return aD};for(var aw=0,Z,az=[];aw<X.length;aw++){ak.push(X[aw]);az.push(!!X[aw][0].collapsed);if(!Ext.isArray(X[aw+1])||!!X[aw+1][0].root){ak.push(au(az));az=[]}}for(var aw=0;aw<ak.length;aw++){ag.push([])}for(var aw=0;aw<al[0].length;aw++){for(var av=0,T=0,ao=0,U=0,L=[],az,ah;av<al.length;av++){ah=al[av][aw];ag[ao++].push(ah);U+=ah.value;L.push(!!ah.empty);T++;if(X[av][0].root){az=!!X[av][0].collapsed}if(!Ext.isArray(X[av+1])||X[av+1][0].root){var aa=!Ext.Array.contains(L,false);ag[ao++].push({type:ah.type==="value"?"valueSubtotal":"valueSubtotalTotal",value:U,htmlValue:aa?"&nbsp;":v(U),collapsed:az,cls:(ah.type==="value"?"pivot-value-subtotal":"pivot-value-subtotal-total")+(aa?" cursor-default":"")});T=0;U=0;L=[]}}}for(var aw=0,P,az=[],L=[],U=0,ar=0;aw<R.length;aw++){P=R[aw];ax.push(P);az.push(!!P.collapsed);L.push(!!P.empty);U+=P.value;ar++;if(ar===B.span[0]){var aa=!Ext.Array.contains(L,false);ax.push({type:"valueTotalSubgrandtotal",cls:"pivot-value-total-subgrandtotal"+(aa?" cursor-default":""),value:U,htmlValue:aa?"&nbsp;":v(U),empty:aa,collapsed:!Ext.Array.contains(az,false)});az=[];L=[];U=0;ar=0}}X=ak;al=ag;R=ax}for(var aw=0,Z;aw<al.length;aw++){Z=[];if(B){Z=Z.concat(X[aw])}Z=Z.concat(al[aw]);if(I){Z=Z.concat(R[aw])}af.push(Z)}for(var aw=0,Z;aw<af.length;aw++){Z=[];for(var av=0;av<af[aw].length;av++){Z.push(D(af[aw][av]))}aA.push(Z)}return aA};u=function(){var S=[];if(B&&o()){var V;for(var N=0,R=0,Q=[];N<J[0].length;N++){for(var L=0,M;L<J.length;L++){M=J[L][N];R+=M.value;Q.push(!!M.empty)}r.push({type:"valueTotal",value:R,htmlValue:Ext.Array.contains(Q,false)?v(R):"",empty:!Ext.Array.contains(Q,false),cls:"pivot-value-total"});R=0;Q=[]}V=Ext.clone(r);if(I&&n(I)){var O=[];for(var N=0,U,P=0,Q=[],T=0;N<V.length;N++){U=V[N];O.push(U);P+=U.value;Q.push(!!U.empty);T++;if(T===H){O.push({type:"valueTotalSubgrandtotal",value:P,htmlValue:Ext.Array.contains(Q,false)?v(P):"",empty:!Ext.Array.contains(Q,false),cls:"pivot-value-total-subgrandtotal"});P=0;T=0}}V=O}for(var N=0;N<V.length;N++){S.push(D(V[N]))}}return S};z=function(){var N=0,O=[],L=[];if(o()){for(var M=0,P;M<r.length;M++){P=r[M];N+=P.value;O.push(P.empty)}if(I&&B){L.push(D({type:"valueGrandTotal",cls:"pivot-value-grandtotal",value:N,htmlValue:Ext.Array.contains(O,false)?v(N):"",empty:!Ext.Array.contains(O,false)}))}}return L};E=function(){var N,M=u(),O=z(),P,L=[];if(o()){if(B){N=[D({type:"dimensionSubtotal",cls:"pivot-dim-total",colSpan:B.dims,htmlValue:"Total"})]}P=[].concat(N||[],Ext.clone(M)||[],Ext.clone(O)||[]);L.push(P)}return L};K=function(){var M='<table id="'+C.tableUuid+'" class="pivot">';for(var L=0;L<G.length;L++){M+="<tr>"+G[L].join("")+"</tr>"}return M+="</table>"};return function(){G=Ext.Array.clean([].concat(F()||[],s()||[],E()||[]));return{html:K(G),uuidDimUuidsMap:x}}()}}());(function(){if(Ext.isArray(m.dimensions)){j.prototype.array.sort(m.dimensions);for(var n=0,o;n<m.dimensions.length;n++){o=m.dimensions[n];o.dimensionName=o.id;o.objectName=i.finals.dimension.dimension.objectName;i.finals.dimension.objectNameMap[o.id]=o}}j.prototype.array.sort(m.user.ouc);m.idLegendSetMap={};for(var n=0,p;n<m.legendSets.length;n++){p=m.legendSets[n];m.idLegendSetMap[p.id]=p}}());return{conf:i,api:k,support:j,service:g,web:h,init:m}};css="table.pivot { \n font-family: arial,sans-serif,ubuntu,consolas; \n } \n";css+=".td-nobreak { \n white-space: nowrap; \n } \n";css+=".td-hidden { \n display: none; \n } \n";css+=".td-collapsed { \n display: none; \n } \n";css+="table.pivot { \n border-collapse: collapse; \n border-spacing: 0px; \n border: 0 none; \n } \n";css+=".pivot td { \n padding: 5px; \n border: \n 1px solid #b2b2b2; \n } \n";css+=".pivot-dim { \n background-color: #dae6f8; \n text-align: center; \n } \n";css+=".pivot-dim.highlighted { \n	background-color: #c5d8f6; \n } \n";css+=".pivot-dim-subtotal { \n background-color: #cad6e8; \n text-align: center; \n } \n";css+=".pivot-dim-total { \n background-color: #bac6d8; \n text-align: center; \n } \n";css+=".pivot-dim-total.highlighted { \n background-color: #adb8c9; \n } \n";css+=".pivot-dim-empty { \n background-color: #dae6f8; \n text-align: center; \n } \n";css+=".pivot-value { \n background-color: #fff; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-subtotal { \n background-color: #f4f4f4; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-subtotal-total { \n background-color: #e7e7e7; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-total { \n background-color: #e4e4e4; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-total-subgrandtotal { \n background-color: #d8d8d8; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".pivot-value-grandtotal { \n background-color: #c8c8c8; \n white-space: nowrap; \n text-align: right; \n } \n";css+=".x-mask-msg { \n padding: 0; \n	border: 0 none; \n background-image: none; \n background-color: transparent; \n } \n";css+=".x-mask-msg div { \n background-position: 11px center; \n } \n";css+=".x-mask-msg .x-mask-loading { \n border: 0 none; \n	background-color: #000; \n color: #fff; \n border-radius: 2px; \n padding: 12px 14px 12px 30px; \n opacity: 0.65; \n } \n";css+=".pivot td.legend { \n padding: 0; \n } \n";css+=".pivot div.legendCt { \n display: table; \n float: right; \n width: 100%; \n } \n";css+=".pivot div.arrowCt { \n display: table-cell; \n vertical-align: top; \n width: 8px; \n } \n";css+=".pivot div.arrow { \n width: 0; \n height: 0; \n } \n";css+=".pivot div.number { \n display: table-cell; \n } \n",css+=".pivot div.legendColor { \n display: table-cell; \n width: 2px; \n } \n";css+=".pointer { \n cursor: pointer; \n } \n";css+='.td-sortable { \n background-image: url("http://dhis2-cdn.org/v214/plugin/images/arrowupdown.png";); \n background-repeat: no-repeat; \n background-position: right center; \n padding-right: 15px !important; \n } \n';Ext.util.CSS.createStyleSheet(css);PT.plugin={};var e={user:{}},d=[],f=false,b=false,a,c;a=function(g){var m=false,l=[],k=0,j;j=function(){if(++k===l.length){b=true;for(var n=0;n<d.length;n++){c(d[n])}d=[]}};l.push({url:g+"/api/system/context.jsonp",success:function(i){e.contextPath=i.contextPath;j()}});l.push({url:g+"/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&links=false",success:function(n){var i=n.organisationUnits[0];e.user.ou=i.id;e.user.ouc=Ext.Array.pluck(i.children,"id");j()}});l.push({url:g+"/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false",success:function(i){e.legendSets=i.mapLegendSets;j()}});l.push({url:g+"/api/dimensions.jsonp?links=false&paging=false",success:function(i){e.dimensions=i.dimensions;j()}});for(var h=0;h<l.length;h++){Ext.data.JsonP.request(l[h])}};c=function(j){var l,i,h,g,k={core:{},app:{}};l=function(m){if(!Ext.isObject(m)){console.log("Report table configuration is not an object");return}if(!Ext.isString(m.el)){console.log("No valid element id provided");return}m.id=m.id||m.uid;return true};i=function(q){var r=k.core.init,p=k.core.api,o=k.core.support,m=k.core.service,n=k.core.web;n.events=n.events||{};n.events.setColumnHeaderMouseHandlers=function(t,s){if(Ext.isArray(t.sortableIdObjects)){for(var u=0,w,v;u<t.sortableIdObjects.length;u++){w=t.sortableIdObjects[u];v=Ext.get(w.uuid);v.dom.xLayout=t;v.dom.response=s;v.dom.metaDataId=w.id;v.dom.onColumnHeaderMouseClick=n.events.onColumnHeaderMouseClick;v.dom.onColumnHeaderMouseOver=n.events.onColumnHeaderMouseOver;v.dom.onColumnHeaderMouseOut=n.events.onColumnHeaderMouseOut;v.dom.setAttribute("onclick","this.onColumnHeaderMouseClick(this.xLayout, this.response, this.metaDataId)");v.dom.setAttribute("onmouseover","this.onColumnHeaderMouseOver(this)");v.dom.setAttribute("onmouseout","this.onColumnHeaderMouseOut(this)")}}};n.events.onColumnHeaderMouseClick=function(t,s,u){if(t.sorting&&t.sorting.id===u){t.sorting.direction=o.prototype.str.toggleDirection(t.sorting.direction)}else{t.sorting={id:u,direction:"DESC"}}k.core.web.pivot.sort(t,s,u)};n.events.onColumnHeaderMouseOver=function(s){Ext.get(s).addCls("pointer highlighted")};n.events.onColumnHeaderMouseOut=function(s){Ext.get(s).removeCls("pointer highlighted")};n.pivot=n.pivot||{};n.pivot.loadTable=function(s){if(!Ext.isString(s)){alert("Invalid report table id");return}Ext.data.JsonP.request({url:r.contextPath+"/api/reportTables/"+s+".jsonp?viewClass=dimensional&links=false",failure:function(t){window.open(r.contextPath+"/api/reportTables/"+s+".json?viewClass=dimensional&links=false","_blank")},success:function(u){var t=p.layout.Layout(u);if(t){n.pivot.getData(t,true)}}})};n.pivot.getData=function(t,u){var s,v;if(!t){return}s=m.layout.getExtendedLayout(t);v=n.analytics.getParamString(s,true);n.mask.show(k.app.centerRegion);Ext.data.JsonP.request({url:r.contextPath+"/api/analytics.jsonp"+v,timeout:60000,headers:{"Content-Type":"application/json",Accepts:"application/json"},disableCaching:false,failure:function(w){n.mask.hide(k.app.centerRegion);window.open(r.contextPath+"/api/analytics.json"+v,"_blank")},success:function(x){var w=p.response.Response(x);if(!w){n.mask.hide(k.app.centerRegion);return}s=m.layout.getSyncronizedXLayout(s,w);if(!s){n.mask.hide(k.app.centerRegion);return}k.app.paramString=v;n.pivot.createTable(t,s,w,u)}})};n.pivot.createTable=function(x,u,t,y){var z,w,s,v;if(!u){u=m.layout.getExtendedLayout(x)}z=m.response.getExtendedResponse(u,t);w=m.layout.getExtendedAxis(u,z,"col");s=m.layout.getExtendedAxis(u,z,"row");v=n.pivot.getHtml(u,z,w,s);k.app.centerRegion.update(v.html);k.app.layout=x;k.app.xLayout=u;k.app.response=t;k.app.xResponse=z;k.app.uuidDimUuidsMap=v.uuidDimUuidsMap;k.app.uuidObjectMap=Ext.applyIf((w?w.uuidObjectMap:{}),(s?s.uuidObjectMap:{}));n.events.setColumnHeaderMouseHandlers(u,t);n.mask.hide(k.app.centerRegion)};n.pivot.sort=function(y,u,s){var y=Ext.clone(y),u=Ext.clone(u),w=y.rows[0],t=u.idValueMap,z=y.sorting?y.sorting.direction:"DESC",x;w.ids=[];for(var v=0,C,B,A;v<w.items.length;v++){C=w.items[v];B=s+C.id;A=parseFloat(t[B]);C.value=Ext.isNumber(A)?A:(Number.MAX_VALUE*-1)}o.prototype.array.sort(w.items,z,"value");for(var v=0;v<w.items.length;v++){w.ids.push(w.items[v].id)}x=p.layout.Layout(y);n.pivot.createTable(x,null,u,false)}};h=function(){return{centerRegion:Ext.get(j.el)}};g=function(){if(!l(j)){return}k.core=PT.getCore(Ext.clone(e));i(k);k.app.viewport=h();k.app.centerRegion=k.app.viewport.centerRegion;if(j.id){k.core.web.pivot.loadTable(j.id)}else{layout=k.core.api.layout.Layout(j);if(!layout){return}k.core.web.pivot.getData(layout)}}()};PT.plugin.getTable=function(g){if(Ext.isString(g.url)&&g.url.split("").pop()==="/"){g.url=g.url.substr(0,g.url.length-1)}if(b){c(g)}else{d.push(g);if(!f){f=true;a(g.url)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getTable=PT.plugin.getTable});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2014-01-13 16:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2014-02-08 18:09:18 +0000
@@ -14,7 +14,7 @@
 <div class="setting settingIndent">
 <select id="resourceTableStrategy" name="resourceTableStrategy" class="scheduling">
 	<option value="never">$i18n.getString( "never" )</option>
-	<option value="allDaily"#if( $resourceTableStrategy && $resourceTableStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "all_daily" )</option>
+	<option value="allDaily"#if( $resourceTableStrategy && $resourceTableStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "all_daily" )</option>
 </select>
 </div>
 
@@ -47,15 +47,16 @@
 </div>
 
 <div class="settingLabel settingIndent">$i18n.getString( "aggregation_period_types" )</div>
-
+
 <div class="setting settingIndent">
     <input type="checkbox" id="weekly" class="scheduling dataMart" name="scheduledPeriodTypes" value="Weekly"#if( $scheduledPeriodTypes.contains( "Weekly" ) ) checked="checked"#end> <label for="weekly">$i18n.getString( "Weekly" )</label>&nbsp;
     <input type="checkbox" id="monthly" class="scheduling dataMart" name="scheduledPeriodTypes" value="Monthly"#if( $scheduledPeriodTypes.contains( "Monthly" ) ) checked="checked"#end> <label for="monthly">$i18n.getString( "Monthly" )</label>&nbsp;
     <input type="checkbox" id="biMonthly" class="scheduling dataMart" name="scheduledPeriodTypes" value="BiMonthly"#if( $scheduledPeriodTypes.contains( "BiMonthly" ) ) checked="checked"#end> <label for="biMonthly">$i18n.getString( "BiMonthly" )</label>&nbsp;
     <input type="checkbox" id="quarterly" class="scheduling dataMart" name="scheduledPeriodTypes" value="Quarterly"#if( $scheduledPeriodTypes.contains( "Quarterly" ) ) checked="checked"#end> <label for="quarterly">$i18n.getString( "Quarterly" )</label><br>
     <input type="checkbox" id="sixMonthly" class="scheduling dataMart" name="scheduledPeriodTypes" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end> <label for="sixMonthly">$i18n.getString( "SixMonthly" )</label>&nbsp;
+    <input type="checkbox" id="sixMonthlyApril" class="scheduling dataMart" name="scheduledPeriodTypes" value="SixMonthlyApril"#if( $scheduledPeriodTypes.contains( "SixMonthlyApril" ) ) checked="checked"#end> <label for="sixMonthlyApril">$i18n.getString( "SixMonthlyApril" )</label>&nbsp;
     <input type="checkbox" id="yearly" class="scheduling dataMart" name="scheduledPeriodTypes" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end> <label for="yearly">$i18n.getString( "Yearly" )</label>&nbsp;
-    <input type="checkbox" id="financialYearly" class="scheduling dataMart" name="scheduledPeriodTypes" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end> <label for="financialYearly">$i18n.getString( "financial_yearly" )</label>			
+    <input type="checkbox" id="financialYearly" class="scheduling dataMart" name="scheduledPeriodTypes" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end> <label for="financialYearly">$i18n.getString( "financial_yearly" )</label>			
 </div>
 
 <div class="settingLabel settingIndent">$i18n.getString( "organisation_unit_group_set_aggregation_level" )</div>
@@ -64,8 +65,8 @@
 <select id="orgUnitGroupSetAggLevel" name="orgUnitGroupSetAggLevel" class="scheduling dataMart">
     <option value="0"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == 0 ) selected="selected"#end>[$i18n.getString( "no_aggregation" )]</option>
 	#foreach( $level in $levels )
-	<option value="$level.level"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == $level.level ) selected="selected"#end>$encoder.htmlEncode( $level.displayName )</option>
-	#end
+	<option value="$level.level"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == $level.level ) selected="selected"#end>$encoder.htmlEncode( $level.displayName )</option>
+	#end
 </select>
 </div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2014-01-30 14:43:05 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2014-02-08 18:09:18 +0000
@@ -395,6 +395,7 @@
 bimonthly=Bi-monthly
 quarterly=Quarterly
 sixmonthly=Six-monthly
+sixmonthly_april=Six-monthly April
 yearly=Yearly
 financial_oct=Financial October
 financial_july=Financial July

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/i18n.json	2014-01-30 16:34:39 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/i18n.json	2014-02-08 18:09:18 +0000
@@ -419,6 +419,7 @@
 "bimonthly",
 "quarterly",
 "sixmonthly",
+"sixmonthly_april",
 "yearly",
 "financial_oct",
 "financial_july",

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-02-05 12:56:09 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-02-08 18:09:18 +0000
@@ -2240,7 +2240,8 @@
 					{id: 'Monthly', name: GIS.i18n.monthly},
 					{id: 'BiMonthly', name: GIS.i18n.bimonthly},
 					{id: 'Quarterly', name: GIS.i18n.quarterly},
-					{id: 'SixMonthly', name: GIS.i18n.sixmonthly},
+                    {id: 'SixMonthly', name: GIS.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: GIS.i18n.sixmonthly_april},
 					{id: 'Yearly', name: GIS.i18n.yearly},
 					{id: 'FinancialOct', name: GIS.i18n.financial_oct},
 					{id: 'FinancialJuly', name: GIS.i18n.financial_july},

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js	2014-01-30 14:58:19 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js	2014-02-08 18:09:18 +0000
@@ -2604,6 +2604,7 @@
 					{id: 'BiMonthly', name: GIS.i18n.bimonthly},
 					{id: 'Quarterly', name: GIS.i18n.quarterly},
 					{id: 'SixMonthly', name: GIS.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: GIS.i18n.sixmonthly_april},
 					{id: 'Yearly', name: GIS.i18n.yearly},
 					{id: 'FinancialOct', name: GIS.i18n.financial_oct},
 					{id: 'FinancialJuly', name: GIS.i18n.financial_july},

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2013-11-06 19:01:46 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2014-02-08 18:09:18 +0000
@@ -419,6 +419,7 @@
 "bimonthly": "$encoder.jsEscape($i18n.getString( 'bimonthly' ) , "'")",
 "quarterly": "$encoder.jsEscape($i18n.getString( 'quarterly' ) , "'")",
 "sixmonthly": "$encoder.jsEscape($i18n.getString( 'sixmonthly' ) , "'")",
+"sixmonthly_april": "$encoder.jsEscape($i18n.getString( 'sixmonthly_april' ) , "'")",
 "yearly": "$encoder.jsEscape($i18n.getString( 'yearly' ) , "'")",
 "financial_oct": "$encoder.jsEscape($i18n.getString( 'financial_oct' ) , "'")",
 "financial_july": "$encoder.jsEscape($i18n.getString( 'financial_july' ) , "'")",

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties	2014-01-29 11:02:07 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties	2014-02-08 18:09:18 +0000
@@ -140,6 +140,7 @@
 bimonthly=Bi-monthly
 quarterly=Quarterly
 sixmonthly=Six-monthly
+sixmonthly_april=Six-monthly April
 yearly=Yearly
 financial_oct=Financial October
 financial_july=Financial July

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json	2014-01-29 11:02:07 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json	2014-02-08 18:09:18 +0000
@@ -141,6 +141,7 @@
 "bimonthly",
 "quarterly",
 "sixmonthly",
+"sixmonthly_april",
 "yearly",
 "financial_oct",
 "financial_july",

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2014-01-29 11:02:07 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2014-02-08 18:09:18 +0000
@@ -118,6 +118,7 @@
 					{id: 'BiMonthly', name: NS.i18n.bimonthly},
 					{id: 'Quarterly', name: NS.i18n.quarterly},
 					{id: 'SixMonthly', name: NS.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: NS.i18n.sixmonthly_april},
 					{id: 'Yearly', name: NS.i18n.yearly},
 					{id: 'FinancialOct', name: NS.i18n.financial_oct},
 					{id: 'FinancialJuly', name: NS.i18n.financial_july},

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js	2014-01-02 18:14:38 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js	2014-02-08 18:09:18 +0000
@@ -118,7 +118,8 @@
 					{id: 'Monthly', name: PT.i18n.monthly},
 					{id: 'BiMonthly', name: PT.i18n.bimonthly},
 					{id: 'Quarterly', name: PT.i18n.quarterly},
-					{id: 'SixMonthly', name: PT.i18n.sixmonthly},
+                    {id: 'SixMonthly', name: PT.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: PT.i18n.sixmonthly_april},
 					{id: 'Yearly', name: PT.i18n.yearly},
 					{id: 'FinancialOct', name: PT.i18n.financial_oct},
 					{id: 'FinancialJuly', name: PT.i18n.financial_july},

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm	2014-01-13 16:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm	2014-02-08 18:09:18 +0000
@@ -7,7 +7,7 @@
 
 <div class="setting settingIndent">
 	<input type="checkbox" id="analytics" checked="checked" />
-    <label for="analytics">$i18n.getString( "analytics_tables_update" )</label>
+    <label for="analytics">$i18n.getString( "analytics_tables_update" )</label>
 </div>
 
 <!-- Data mart -->
@@ -27,6 +27,7 @@
 <input type="checkbox" id="biMonthly" class="dataMart" name="periodTypes" value="BiMonthly"> <label for="biMonthly">$i18n.getString( "BiMonthly" )</label>&nbsp;
 <input type="checkbox" id="quarterly" class="dataMart" name="periodTypes" value="Quarterly" checked="checked"> <label for="quarterly">$i18n.getString( "Quarterly" )</label><br>
 <input type="checkbox" id="sixMonthly" class="dataMart" name="periodTypes" value="SixMonthly" checked="checked"> <label for="sixMonthly">$i18n.getString( "SixMonthly" )</label>&nbsp;
+<input type="checkbox" id="sixMonthlyApril" class="dataMart" name="periodTypes" value="SixMonthlyApril" checked="checked"> <label for="sixMonthlyApril">$i18n.getString( "SixMonthlyApril" )</label>&nbsp;
 <input type="checkbox" id="yearly" class="dataMart" name="periodTypes" value="Yearly" checked="checked"> <label for="yearly">$i18n.getString( "Yearly" )</label>&nbsp;
 <input type="checkbox" id="financialYearly" class="dataMart" name="periodTypes" value="FinancialJuly"> <label for="financialYearly">$i18n.getString( "financial_yearly" )</label>
 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2013-11-27 13:16:08 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2014-02-08 18:09:18 +0000
@@ -208,6 +208,7 @@
 bimonthly=Bi-monthly
 quarterly=Quarterly
 sixmonthly=Six-monthly
+sixmonthly_april=Six-monthly April
 yearly=Yearly
 financial_oct=Financial October
 financial_july=Financial July

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json	2013-11-27 13:16:08 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json	2014-02-08 18:09:18 +0000
@@ -208,6 +208,7 @@
 "bimonthly",
 "quarterly",
 "sixmonthly",
+"sixmonthly_april",
 "yearly",
 "financial_oct",
 "financial_july",

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-01-29 16:12:38 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-02-08 18:09:18 +0000
@@ -152,6 +152,7 @@
 					{id: 'BiMonthly', name: NS.i18n.bimonthly},
 					{id: 'Quarterly', name: NS.i18n.quarterly},
 					{id: 'SixMonthly', name: NS.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: NS.i18n.sixmonthly_april},
 					{id: 'Yearly', name: NS.i18n.yearly},
 					{id: 'FinancialOct', name: NS.i18n.financial_oct},
 					{id: 'FinancialJuly', name: NS.i18n.financial_july},

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js	2014-01-02 19:18:40 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js	2014-02-08 18:09:18 +0000
@@ -209,6 +209,7 @@
 					{id: 'BiMonthly', name: DV.i18n.bimonthly},
 					{id: 'Quarterly', name: DV.i18n.quarterly},
 					{id: 'SixMonthly', name: DV.i18n.sixmonthly},
+                    {id: 'SixMonthlyApril', name: DV.i18n.sixmonthly_april},
 					{id: 'Yearly', name: DV.i18n.yearly},
 					{id: 'FinancialOct', name: DV.i18n.financial_oct},
 					{id: 'FinancialJuly', name: DV.i18n.financial_july},