=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/AddDepartmentAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/AddDepartmentAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/AddDepartmentAction.java 2013-01-03 10:00:51 +0000 @@ -0,0 +1,175 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * Copyright (c) 2004-2012, 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.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; + +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class AddDepartmentAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private Collection selectedGroups = new HashSet(); + + public void setSelectedGroups( Collection selectedGroups ) + { + this.selectedGroups = selectedGroups; + } + + private Integer organisationUnitId; + + public Integer getOrganisationUnitId() + { + return organisationUnitId; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + Date date = format.parseDateTime( Calendar.getInstance().getTime().toString() ); + + // --------------------------------------------------------------------- + // Get parent + // --------------------------------------------------------------------- + + OrganisationUnit parent = selectionManager.getSelectedOrganisationUnit(); + + if ( parent == null ) + { + // ----------------------------------------------------------------- + // If no unit is selected, the parent is the parent of the roots + // ----------------------------------------------------------------- + + parent = selectionManager.getRootOrganisationUnitsParent(); + } + + // --------------------------------------------------------------------- + // Create organization unit + // --------------------------------------------------------------------- + + OrganisationUnit organisationUnit = new OrganisationUnit( name, shortName, null, date, null, true, null ); + + organisationUnit.setParent( parent ); + + if ( parent != null ) + { + parent.getChildren().add( organisationUnit ); + } + + // --------------------------------------------------------------------- + // Must persist org-unit before adding data sets because association are + // updated on both sides (and this side is inverse) + // --------------------------------------------------------------------- + + organisationUnitId = organisationUnitService.addOrganisationUnit( organisationUnit ); + + for ( String id : selectedGroups ) + { + OrganisationUnitGroup group = organisationUnitGroupService + .getOrganisationUnitGroup( Integer.parseInt( id ) ); + + if ( group != null ) + { + group.addOrganisationUnit( organisationUnit ); + organisationUnitGroupService.updateOrganisationUnitGroup( group ); + } + } + + organisationUnitService.updateOrganisationUnit( organisationUnit ); + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java 2013-01-03 10:00:51 +0000 @@ -0,0 +1,146 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * Copyright (c) 2004-2012, 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.apache.commons.lang.StringUtils.isNotBlank; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.paging.ActionPagingSupport; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class ShowAddDepartmentFormAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List groupSets; + + public List getGroupSets() + { + return groupSets; + } + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() + { + return organisationUnits; + } + + private String key; + + public String getKey() + { + return key; + } + + public void setKey( String key ) + { + this.key = key; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + groupSets = new ArrayList( organisationUnitGroupService + .getCompulsoryOrganisationUnitGroupSetsWithMembers() ); + + Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE ); + + // + + Collection selectedUnits = selectionManager.getSelectedOrganisationUnits(); + + if ( selectedUnits.isEmpty() ) + { + organisationUnits.addAll( selectionManager.getRootOrganisationUnits() ); + } + else + { + for ( OrganisationUnit selectedUnit : selectedUnits ) + { + organisationUnits.addAll( selectedUnit.getChildren() ); + } + } + + Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() ); + + if ( isNotBlank( key ) ) + { + organisationUnitService.searchOrganisationUnitByName( organisationUnits, key ); + } + + this.paging = createPaging( organisationUnits.size() ); + organisationUnits = getBlockElement( organisationUnits, paging.getStartPos(), paging.getPageSize() ); + + return SUCCESS; + } +} === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-12-17 10:36:42 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-01-03 10:00:51 +0000 @@ -1538,4 +1538,34 @@ scope="prototype"> + + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-12-18 08:08:53 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2013-01-03 10:00:51 +0000 @@ -1872,6 +1872,20 @@ ../dhis-web-commons/ajax/jsonResponseError.vm plainTextError - + + + + + /main.vm + /dhis-web-maintenance-organisationunit/department.vm + /dhis-web-maintenance-organisationunit/menuWithTree.vm + ../dhis-web-commons/ouwt/ouwt.js,javascript/department.js + + + + + department.action + F_ORGANISATIONUNIT_ADD + \ No newline at end of file === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm 2013-01-03 10:00:51 +0000 @@ -0,0 +1,198 @@ + + +

$i18n.getString( "org_unit_management" ) #openHelp( "orgunit" )

+ +
+ + + + + + + + + + + + + +
$i18n.getString( "details" )
+ + + + + + #foreach ( $groupSet in $groupSets ) + + + + + + #end +
$i18n.getString( "organisation_unit_groups" )
$encoder.htmlEncode( $groupSet.name ) + + + +
+ +
+ +
+ +

$i18n.getString( "list_of_organisation_unit" )

+ + + + + + +
+ + + + + +
#filterDiv( "organisationUnit" ) + +
+ + + + + + + + + + + + + #foreach( $organisationUnit in $organisationUnits ) + + + + + + #end + + #if ( $organisationUnits.size() == 0 ) + + + + #end +
$i18n.getString( "name" )$i18n.getString( "organisation_unit_groups" )$i18n.getString( "operations" )
$encoder.htmlEncode( $organisationUnit.name ) + + + $i18n.getString( 'edit' ) + #if( $organisationUnit.children.size() == 0 && $auth.hasAccess( "dhis-web-maintenance-organisationunit", "removeOrganisationUnit" ) ) + $i18n.getString( 'remove' ) + #else $i18n.getString( 'remove' ) #end + $i18n.getString( 'show_details' ) +
$i18n.getString( "this_org_unit_has_no_children" )
+

+ #parse( "/dhis-web-commons/paging/paging.vm" ) + +
+ + + + + +
=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js 2013-01-03 10:00:51 +0000 @@ -0,0 +1,70 @@ +// ----------------------------------------------------------------------------- +// Organisation unit selection listener +// ----------------------------------------------------------------------------- + +$( document ).ready( function() +{ + selection.setAutoSelectRoot( false ); + selection.setRootUnselectAllowed( true ); + selection.setListenerFunction( organisationUnitSelected, true ); +} ); + +function organisationUnitSelected( orgUnitIds ) +{ + window.location.href = 'department.action'; +} + +// ----------------------------------------------------------------------------- +// Export to PDF +// ----------------------------------------------------------------------------- + +function exportPDF( type ) +{ + var params = "type=" + type; + + exportPdfByType( type, params ); +} + +// ----------------------------------------------------------------------------- +// View details +// ----------------------------------------------------------------------------- + +function showOrganisationUnitDetails( unitId ) +{ + jQuery.post( '../dhis-web-commons-ajax-json/getOrganisationUnit.action', + { id: unitId }, function ( json ) { + setInnerHTML( 'nameField', json.organisationUnit.name ); + setInnerHTML( 'shortNameField', json.organisationUnit.shortName ); + setInnerHTML( 'descriptionField', json.organisationUnit.description ); + setInnerHTML( 'openingDateField', json.organisationUnit.openingDate ); + + var orgUnitCode = json.organisationUnit.code; + setInnerHTML( 'codeField', orgUnitCode ? orgUnitCode : '[' + none + ']' ); + + var closedDate = json.organisationUnit.closedDate; + setInnerHTML( 'closedDateField', closedDate ? closedDate : '[' + none + ']' ); + + var commentValue = json.organisationUnit.comment; + setInnerHTML( 'commentField', commentValue ? commentValue.replace( /\n/g, '
' ) : '[' + none + ']' ); + + var active = json.organisationUnit.active; + setInnerHTML( 'activeField', active == 'true' ? yes : no ); + + var url = json.organisationUnit.url; + setInnerHTML( 'urlField', url ? '' + url + '' : '[' + none + ']' ); + + var lastUpdated = json.organisationUnit.lastUpdated; + setInnerHTML( 'lastUpdatedField', lastUpdated ? lastUpdated : '[' + none + ']' ); + + showDetails(); + }); +} + +// ----------------------------------------------------------------------------- +// Remove organisation unit +// ----------------------------------------------------------------------------- + +function removeOrganisationUnit( unitId, unitName ) +{ + removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action', subtree.refreshTree ); +} === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/menu.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/menu.vm 2012-12-13 08:59:31 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/menu.vm 2013-01-03 10:00:51 +0000 @@ -5,6 +5,11 @@

$i18n.getString( "generate_report" ) 

+ +

$i18n.getString( "generate_report" ) 

+