dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03767
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1250: generate excel report organisation group listing with organisation unit at selected level
------------------------------------------------------------
revno: 1250
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Sat 2009-12-19 14:02:53 +0700
message:
generate excel report organisation group listing with organisation unit at selected level
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/ListOrganisationUnitGroupAtLevelAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/UpdateOrganisationUnitGroupAtLevelAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/images/organisationunitlevel.png
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/organisationUnitAtLevels.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/ListOrganisationUnitGroupAtLevelAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/ListOrganisationUnitGroupAtLevelAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/ListOrganisationUnitGroupAtLevelAction.java 2009-12-19 07:02:53 +0000
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+package org.hisp.dhis.reportexcel.organisationunitgrouplisting.action;
+
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.reportexcel.ReportExcelOganiztionGroupListing;
+import org.hisp.dhis.reportexcel.ReportExcelService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ * @version $Id$
+ */
+public class ListOrganisationUnitGroupAtLevelAction
+ implements Action
+{
+
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private ReportExcelService reportService;
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------
+ // Input & Output
+ // -------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private Map<OrganisationUnitGroup, OrganisationUnitLevel> organisationUnitGroupAtLevel;
+
+ public Map<OrganisationUnitGroup, OrganisationUnitLevel> getOrganisationUnitGroupAtLevel()
+ {
+ return organisationUnitGroupAtLevel;
+ }
+
+ private List<OrganisationUnitGroup> availableOrganisationUnitGroups;
+
+ public List<OrganisationUnitGroup> getAvailableOrganisationUnitGroups()
+ {
+ return availableOrganisationUnitGroups;
+ }
+
+ private List<OrganisationUnitLevel> organisationUnitLevel;
+
+ public List<OrganisationUnitLevel> getOrganisationUnitLevel()
+ {
+ return organisationUnitLevel;
+ }
+
+ private ReportExcelOganiztionGroupListing reportExcel;
+
+ public ReportExcelOganiztionGroupListing getReportExcel()
+ {
+ return reportExcel;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ organisationUnitLevel = organisationUnitService.getOrganisationUnitLevels();
+
+ reportExcel = (ReportExcelOganiztionGroupListing) reportService.getReportExcel( id );
+
+ availableOrganisationUnitGroups = reportExcel.getOrganisationUnitGroups();
+
+ organisationUnitGroupAtLevel = reportExcel.getOrganisationUnitLevels();
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/UpdateOrganisationUnitGroupAtLevelAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/UpdateOrganisationUnitGroupAtLevelAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/organisationunitgrouplisting/action/UpdateOrganisationUnitGroupAtLevelAction.java 2009-12-19 07:02:53 +0000
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+package org.hisp.dhis.reportexcel.organisationunitgrouplisting.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.reportexcel.ReportExcelOganiztionGroupListing;
+import org.hisp.dhis.reportexcel.ReportExcelService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ * @version $Id$
+ */
+public class UpdateOrganisationUnitGroupAtLevelAction
+ implements Action
+{
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private ReportExcelService reportService;
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
+ // -------------------------------------------
+ // Input & Output
+ // -------------------------------------------
+
+ private Integer reportId;
+
+ public void setReportId( Integer reportId )
+ {
+ this.reportId = reportId;
+ }
+
+ private Integer orgUnitGroupId;
+
+ public void setOrgUnitGroupId( Integer orgUnitGroupId )
+ {
+ this.orgUnitGroupId = orgUnitGroupId;
+ }
+
+ private Integer levelId;
+
+ public void setLevelId( Integer levelId )
+ {
+ this.levelId = levelId;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ ReportExcelOganiztionGroupListing reportExcel = (ReportExcelOganiztionGroupListing) reportService
+ .getReportExcel( reportId );
+
+ Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels = new HashMap<OrganisationUnitGroup, OrganisationUnitLevel>(
+ reportExcel.getOrganisationUnitLevels() );
+
+ OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService
+ .getOrganisationUnitGroup( orgUnitGroupId );
+
+ if ( levelId != null )
+ {
+ OrganisationUnitLevel organisationUnitLevel = organisationUnitService.getOrganisationUnitLevel( levelId );
+
+ orgUniGroupAtLevels.put( organisationUnitGroup, organisationUnitLevel );
+
+ }else{
+
+ orgUniGroupAtLevels.remove( organisationUnitGroup );
+
+ }
+
+ reportExcel.setOrganisationUnitLevels( orgUniGroupAtLevels );
+
+ reportService.updateReportExcel( reportExcel );
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/images/organisationunitlevel.png'
Binary files dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/images/organisationunitlevel.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/images/organisationunitlevel.png 2009-12-19 07:02:53 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/organisationUnitAtLevels.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/organisationUnitAtLevels.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/organisationUnitAtLevels.vm 2009-12-19 07:02:53 +0000
@@ -0,0 +1,59 @@
+<h2>$encoder.htmlEncode($reportExcel.name)</h2>
+<hr>
+
+<table width=100%>
+ <thead>
+ <tr>
+ <td colspan=2>
+ $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:300px"/>
+ </td>
+ </tr>
+ <tr>
+ <th>$i18n.getString( "name" )</th>
+ <th width="200px;">$i18n.getString( "levels" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #set( $mark = false )
+ #set( $selected = false )
+ #foreach( $orgUnitGroup in $availableOrganisationUnitGroups)
+
+ <tr #alternate( $mark )>
+ <td>
+ $encoder.htmlEncode($orgUnitGroup.name)
+ </td>
+ <td>
+ <select id="selectedLevel" onchange="updateOrganisationUnitGroupAtLevel($reportExcel.id, $orgUnitGroup.id, this)" >
+ <option #if(!$organisationUnitGroupAtLevel.get($orgUnitGroup)) selected=true #end>$i18n.getString( "default" )</option>
+ #foreach( $level in $organisationUnitLevel)
+ <option value="$level.id" #if($organisationUnitGroupAtLevel.get($orgUnitGroup)==$level) selected=true #end>$encoder.htmlEncode($level.name)</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ #if( $mark )
+ #set( $mark = false )
+ #else
+ #set( $mark = true )
+ #end
+ #end
+ </tbody>
+</table>
+
+
+<script>
+ function updateOrganisationUnitGroupAtLevel(reportId, orgUnitGroupId, select){
+ select.style.backgroundColor = "#FFFFFF";
+ var request = new Request();
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( function (message){
+ select.style.backgroundColor = "#D5FFC5";
+ });
+ request.send( "updateOrganisationUnitGroupAtLevel.action?reportId=" + reportId + "&orgUnitGroupId=" + orgUnitGroupId + "&levelId=" + select.value);
+ }
+
+
+
+</script>
+
+
Follow ups