← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4553: (wip) Fixed in exporting to PDF - Allowed to export file based on the filter on page of user with...

 

------------------------------------------------------------
revno: 4553
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-09 13:18:32 +0700
message:
  (wip) Fixed in exporting to PDF - Allowed to export file based on the filter on page of user without belongs to paging.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/UserConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/pdf/ExportToPdfAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.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/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-09-09 06:18:32 +0000
@@ -198,6 +198,8 @@
     Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name,
         int first, int max );
     
+    Collection<UserCredentials> getInactiveUsers( int months );
+    
     Collection<UserCredentials> getInactiveUsers( int months, int first, int max );
     
     int getInactiveUsersCount( int months );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2011-09-04 10:21:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2011-09-09 06:18:32 +0000
@@ -173,11 +173,13 @@
 
     Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name,
         int first, int max );
+
+    Collection<UserCredentials> getInactiveUsers( Date date );
     
     Collection<UserCredentials> getInactiveUsers( Date date, int first, int max );
-    
+
     int getInactiveUsersCount( Date date );
-    
+
     int getActiveUsersCount( Date date );
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2011-09-09 06:18:32 +0000
@@ -374,6 +374,14 @@
         updateUserCredentials( credentials );
     }
 
+    public Collection<UserCredentials> getInactiveUsers( int months )
+    {
+        Calendar cal = PeriodType.createCalendarInstance();
+        cal.add( Calendar.MONTH, (months * -1) );
+        
+        return userStore.getInactiveUsers( cal.getTime() );
+    }
+
     public Collection<UserCredentials> getInactiveUsers( int months, int first, int max )
     {
         Calendar cal = PeriodType.createCalendarInstance();
@@ -426,5 +434,4 @@
     {
         return userStore.getUserSetting( user, name );
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2011-09-04 10:21:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2011-09-09 06:18:32 +0000
@@ -60,14 +60,14 @@
     // -------------------------------------------------------------------------
 
     private SessionFactory sessionFactory;
-    
+
     public void setSessionFactory( SessionFactory sessionFactory )
     {
         this.sessionFactory = sessionFactory;
     }
-    
+
     private GenericIdentifiableObjectStore<UserAuthorityGroup> userRoleStore;
-    
+
     public void setUserRoleStore( GenericIdentifiableObjectStore<UserAuthorityGroup> userRoleStore )
     {
         this.userRoleStore = userRoleStore;
@@ -97,7 +97,7 @@
 
         return (User) session.get( User.class, id );
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public Collection<User> getAllUsers()
     {
@@ -107,40 +107,40 @@
     }
 
     public Collection<User> getUsersWithoutOrganisationUnit()
-    {    	
-    	Collection<User> users = getAllUsers();
-        
+    {
+        Collection<User> users = getAllUsers();
+
         Iterator<User> iterator = users.iterator();
-        
-        while( iterator.hasNext() )
+
+        while ( iterator.hasNext() )
         {
-            if( iterator.next().getOrganisationUnits().size() > 0 )
+            if ( iterator.next().getOrganisationUnits().size() > 0 )
             {
-        	iterator.remove();
+                iterator.remove();
             }
         }
-        
+
         return users;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public Collection<User> getUsersByPhoneNumber( String phoneNumber )
     {
         String hql = "from User u where u.phoneNumber = :phoneNumber";
-        
+
         Query query = sessionFactory.getCurrentSession().createQuery( hql );
         query.setString( "phoneNumber", phoneNumber );
-        
+
         return query.list();
     }
-    
+
     public void deleteUser( User user )
     {
         Session session = sessionFactory.getCurrentSession();
 
         session.delete( user );
     }
-    
+
     // -------------------------------------------------------------------------
     // UserCredentials
     // -------------------------------------------------------------------------
@@ -184,7 +184,7 @@
     public Collection<UserCredentials> getAllUserCredentials()
     {
         Session session = sessionFactory.getCurrentSession();
-        
+
         return session.createCriteria( UserCredentials.class ).list();
     }
 
@@ -212,7 +212,7 @@
 
         session.update( userAuthorityGroup );
     }
-    
+
     public UserAuthorityGroup getUserAuthorityGroup( int id )
     {
         Session session = sessionFactory.getCurrentSession();
@@ -223,11 +223,11 @@
     public UserAuthorityGroup getUserAuthorityGroupByName( String name )
     {
         Session session = sessionFactory.getCurrentSession();
-        
+
         Criteria criteria = session.createCriteria( UserAuthorityGroup.class );
-        
+
         criteria.add( Restrictions.eq( "name", name ) );
-        
+
         return (UserAuthorityGroup) criteria.uniqueResult();
     }
 
@@ -295,26 +295,26 @@
 
         session.delete( userSetting );
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public Collection<UserCredentials> searchUsersByName( String key )
-    {        
+    {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( UserCredentials.class );
-      
+
         criteria.add( Restrictions.ilike( "username", "%" + key + "%" ) );
         criteria.addOrder( Order.asc( "username" ) );
 
         return criteria.list();
     }
-    
+
     public int getUserCount()
     {
         Session session = sessionFactory.getCurrentSession();
-        
+
         Query query = session.createQuery( "select count(*) from User" );
-        
+
         Number rs = (Number) query.uniqueResult();
 
         return rs != null ? rs.intValue() : 0;
@@ -325,31 +325,32 @@
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( UserCredentials.class );
-      
+
         criteria.add( Restrictions.ilike( "username", "%" + name + "%" ) );
-        
+
         criteria.setProjection( Projections.rowCount() );
 
         Number rs = (Number) criteria.uniqueResult();
-        
+
         return rs != null ? rs.intValue() : 0;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public Collection<UserCredentials> getUsersBetween( int first, int max )
     {
         Session session = sessionFactory.getCurrentSession();
 
-        return session.createQuery( "from UserCredentials order by username" ).setFirstResult( first ).setMaxResults( max ).list();
+        return session.createQuery( "from UserCredentials order by username" ).setFirstResult( first ).setMaxResults(
+            max ).list();
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max )
     {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( UserCredentials.class );
-      
+
         criteria.add( Restrictions.ilike( "username", "%" + name + "%" ) );
         criteria.addOrder( Order.asc( "username" ) );
         criteria.setFirstResult( first );
@@ -401,7 +402,7 @@
 
     public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetween( int first, int max )
     {
-        return getBlockUser( toUserCredentials( getUsersWithoutOrganisationUnit()), first, max );
+        return getBlockUser( toUserCredentials( getUsersWithoutOrganisationUnit() ), first, max );
     }
 
     public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String name, int first, int max )
@@ -419,49 +420,59 @@
         return findByName( toUserCredentials( getUsersWithoutOrganisationUnit() ), name ).size();
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
+    public Collection<UserCredentials> getInactiveUsers( Date date )
+    {
+        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
+        criteria.add( Restrictions.lt( "lastLogin", date ) );
+
+        return criteria.list();
+    }
+
+    @SuppressWarnings( "unchecked" )
     public Collection<UserCredentials> getInactiveUsers( Date date, int first, int max )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
         criteria.add( Restrictions.lt( "lastLogin", date ) );
         criteria.setFirstResult( first );
         criteria.setMaxResults( max );
-        
+
         return criteria.list();
     }
-    
+
     public int getInactiveUsersCount( Date date )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
         criteria.add( Restrictions.lt( "lastLogin", date ) );
         criteria.setProjection( Projections.rowCount() );
-        
+
         Number rs = (Number) criteria.uniqueResult();
-        
+
         return rs != null ? rs.intValue() : 0;
     }
-    
+
     public int getActiveUsersCount( Date date )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
         criteria.add( Restrictions.ge( "lastLogin", date ) );
         criteria.setProjection( Projections.rowCount() );
-        
+
         Number rs = (Number) criteria.uniqueResult();
-        
+
         return rs != null ? rs.intValue() : 0;
     }
 
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
-    
-    // TODO All this user / credentials search stuff is horrible and must be improved
-    
+
+    // TODO All this user / credentials search stuff is horrible and must be
+    // improved
+
     private Collection<UserCredentials> findByName( Collection<UserCredentials> users, String key )
     {
         List<UserCredentials> returnList = new ArrayList<UserCredentials>();
-        
+
         for ( UserCredentials user : users )
         {
             if ( user != null )
@@ -481,10 +492,10 @@
         List<UserCredentials> elementList = new ArrayList<UserCredentials>( usersList );
 
         int toIndex = Math.min( startPos + pageSize, elementList.size() );
-        
+
         return elementList.subList( startPos, toIndex );
     }
-    
+
     private List<UserCredentials> toUserCredentials( Collection<User> users )
     {
         List<UserCredentials> credentials = new ArrayList<UserCredentials>();
@@ -493,7 +504,7 @@
         {
             credentials.add( user.getUserCredentials() );
         }
-        
+
         return credentials;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java	2011-09-09 06:18:32 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserCredentials;
 
 /**
  * @author Lars Helge Overland
@@ -90,7 +91,7 @@
 
     private Collection<Integer> organisationUnitLevels = new HashSet<Integer>();
 
-    private Collection<Integer> users = new HashSet<Integer>();
+    private Collection<UserCredentials> users = new HashSet<UserCredentials>();
 
     private Collection<Integer> validationRules = new ArrayList<Integer>();
 
@@ -391,12 +392,12 @@
         this.validationRules = validationRules;
     }
 
-    public Collection<Integer> getUsers()
+    public Collection<UserCredentials> getUsers()
     {
         return users;
     }
 
-    public void setUsers( Collection<Integer> users )
+    public void setUsers( Collection<UserCredentials> users )
     {
         this.users = users;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/UserConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/UserConverter.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/UserConverter.java	2011-09-09 06:18:32 +0000
@@ -27,18 +27,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.PDFConverter;
 import org.hisp.dhis.system.util.PDFUtils;
 import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserService;
-import org.hisp.dhis.user.comparator.UsernameComparator;
 
 import com.lowagie.text.Document;
 
@@ -50,14 +44,11 @@
     extends PDFUtils
     implements PDFConverter
 {
-    private UserService userService;
-
     /**
      * Constructor for write operations.
      */
-    public UserConverter( UserService userService )
+    public UserConverter()
     {
-        this.userService = userService;
     }
 
     // -------------------------------------------------------------------------
@@ -70,13 +61,8 @@
         I18nFormat format = params.getFormat();
 
         PDFUtils.printObjectFrontPage( document, params.getUsers(), i18n, format, "users" );
-
-        List<UserCredentials> userCredentialss = new ArrayList<UserCredentials>( userService.getUsers( params
-            .getUsers(), params.getCurrentUser() ) );
-
-        Collections.sort( userCredentialss, new UsernameComparator() );
-
-        for ( UserCredentials userCredentials : userCredentialss )
+        
+        for ( UserCredentials userCredentials : params.getUsers() )
         {
             addTableToDocument( document, printUser( userCredentials, i18n, format, true, 0.40f, 0.60f ) );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java	2011-09-09 06:18:32 +0000
@@ -48,7 +48,6 @@
 import org.hisp.dhis.importexport.pdf.converter.ValidationRuleConverter;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.user.UserService;
 import org.hisp.dhis.validation.ValidationRuleService;
 
 /**
@@ -97,13 +96,6 @@
         this.organisationUnitService = organisationUnitService;
     }
 
-    private UserService userService;
-
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
-
     private ValidationRuleService validationRuleService;
 
     public void setValidationRuleService( ValidationRuleService validationRuleService )
@@ -140,10 +132,9 @@
 
             thread.setDataElementConverter( new DataElementConverter( dataElementService ) );
             thread.setIndicatorConverter( new IndicatorConverter( indicatorService, expressionService ) );
-            thread.setOrganisationUnitHierarchyConverter( new OrganisationUnitHierarchyConverter(
-                organisationUnitService ) );
+            thread.setOrganisationUnitHierarchyConverter( new OrganisationUnitHierarchyConverter( organisationUnitService ) );
             thread.setOrganisationUnitConverter( new OrganisationUnitConverter( organisationUnitService ) );
-            thread.setUserConverter( new UserConverter( userService ) );
+            thread.setUserConverter( new UserConverter() );
             thread.setValidationRuleConverter( new ValidationRuleConverter( validationRuleService, expressionService ) );
 
             thread.start();

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2011-09-09 06:18:32 +0000
@@ -272,7 +272,6 @@
 	<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="userService" ref="org.hisp.dhis.user.UserService" />
     <property name="validationRuleService" ref="org.hisp.dhis.validation.ValidationRuleService" />
   </bean>
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java	2011-09-09 06:18:32 +0000
@@ -592,7 +592,7 @@
         }
 
         temp = temp.trim();
-        temp.substring( 0, temp.isEmpty() ? 0 : temp.length() - 2 );
+        temp = temp.substring( 0, temp.isEmpty() ? 0 : temp.length() - 1 );
 
         table.addCell( getItalicCell( i18n.getString( "organisation_units" ) ) );
         table.addCell( getTextCell( temp ) );
@@ -605,7 +605,7 @@
         }
 
         temp = temp.trim();
-        temp.substring( 0, temp.isEmpty() ? 0 : temp.length() - 2 );
+        temp = temp.substring( 0, temp.isEmpty() ? 0 : temp.length() - 1 );
 
         table.addCell( getItalicCell( i18n.getString( "roles" ) ) );
         table.addCell( getTextCell( temp ) );

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-08-19 08:56:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-09-09 06:18:32 +0000
@@ -1334,12 +1334,17 @@
 }
 
 /**
- * Used to export PDF file by the given type and the active items in table
+ * Used to export PDF file by the given type and the filter params in page
  */
-function exportPdfByType( type )
-{
-	var activeIds = getArrayIdOfActiveRows();
-	window.location.href = 'exportToPdf.action?type=' + type + activeIds;
+function exportPdfByType( type, params )
+{	
+	if ( jQuery( "table.listTable tbody tr" ).length == 0 )
+	{
+		showWarningMessage( 'no_item_to_export' );
+		return;
+	}
+	
+	window.location.href = 'exportToPdf.action?type=' + type + params;
 }
 
 /**

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-08 10:38:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-09 06:18:32 +0000
@@ -426,6 +426,7 @@
 #-- Export PDF messages  -------------------------------------------------------#
 
 get_pdf                             = Get PDF
+no_item_to_export					= There is no item to export
 name                                = Name
 short_name                          = Short name
 alternative_name                    = Alternative name

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties	2011-09-09 06:18:32 +0000
@@ -367,6 +367,7 @@
 #-- Export PDF messages  -------------------------------------------------------#
 
 get_pdf                             = Xu\u1ea5t t\u1eadp tin PDF
+no_item_to_export					= Hi\u1ec7n t\u1ea1i kh\u00f4ng c\u00f3 d\u1eef li\u1ec7u n\u00e0o \u0111\u1ec3 xu\u1ea5t b\u00e1o c\u00e1o
 name                                = T\u00ean
 short_name                          = T\u00ean vi\u1ebft t\u1eaft
 alternative_name                    = T\u00ean thay th\u1ebf

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java	2011-06-19 10:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java	2011-09-09 06:18:32 +0000
@@ -126,7 +126,6 @@
                 this.paging = createPaging( userService.getUsersByOrganisationUnitCountByName( organisationUnit, key ) );
                 
                 userCredentialsList = new ArrayList<UserCredentials>( userService.getUsersByOrganisationUnitBetweenByName( organisationUnit, key, paging.getStartPos(), paging.getPageSize() ) );
-                
             }
         }
         else

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/pdf/ExportToPdfAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/pdf/ExportToPdfAction.java	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/pdf/ExportToPdfAction.java	2011-09-09 06:18:32 +0000
@@ -27,8 +27,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -38,7 +41,12 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ExportService;
+import org.hisp.dhis.system.filter.UserCredentialsCanUpdateFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserService;
+import org.hisp.dhis.user.comparator.UsernameComparator;
 
 import com.opensymphony.xwork2.Action;
 
@@ -61,6 +69,13 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    private UserService userService;
+
+    public void setUserService( UserService userService )
+    {
+        this.userService = userService;
+    }
+
     private CurrentUserService currentUserService;
 
     public void setCurrentUserService( CurrentUserService currentUserService )
@@ -111,6 +126,20 @@
     // Input
     // -------------------------------------------------------------------------
 
+    private String key;
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    private Integer months;
+
+    public void setMonths( Integer months )
+    {
+        this.months = months;
+    }
+
     private String type;
 
     public void setType( String type )
@@ -118,12 +147,7 @@
         this.type = type;
     }
 
-    private List<Integer> activeIds = new ArrayList<Integer>();
-
-    public void setActiveIds( List<Integer> activeIds )
-    {
-        this.activeIds = activeIds;
-    }
+    private List<UserCredentials> userCredentialsList = null;
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -138,9 +162,27 @@
 
             if ( type.equals( TYPE_USER ) )
             {
-                if ( (activeIds != null) && !activeIds.isEmpty() )
-                {
-                    params.setUsers( activeIds );
+                if ( isNotBlank( key ) ) // Filter on key only if set
+                {
+                    userCredentialsList = new ArrayList<UserCredentials>( userService.searchUsersByName( key ) );
+                }
+                else if ( months != null && months != 0 )
+                {
+                    userCredentialsList = new ArrayList<UserCredentials>( userService.getInactiveUsers( months ) );
+                }
+                else
+                {
+                    userCredentialsList = new ArrayList<UserCredentials>( userService.getAllUserCredentials() );
+                }
+
+                FilterUtils.filter( userCredentialsList, new UserCredentialsCanUpdateFilter( currentUserService
+                    .getCurrentUser() ) );
+
+                Collections.sort( userCredentialsList, new UsernameComparator() );
+
+                if ( (userCredentialsList != null) && !userCredentialsList.isEmpty() )
+                {
+                    params.setUsers( userCredentialsList );
                 }
                 else
                 {
@@ -152,7 +194,6 @@
                 log.info( "Exporting to PDF for object type: " + TYPE_USER );
             }
 
-            params.setCurrentUser( currentUserService.getCurrentUser() );
             params.setIncludeDataValues( false );
             params.setI18n( i18n );
             params.setFormat( format );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml	2011-09-09 06:18:32 +0000
@@ -142,6 +142,7 @@
     <property name="serviceProvider">
       <ref bean="exportServiceProvider" />
     </property>
+    <property name="userService" ref="org.hisp.dhis.user.UserService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
   

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm	2011-09-09 06:04:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm	2011-09-09 06:18:32 +0000
@@ -32,7 +32,7 @@
 						</select>
 					</td>
 					<td colspan="3" style="text-align:right">
-						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="//exportPdfByType( 'user' );" style="width:80px"/>
+						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="exportPDF( 'user' );" style="width:80px"/>
 						<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddUserForm.action'"/>
 					</td>
 				</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js	2011-09-05 04:00:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js	2011-09-09 06:18:32 +0000
@@ -1,5 +1,17 @@
 
 // -----------------------------------------------------------------------------
+// Export to PDF file
+// -----------------------------------------------------------------------------
+
+function exportPDF( type )
+{
+	var params = "&key=" + jQuery( 'input[type=text][id=key]' ).val();
+	params += "&months=" + jQuery( '#months' ).val();
+
+	exportPdfByType( type, params );
+}
+
+// -----------------------------------------------------------------------------
 // Search users
 // -----------------------------------------------------------------------------