=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2014-05-07 10:09:11 +0000 @@ -337,11 +337,4 @@ */ ProgramStageInstance createProgramStageInstance( TrackedEntityInstance entityInstance, Program program, Date executionDate, OrganisationUnit organisationUnit ); - - Grid searchEvents( ProgramStage programStage, List columns, - Collection organisationUnits, Date startDate, Date endDate, Boolean completed, Integer min, - Integer max, I18n i18n ); - - int searchEventsCount( ProgramStage programStage, List columns, - Collection organisationUnits, Boolean completed, Date startDate, Date endDate ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2014-05-07 10:09:11 +0000 @@ -245,41 +245,4 @@ * @return Grid */ Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ); - - /** - * Search {@link ProgramStageInstance} by criteria with result limited - * - * @param programStage {@link ProgramStage} needs for searching events - * @param orgUnits List of {@link OrganisationUnit} ids - * @param columns The criteria for searching - * @param startDate Report date the instance should be on or after. - * @param endDate Report date the instance should be on or before. - * @param completed The status of events. There are three status values, - * NULL for retrieving all events, false for retrieving events - * uncompleted and true for retrieving events completed. - * @param min - * @param max - * @param i18n - * - * @return A grid - */ - Grid searchEvent( ProgramStage programStage, Collection orgUnits, List columns, - Date startDate, Date endDate, Boolean completed, Integer min, Integer max, I18n i18n ); - - /** - * Search {@link ProgramStageInstance} by criteria - * - * @param programStage {@link ProgramStage} needs for searching events - * @param orgUnits List of {@link OrganisationUnit} ids - * @param columns The criteria for searching - * @param startDate Report date the instance should be on or after. - * @param endDate Report date the instance should be on or before. - * @param completed The status of events. There are three status values, - * NULL for retrieving all events, false for retrieving events - * uncompleted and true for retrieving events completed. - * - * @return The number of events - */ - int searchEventsCount( ProgramStage programStage, List columns, - Collection organisationUnits, Date startDate, Date endDate, Boolean completed ); } === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2014-05-07 10:09:11 +0000 @@ -677,23 +677,6 @@ return programStageInstance; } - @Override - public Grid searchEvents( ProgramStage programStage, List columns, - Collection organisationUnits, Date startDate, Date endDate, Boolean completed, Integer min, - Integer max, I18n i18n ) - { - return programStageInstanceStore.searchEvent( programStage, organisationUnits, columns, startDate, endDate, - completed, min, max, i18n ); - } - - @Override - public int searchEventsCount( ProgramStage programStage, List columns, - Collection organisationUnits, Boolean completed, Date startDate, Date endDate ) - { - return programStageInstanceStore.searchEventsCount( programStage, columns, organisationUnits, startDate, - endDate, completed ); - } - // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2014-05-07 10:09:11 +0000 @@ -34,7 +34,6 @@ import java.util.Date; import java.util.HashSet; import java.util.List; -import java.util.Set; import org.hibernate.Criteria; import org.hibernate.criterion.Order; @@ -44,7 +43,6 @@ import org.hisp.dhis.common.GridHeader; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; @@ -54,11 +52,9 @@ import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramStageInstanceStore; import org.hisp.dhis.program.SchedulingProgramObject; -import org.hisp.dhis.program.TabularEventColumn; import org.hisp.dhis.sms.outbound.OutboundSms; import org.hisp.dhis.system.grid.GridUtils; import org.hisp.dhis.system.grid.ListGrid; -import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.system.util.TextUtils; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; @@ -82,13 +78,6 @@ this.programInstanceService = programInstanceService; } - private StatementBuilder statementBuilder; - - public void setStatementBuilder( StatementBuilder statementBuilder ) - { - this.statementBuilder = statementBuilder; - } - // ------------------------------------------------------------------------- // Implemented methods // ------------------------------------------------------------------------- @@ -199,11 +188,7 @@ String programName = rs.getString( "programName" ); String programStageName = rs.getString( "programStageName" ); String daysSinceDueDate = rs.getString( "days_since_due_date" ); - String dueDate = rs.getString( "duedate" ).split( " " )[0];// just - // get - // date, - // remove - // timestamp + String dueDate = rs.getString( "duedate" ).split( " " )[0]; message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName ); message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGAM_STAGE_NAME, programStageName ); @@ -507,60 +492,6 @@ return criteria.list(); } - @Override - public Grid searchEvent( ProgramStage programStage, Collection orgUnits, List columns, - Date startDate, Date endDate, Boolean completed, Integer min, Integer max, I18n i18n ) - { - // --------------------------------------------------------------------- - // Headers cols - // --------------------------------------------------------------------- - - Grid grid = new ListGrid(); - grid.setTitle( programStage.getDisplayName() ); - grid.setSubtitle( i18n.getString( "from" ) + " " + DateUtils.getMediumDateString( startDate ) + " " - + i18n.getString( "to" ) + " " + DateUtils.getMediumDateString( endDate ) ); - - grid.addHeader( new GridHeader( "id", true, true ) ); - grid.addHeader( new GridHeader( programStage.getReportDateDescription(), false, true ) ); - - Collection deKeys = new HashSet(); - for ( TabularEventColumn column : columns ) - { - String deKey = "element_" + column.getIdentifier(); - if ( !deKeys.contains( deKey ) ) - { - grid.addHeader( new GridHeader( column.getName(), column.isHidden(), true ) ); - deKeys.add( deKey ); - } - } - - grid.addHeader( new GridHeader( "Complete", true, true ) ); - grid.addHeader( new GridHeader( "TrackedEntityInstanceId", true, true ) ); - - // --------------------------------------------------------------------- - // Get SQL and build grid - // --------------------------------------------------------------------- - - String sql = getTabularReportSql( false, programStage, columns, orgUnits, startDate, endDate, completed, min, - max ); - - SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql ); - - GridUtils.addRows( grid, rowSet ); - - return grid; - } - - @Override - public int searchEventsCount( ProgramStage programStage, List columns, - Collection organisationUnits, Date startDate, Date endDate, Boolean completed ) - { - String sql = getTabularReportSql( true, programStage, columns, organisationUnits, startDate, endDate, - completed, null, null ); - - return jdbcTemplate.queryForObject( sql, Integer.class ); - } - // --------------------------------------------------------------------- // Supportive methods // --------------------------------------------------------------------- @@ -719,101 +650,4 @@ + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null " + " and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_USER_GROUP; } - - private String getTabularReportSql( boolean count, ProgramStage programStage, List columns, - Collection orgUnits, Date startDate, Date endDate, Boolean completed, Integer min, Integer max ) - { - Set deKeys = new HashSet(); - String selector = count ? "count(*) " : "* "; - - String sql = "select " + selector + "from ( select DISTINCT psi.programstageinstanceid, psi.executiondate,"; - String where = ""; - String operator = "where "; - - for ( TabularEventColumn column : columns ) - { - if ( column.isNumberDataElement() ) - { - String deKey = "element_" + column.getIdentifier(); - if ( !deKeys.contains( deKey ) ) - { - sql += "(select cast( value as " - + statementBuilder.getDoubleColumnType() - + " ) from trackedentitydatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid=" - + column.getIdentifier() + ") as element_" + column.getIdentifier() + ","; - deKeys.add( deKey ); - } - - if ( column.hasQuery() ) - { - where += operator + "element_" + column.getIdentifier() + " " + column.getOperator() + " " - + column.getQuery() + " "; - operator = "and "; - } - } - else if ( column.isDataElement() ) - { - String deKey = "element_" + column.getIdentifier(); - if ( !deKeys.contains( deKey ) ) - { - sql += "(select value from trackedentitydatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid=" - + column.getIdentifier() + ") as element_" + column.getIdentifier() + ","; - deKeys.add( deKey ); - } - - if ( column.hasQuery() ) - { - if ( column.isDateType() ) - { - where += operator + "element_" + column.getIdentifier() + " " + column.getOperator() + " " - + column.getQuery() + " "; - } - else - { - where += operator + "lower(element_" + column.getIdentifier() + ") " + column.getOperator() - + " " + column.getQuery() + " "; - } - operator = "and "; - } - } - } - - sql += " psi.completed "; - - sql += "from programstageinstance psi "; - sql += "left join programinstance pi on (psi.programinstanceid=pi.programinstanceid) "; - sql += "left join trackedentityinstance p on (pi.trackedentityinstanceid=p.trackedentityinstanceid) "; - sql += "join organisationunit ou on (ou.organisationunitid=psi.organisationunitid) "; - - sql += "where psi.programstageid=" + programStage.getId() + " "; - - if ( startDate != null && endDate != null ) - { - String sDate = DateUtils.getMediumDateString( startDate ); - String eDate = DateUtils.getMediumDateString( endDate ); - - sql += "and psi.executiondate >= '" + sDate + "' "; - sql += "and psi.executiondate <= '" + eDate + "' "; - } - - if ( orgUnits != null ) - { - sql += "and ou.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgUnits ) + ") "; - } - if ( completed != null ) - { - sql += "and psi.completed=" + completed + " "; - } - - sql += "order by psi.executiondate desc "; - - sql += " "; - sql += ") as tabular "; - sql += where; // filters - sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma - sql += (min != null && max != null) ? statementBuilder.limitRecord( min, max ) : ""; - - return sql; - } - } \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-05-07 09:03:42 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-05-07 10:09:11 +0000 @@ -30,7 +30,6 @@ - programs; - - public List getPrograms() - { - return programs; - } - - private List levels; - - public List getLevels() - { - return levels; - } - - // ------------------------------------------------------------------------- - // Implementation Action - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - orgunit = selectionManager.getSelectedOrganisationUnit(); - - if ( orgunit != null ) - { - programs = new ArrayList( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, - orgunit ) ); - programs.retainAll( programService.getProgramsByCurrentUser()); - - Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE ); - } - - levels = organisationUnitService.getOrganisationUnitLevels(); - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchEventsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchEventsAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchEventsAction.java 1970-01-01 00:00:00 +0000 @@ -1,457 +0,0 @@ -package org.hisp.dhis.caseentry.action.caseentry; - -/* - * Copyright (c) 2004-2014, 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.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hibernate.exception.SQLGrammarException; -import org.hisp.dhis.common.Grid; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.paging.ActionPagingSupport; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageInstance; -import org.hisp.dhis.program.ProgramStageInstanceService; -import org.hisp.dhis.program.ProgramStageService; -import org.hisp.dhis.program.TabularEventColumn; -import org.hisp.dhis.system.util.ConversionUtils; -import org.hisp.dhis.system.util.TextUtils; -import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.user.CurrentUserService; - -/** - * @author Chau Thu Tran - * @version $ SearchEventsAction.java Nov 22, 2013 1:06:04 PM $ - */ -public class SearchEventsAction - extends ActionPagingSupport -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - private ProgramStageService programStageService; - - public void setProgramStageService( ProgramStageService programStageService ) - { - this.programStageService = programStageService; - } - - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - private ProgramStageInstanceService programStageInstanceService; - - public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) - { - this.programStageInstanceService = programStageInstanceService; - } - - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private List attributes = new ArrayList(); - - public List getAttributes() - { - return attributes; - } - - private Collection orgunitIds = new HashSet(); - - public void setOrgunitIds( Collection orgunitIds ) - { - this.orgunitIds = orgunitIds; - } - - private Integer programStageId; - - public void setProgramStageId( Integer programStageId ) - { - this.programStageId = programStageId; - } - - private String startDate; - - public void setStartDate( String startDate ) - { - this.startDate = startDate; - } - - private String endDate; - - public void setEndDate( String endDate ) - { - this.endDate = endDate; - } - - private List values = new ArrayList(); - - public List getValues() - { - return values; - } - - private List filterValues = new ArrayList(); - - public void setFilterValues( List filterValues ) - { - this.filterValues = filterValues; - } - - private Boolean userOrganisationUnit; - - public void setUserOrganisationUnit( Boolean userOrganisationUnit ) - { - this.userOrganisationUnit = userOrganisationUnit; - } - - private Boolean userOrganisationUnitChildren; - - public void setUserOrganisationUnitChildren( Boolean userOrganisationUnitChildren ) - { - this.userOrganisationUnitChildren = userOrganisationUnitChildren; - } - - private Grid grid; - - public Grid getGrid() - { - return grid; - } - - private Integer total; - - public void setTotal( Integer total ) - { - this.total = total; - } - - public Integer getTotal() - { - return total; - } - - private I18n i18n; - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - private I18nFormat format; - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - private Boolean useCompletedEvents; - - public void setUseCompletedEvents( Boolean useCompletedEvents ) - { - this.useCompletedEvents = useCompletedEvents; - } - - private List dataElements = new ArrayList(); - - public List getDataElements() - { - return dataElements; - } - - private String type; - - public void setType( String type ) - { - this.type = type; - } - - private String facilityLB; // All, children, current - - public void setFacilityLB( String facilityLB ) - { - this.facilityLB = facilityLB; - } - - private List valueTypes = new ArrayList(); - - public List getValueTypes() - { - return valueTypes; - } - - private Map> mapSuggestedValues = new HashMap>(); - - public Map> getMapSuggestedValues() - { - return mapSuggestedValues; - } - - private String message; - - public String getMessage() - { - return message; - } - - private Boolean useFormNameDataElement; - - public void setUseFormNameDataElement( Boolean useFormNameDataElement ) - { - this.useFormNameDataElement = useFormNameDataElement; - } - - // ------------------------------------------------------------------------- - // Implementation Action - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - if ( programStageId == null ) - { - return INPUT; - } - - // --------------------------------------------------------------------- - // Get user orgunits - // --------------------------------------------------------------------- - - Set ous = new HashSet( organisationUnitService.getOrganisationUnitsByUid( orgunitIds ) ); - Set orgUnitIds = new HashSet( ConversionUtils.getIdentifiers( OrganisationUnit.class, ous ) ); - - if ( userOrganisationUnit || userOrganisationUnitChildren ) - { - Collection userOrgunits = currentUserService.getCurrentUser().getOrganisationUnits(); - orgUnitIds = new HashSet(); - - if ( userOrganisationUnit ) - { - for ( OrganisationUnit userOrgunit : userOrgunits ) - { - orgUnitIds.add( userOrgunit.getId() ); - } - } - - if ( userOrganisationUnitChildren ) - { - for ( OrganisationUnit userOrgunit : userOrgunits ) - { - if ( userOrgunit.hasChild() ) - { - for ( OrganisationUnit childOrgunit : userOrgunit.getSortedChildren() ) - { - orgUnitIds.add( childOrgunit.getId() ); - } - } - } - } - } - - // --------------------------------------------------------------------- - // Get orgunitIds - // --------------------------------------------------------------------- - - Set organisationUnits = new HashSet(); - - if ( facilityLB.equals( "selected" ) ) - { - organisationUnits.addAll( orgUnitIds ); - } - else if ( facilityLB.equals( "childrenOnly" ) ) - { - for ( Integer orgunitId : orgUnitIds ) - { - OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId ); - organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy() - .getChildren( orgunitId ) ); - organisationUnits.remove( selectedOrgunit ); - } - } - else - { - for ( Integer orgunitId : orgUnitIds ) - { - organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy() - .getChildren( orgunitId ) ); - } - } - - // --------------------------------------------------------------------- - // Get program-stage, start-date, end-date - // --------------------------------------------------------------------- - - ProgramStage programStage = programStageService.getProgramStage( programStageId ); - Date start = format.parseDate( startDate ); - Date end = format.parseDate( endDate ); - List columns = getTableColumns(); - - // --------------------------------------------------------------------- - // Generate tabular report - // --------------------------------------------------------------------- - try - { - if ( type == null ) // Tabular report - { - total = programStageInstanceService.searchEventsCount( programStage, columns, organisationUnits, - useCompletedEvents, start, end ); - this.paging = createPaging( total ); - - grid = programStageInstanceService.searchEvents( programStage, columns, organisationUnits, start, end, - useCompletedEvents, paging.getStartPos(), paging.getPageSize(), i18n ); - } - // Download as Excel - else - { - grid = programStageInstanceService.searchEvents( programStage, columns, organisationUnits, start, end, - useCompletedEvents, null, null, i18n ); - } - } - catch ( SQLGrammarException ex ) - { - message = i18n.getString( "failed_to_get_events" ); - } - - return type == null ? SUCCESS : type; - } - - // ------------------------------------------------------------------------- - // Supportive methods - // ------------------------------------------------------------------------- - - private List getTableColumns() - { - List columns = new ArrayList(); - - int index = 0; - - for ( String filterValue : filterValues ) - { - String[] values = filterValue.split( "_" ); - - if ( values != null && values.length >= 3 ) - { - String prefix = values[0]; - - TabularEventColumn column = new TabularEventColumn(); - column.setPrefix( prefix ); - column.setIdentifier( values[1] ); - column.setHidden( Boolean.parseBoolean( values[2] ) ); - - column.setOperator( values.length > 3 ? TextUtils.lower( values[3] ) : TextUtils.EMPTY ); - column.setQuery( values.length > 4 ? TextUtils.lower( values[4] ) : TextUtils.EMPTY ); - - if ( "de".equals( prefix ) ) - { - int objectId = Integer.parseInt( values[1] ); - DataElement dataElement = dataElementService.getDataElement( objectId ); - if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) ) - { - column.setPrefix( "numberDe" ); - } - dataElements.add( dataElement ); - - String valueType = dataElement.getOptionSet() != null ? "optionSet" : dataElement - .getType(); - valueTypes.add( valueType ); - mapSuggestedValues.put( index, getSuggestedDataElementValues( dataElement ) ); - if ( dataElement.getType().equals( DataElement.VALUE_TYPE_DATE ) ) - { - column.setDateType( true ); - } - - if ( useFormNameDataElement != null && useFormNameDataElement ) - { - column.setName( dataElement.getFormNameFallback() ); - } - else - { - column.setName( dataElement.getDisplayName() ); - } - } - - columns.add( column ); - - index++; - } - } - - return columns; - } - - private List getSuggestedDataElementValues( DataElement dataElement ) - { - List values = new ArrayList(); - String valueType = dataElement.getType(); - - if ( valueType.equals( DataElement.VALUE_TYPE_BOOL ) ) - { - values.add( i18n.getString( "yes" ) ); - values.add( i18n.getString( "no" ) ); - } - if ( valueType.equals( DataElement.VALUE_TYPE_TRUE_ONLY ) ) - { - values.add( i18n.getString( "" ) ); - values.add( i18n.getString( "yes" ) ); - } - - return values; - } -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-04-30 12:57:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-05-07 10:09:11 +0000 @@ -325,17 +325,6 @@ - - - - - - @@ -687,18 +676,6 @@ scope="prototype"> - - - - - - - - - jQuery( document ).ready( function () { - datePickerInRange( 'startDate', 'endDate', true, true ); - disableCriteriaDiv(); - } ); - - -

$i18n.getString( "anonymous_events_management" ) #openHelp('single_event_without_registration')

-

-

fasdfadfa

- - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- $i18n.getString("program") * - - - - - - -
- - - $i18n.getString("incomplete") -
- - - - -
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - - - - - - - - - - - - - -
- -
- - - -#parse( "dhis-web-commons/loader/loader.vm" ) - - === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/index.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/index.vm 2014-04-06 18:03:57 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/index.vm 2014-05-07 10:09:11 +0000 @@ -18,10 +18,6 @@ #introListImgItem( "singleEventSelect.action" "single_event_with_registration" "attribute" ) #end - #if( $auth.hasAccess( "dhis-web-caseentry", "anonymousRegistration" ) ) - #introListImgItem( "anonymousRegistration.action" "anonymous_events" "attribute" ) - #end - #if( $auth.hasAccess( "dhis-web-caseentry", "reportSelect" ) ) #introListImgItem( "reportSelect.action" "program_summary" "summaryreport" ) #end === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2014-03-20 10:17:37 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 1970-01-01 00:00:00 +0000 @@ -1,1163 +0,0 @@ -var DAO = DAO || {}; - -DAO.store = new dhis2.storage.Store( { - name: 'dhis2', - adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ], - objectStores: [ 'programs', 'programStages', 'optionSets', 'usernames', { - name: 'dataValues', - adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ] - } ] -} ); - -function loadPrograms() { - var def = $.Deferred(); - - $.ajax( { - url: 'getProgramMetaData.action', - dataType: 'json', - cache: false - } ).done(function ( data ) { - var programs = _.values( data.metaData.programs ); - DAO.store.setAll( 'programs', programs ).then( function () { - def.resolve( data.metaData ); - } ); - } ).fail( function () { - def.resolve(); - } ); - - return def.promise(); -} - -function loadProgramStages( metaData ) { - if ( !metaData ) { - return; - } - - var def = $.Deferred(); - var promise = def.promise(); - - _.each( _.values( metaData.programs ), function ( el ) { - var id = el.programStages[0].id; - promise = promise.then( makeProgramStageRequest( id )); - } ); - - promise = promise.then(function() { - return $.Deferred().resolve(metaData); - }); - - def.resolve( metaData ); - - return promise; -} - -function makeProgramStageRequest( id ) { - return function() { - var data = createProgramStage( id ); - - return $.ajax( { - url: 'dataentryform.action', - data: data, - dataType: 'html', - cache: false - } ).done( function ( data ) { - var obj = {}; - obj.id = id; - obj.form = data; - DAO.store.set( 'programStages', obj ); - } ); - } -} - -function loadOptionSets( metaData ) { - if ( !metaData ) { - return; - } - - var mainDef = $.Deferred(); - var mainPromise = mainDef.promise(); - - var def = $.Deferred(); - var promise = def.promise(); - - var builder = $.Deferred(); - var build = builder.promise(); - - _.each( metaData.optionSets, function ( item ) { - build = build.then(function() { - var d = $.Deferred(); - var p = d.promise(); - DAO.store.get('optionSets', item.uid).done(function(obj) { - if(!obj || obj.optionSet.version !== item.v) { - promise = promise.then( makeOptionSetRequest(item.uid) ); - } - - d.resolve(); - }); - - return p; - }); - } ); - - if ( metaData.usernames ) { - promise = promise.then( makeUsernameRequest() ); - } - - build.done(function() { - def.resolve(); - - promise = promise.done( function () { - mainDef.resolve( metaData ); - } ); - }); - - builder.resolve(); - - return mainPromise; -} - -function makeUsernameRequest() { - return function() { - return $.ajax( { - url: 'getUsernames.action', - dataType: 'json', - cache: false - }).done(function( data ) { - var obj = {}; - obj.id = 'usernames'; - obj.usernames = data.usernames; - DAO.store.set( 'usernames', obj ); - }); - } -} - -function makeOptionSetRequest( id ) { - return function() { - return $.ajax({ - url: 'getOptionSet.action', - data: { id: id }, - dataType: 'json', - cache: false - }).done(function(data) { - var obj = {}; - obj.id = id; - obj.optionSet = data.optionSet; - DAO.store.set('optionSets', obj); - }); - } -} - -function updateOfflineEvents() { - var no_offline_template = $( '#no-offline-event-template' ); - var no_offline_template_compiled = _.template( no_offline_template.html() ); - - var offline_template = $( '#offline-event-template' ); - var offline_template_compiled = _.template( offline_template.html() ); - - return DAO.store.getAll( 'dataValues' ).done( function ( arr ) { - var orgUnitId = selection.getSelected(); - var programId = $( '#programId' ).val(); - - var target = $( '#offlineEventList' ); - target.children().remove(); - - if ( arr.length > 0 ) { - var matched = false; - - $.each( arr, function ( idx, item ) { - var event = item.executionDate; - - if ( event.organisationUnitId == orgUnitId && event.programId == programId ) { - event.index = idx + 1; - var html = offline_template_compiled( event ); - target.append( html ); - matched = true; - } - } ); - - if ( !matched ) { - target.append( no_offline_template_compiled() ); - } - } else { - target.append( no_offline_template_compiled() ); - } - } ); -} - -function showOfflineEvents() { - $( "#offlineListDiv table" ).removeClass( 'hidden' ); -} - -function hideOfflineEvents() { - $( "#offlineListDiv table" ).addClass( 'hidden' ); -} - -var haveLocalData = false; - -function checkOfflineData( callback ) { - return DAO.store.getAll( 'dataValues' ).done( function ( arr ) { - haveLocalData = arr.length > 0; - if ( callback && typeof callback == 'function' ) callback( haveLocalData ); - } ); -} - -function uploadOfflineData( event ) { - $.ajax( { - url: 'uploadAnonymousEvent.action', - contentType: 'application/json', - data: JSON.stringify( event ), - cache: false - } ).done( function ( json ) { - if ( json.response === 'success' ) { - DAO.store.remove( 'dataValues', event.id ).done( function () { - updateOfflineEvents(); - searchEvents( eval( getFieldValue( 'listAll' ) ) ); - } ); - } - } ); -} - -function uploadLocalData() { - setHeaderWaitMessage( i18n_uploading_data_notification ); - - DAO.store.getAll( 'dataValues' ).done( function ( arr ) { - if(arr.length == 0) { - setHeaderDelayMessage( i18n_sync_success ); - return; - } - - var deferred = $.Deferred(); - var promise = deferred.promise(); - - $.each(arr, function(idx, item) { - promise = promise.pipe(function () { - uploadOfflineData( item ); - }); - }); - - deferred.done(function() { - setHeaderDelayMessage( i18n_sync_success ); - }); - - deferred.resolve(); - }); -} - -function sync_failed_button() { - var message = i18n_sync_failed - + ' '; - - setHeaderMessage( message ); - - $( '#sync_button' ).bind( 'click', uploadLocalData ); -} - -$( document ).ready( function () { - $.ajaxSetup( { - type: 'POST', - cache: false - } ); - - setHeaderWaitMessage(i18n_please_wait_loading); - - $("#programId").attr('disabled', true); - - $( "#orgUnitTree" ).one( "ouwtLoaded", function () { - var def = $.Deferred(); - var promise = def.promise(); - - promise = promise.then( DAO.store.open ); - promise = promise.then( loadPrograms ); - promise = promise.then( loadProgramStages ); - promise = promise.then( loadOptionSets ); - promise = promise.then( updateOfflineEvents ); - promise = promise.then( checkOfflineData ); - promise.then( function () { - $("#programId").removeAttr('disabled'); - - selection.setListenerFunction( organisationUnitSelected ); - - dhis2.availability.startAvailabilityCheck(); - selection.responseReceived(); - } ); - - def.resolve(); - } ); - - $( document ).bind( 'dhis2.online', function ( event, loggedIn ) { - if ( loggedIn ) { - checkOfflineData(function(localData) { - if ( localData ) { - var message = i18n_need_to_sync_notification - + ' '; - - setHeaderMessage( message ); - - $( '#sync_button' ).bind( 'click', uploadLocalData ); - } else { - setHeaderDelayMessage( i18n_online_notification ); - } - - enableFiltering(); - searchEvents( eval( getFieldValue( 'listAll' ) ) ); - $('#commentInput').removeAttr('disabled'); - $('#commentButton').removeAttr('disabled'); - $('#validateBtn').removeAttr('disabled'); - }); - - hideOfflineEvents(); - } - else { - var form = [ - '
', - '', - '', - '', - '', - '', - '
' - ].join( '' ); - - setHeaderMessage( form ); - ajax_login(); - - showOfflineEvents(); - } - } ); - - $( document ).bind( 'dhis2.offline', function () { - setHeaderMessage( i18n_offline_notification ); - $('#commentInput').attr('disabled', true); - $('#commentInput').attr('disabled', true); - $('#validateBtn').attr('disabled', true); - disableFiltering(); - showOfflineEvents(); - } ); -} ); - -function disableFiltering() { - $('#listDiv').hide(); - $('#filterBtn').attr('disabled', true); - $('#listBtn').attr('disabled', true); - $('#incompleted').attr('disabled', true); - $('#removeBtn').attr('disabled', true); -} - -function enableFiltering() { - var filtering = getFieldValue( 'programStageId' ) != undefined && getFieldValue( 'programStageId' ).length != 0; - - if ( filtering ) { - $( '#filterBtn' ).removeAttr( 'disabled' ); - $( '#listBtn' ).removeAttr( 'disabled' ); - $( '#incompleted' ).removeAttr( 'disabled' ); - $( '#removeBtn' ).removeAttr( 'disabled' ); - } -} - -function ajax_login() -{ - $( '#login_button' ).bind( 'click', function() - { - var username = $( '#username' ).val(); - var password = $( '#password' ).val(); - - $.post( '../dhis-web-commons-security/login.action', { - 'j_username' : username, - 'j_password' : password - } ).success( function() - { - var ret = dhis2.availability.syncCheckAvailability(); - - if ( !ret ) - { - alert( i18n_ajax_login_failed ); - } - } ); - } ); -} - -function organisationUnitSelected( orgUnits, orgUnitNames ) { - showById( 'dataEntryMenu' ); - hideById( 'eventActionMenu' ); - hideById( 'dataEntryInfor' ); - hideById( 'advanced-search' ); - hideById( 'minimized-advanced-search' ); - hideById( 'listDiv' ); - hideById( 'programName' ); - - setFieldValue( "listAll", true ); - setFieldValue( "startDate", '' ); - setFieldValue( "endDate", '' ); - setFieldValue( "programStageId", '' ); - setFieldValue( "programId", '' ); - - $( '#advancedSearchTB [name=searchText]' ).val( '' ); - - setFieldValue( 'orgunitId', orgUnits[0] ); - setFieldValue( 'orgunitName', orgUnitNames[0] ); - hideById( 'listDiv' ); - hideById( 'dataEntryInfor' ); - - DAO.store.getAll( 'programs' ).done( function (arr) { - var programs = []; - - $.each( arr, function ( idx, item ) { - if ( item.programAssociations.indexOf( orgUnits[0] ) != -1 ) { - programs.push( item ); - } - } ); - - updateProgramList( programs ); - } ); - - updateOfflineEvents(); -} - -function updateProgramList( arr ) { - $( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove(); - $( '#advancedSearchTB [id=searchObjectId] option' ).remove(); - clearListById( 'displayInReports' ); - clearListById( 'programId' ); - - $( '#programId' ).append( '' ); - - for ( var i = 0; i < arr.length; i++ ) { - $( '#programId' ).append( - '' ); - } - - disableCriteriaDiv(); - showById( 'selectDiv' ); -} - -function disableCriteriaDiv() { - disable( 'listBtn' ); - disable( 'addBtn' ); - disable( 'filterBtn' ); - disable( 'removeBtn' ); - $( '#criteriaDiv :input' ).each( function ( idx, item ) { - disable( this.id ); - } ); -} - -function enableCriteriaDiv() { - enable( 'listBtn' ); - enable( 'addBtn' ); - enable( 'filterBtn' ); - enable( 'removeBtn' ); - $( '#criteriaDiv :input' ).each( function ( idx, item ) { - enable( this.id ); - } ); -} - -function getDataElements() { - hideById( 'dataEntryInfor' ); - hideById( 'listDiv' ); - $( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove(); - $( '#advancedSearchTB [id=searchObjectId] option' ).remove(); - var programStageId = $( '#programId option:selected' ).attr( 'psid' ); - setFieldValue( 'programStageId', programStageId ); - setInnerHTML( 'reportDateDescriptionField', $( '#programId option:selected' ).attr( 'reportDateDes' ) ); - setInnerHTML( 'reportDateDescriptionField2', $( '#programId option:selected' ).attr( 'reportDateDes' ) ); - - if ( programStageId == '' ) { - removeAllAttributeOption(); - disableCriteriaDiv(); - enable( 'orgunitName' ); - enable( 'programId' ); - hideById( 'listDiv' ); - setFieldValue( 'searchText' ); - updateOfflineEvents(); - return; - } - - $.getJSON( "getProgramStageDataElementList.action", { - programStageId: programStageId - }, function ( json ) { - $( '#advancedSearchTB [name=searchText]' ).val( '' ); - $( '.stage-object-selected' ).attr( 'psid', $( '#programId option:selected' ).attr( "psid" ) ); - - clearListById( 'searchObjectId' ); - clearListById( 'displayInReports' ); - - $('[name=searchObjectId]').append(''); - - $.each(json.programStageDataElements, function() { - $('[name=searchObjectId]').append(''); - - if( this.displayInReports == 'true' ) { - $('#displayInReports').append(''); - } - }); - - enableCriteriaDiv(); - validateSearchEvents( true ); - } ).fail(function() { - enable( 'addBtn' ); - }); - - updateOfflineEvents(); -} - -function dataElementOnChange( this_ ) { - var container = $(this_).parent().parent().attr('id'); - var element = $('#' + container + ' [id=searchText]'); - var valueType = $('#' + container + ' [id=searchObjectId] option:selected').attr('type'); - - if( valueType == 'date' ) { - element.replaceWith(getDateField(container)); - datePickerValid('searchText_' + container); - } - else { - $('#searchText_' + container).datepicker("destroy"); - $('#' + container + ' [id=dateOperator]').replaceWith(""); - - if( valueType == 'bool' ) { - element.replaceWith(getTrueFalseBox()); - } - else if( valueType == 'optionset' ) { - element.replaceWith(searchTextBox); - autocompletedFilterField(container + " [id=searchText]", $(this_).find("option:selected").attr('uid')); - } - else if( valueType == 'username' ) { - autocompletedUsernameField($(this_).attr('id')); - } - else { - element.replaceWith(searchTextBox); - } - } -} - -function autocompletedFilterField( idField, searchObjectId ) { - var input = $( "#" + idField ); - input.css( "width", "237px" ); - input.autocomplete( { - delay: 0, - minLength: 0, - source: function ( request, response ) { - $.ajax( { - url: "getOptions.action?id=" + searchObjectId + "&query=" + input.val(), - dataType: "json", - cache: false, - success: function ( data ) { - response( $.map( data.options, function ( item ) { - return { - label: item.o, - id: item.o - }; - } ) ); - } - } ); - }, - select: function ( event, ui ) { - input.val( ui.item.value ); - input.autocomplete( "close" ); - } - } ) - .addClass( "ui-widget" ); - - input.data( "autocomplete" )._renderItem = function ( ul, item ) { - return $( "
  • " ) - .data( "item.autocomplete", item ) - .append( "" + item.label + "" ) - .appendTo( ul ); - }; - - var wrapper = this.wrapper = $( "" ) - .addClass( "ui-combobox" ) - .insertAfter( input ); - - var button = $( "" ) - .attr( "tabIndex", -1 ) - .attr( "title", i18n_show_all_items ) - .appendTo( wrapper ) - .button( { - icons: { - primary: "ui-icon-triangle-1-s" - }, - text: false - } ) - .addClass( 'small-button' ) - .click( function () { - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); - return; - } - $( this ).blur(); - input.autocomplete( "search", "" ); - input.focus(); - } ); -} - -function autocompletedUsernameField( idField ) { - var input = $( "#" + idField ); - input.parent().width( input.width() + 200 ); - var dataElementId = input.attr( 'id' ).split( '-' )[1]; - - input.autocomplete( { - delay: 0, - minLength: 0, - source: function ( request, response ) { - $.ajax( { - url: "getUsernameList.action?query=" + input.val(), - dataType: "json", - cache: false, - success: function ( data ) { - response( $.map( data.usernames, function ( item ) { - return { - label: item.u, - id: item.u - }; - } ) ); - } - } ); - }, - select: function ( event, ui ) { - var fieldValue = ui.item.value; - - if ( !dhis2.trigger.invoke( "caseentry-value-selected", [dataElementId, fieldValue] ) ) { - input.val( "" ); - return false; - } - - input.val( fieldValue ); - if ( !unSave ) { - saveVal( dataElementId ); - } - input.autocomplete( "close" ); - }, - change: function ( event, ui ) { - if ( !ui.item ) { - var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $( this ).val() ) + "$", "i" ), - valid = false; - if ( !valid ) { - $( this ).val( "" ); - if ( !unSave ) - saveVal( dataElementId ); - input.data( "autocomplete" ).term = ""; - return false; - } - } - } - } ) - .addClass( "ui-widget" ); - - input.data( "autocomplete" )._renderItem = function ( ul, item ) { - return $( "
  • " ) - .data( "item.autocomplete", item ) - .append( "
    " + item.label + "" ) - .appendTo( ul ); - }; - - var wrapper = this.wrapper = $( "" ) - .addClass( "ui-combobox" ) - .insertAfter( input ); - - var button = $( "" ) - .attr( "tabIndex", -1 ) - .attr( "title", i18n_show_all_items ) - .appendTo( wrapper ) - .button( { - icons: { - primary: "ui-icon-triangle-1-s" - }, - text: false - } ) - .addClass( 'small-button' ) - .click( function () { - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); - return; - } - $( this ).blur(); - input.autocomplete( "search", "" ); - input.focus(); - } ); -} - -function removeAllAttributeOption() { - $( '#advancedSearchTB tbody tr' ).each( function ( i, item ) { - if ( i > 0 ) { - $( item ).remove(); - } - } ) -} - -function validateSearchEvents( listAll ) { - listAll = eval( listAll ); - setFieldValue( 'listAll', listAll ); - - var flag = true; - if ( !listAll ) { - if ( getFieldValue( 'startDate' ) == "" || getFieldValue( 'endDate' ) == "" ) { - showWarningMessage( i18n_specify_a_date ); - flag = false; - } - - if ( flag && !listAll && $( '#filterBtn' ).attr( "disabled" ) == "disabled" ) { - $( '#advancedSearchTB tr' ).each( function ( index, row ) { - if ( index > 1 ) { - $( row ).find( ':input' ).each( function ( idx, item ) { - var input = $( item ); - if ( input.attr( 'type' ) != 'button' && idx == 0 && input.val() == '' ) { - showWarningMessage( i18n_specify_data_element ); - flag = false; - } - } ) - } - } ); - } - } - - if ( flag ) { - searchEvents( listAll ); - } -} - -function searchEvents( listAll ) { - var search = getFieldValue( 'programStageId' ) != undefined && getFieldValue( 'programStageId' ).length != 0; - - if ( !search ) { - return; - } - - hideById( 'dataEntryInfor' ); - hideById( 'listDiv' ); - - var params = ''; - $( '#displayInReports option' ).each( function ( i, item ) { - var input = $( item ); - params += '&filterValues=de_' + input.val() + '_false_'; - } ); - - if ( listAll ) { - params += '&startDate='; - params += '&endDate='; - } - else { - var value = ''; - var searchingValue = ''; - params += '&startDate=' + getFieldValue( 'startDate' ); - params += '&endDate=' + getFieldValue( 'endDate' ); - if ( byId( "incompleted" ).checked ) { - params += '&useCompletedEvents=false'; - } - $( '#advancedSearchTB tr' ).each( function ( index, row ) { - if ( index > 1 ) { - $( row ).find( ':input' ).each( function ( idx, item ) { - var input = $( item ); - if ( input.attr( 'type' ) != 'button' ) { - if ( idx == 0 && input.val() != '' ) { - searchingValue = 'de_' + input.val() + '_false_'; - } - else if ( input.val() != '' ) { - value += $.trim( input.val() ).toLowerCase(); - } - } - } ); - - if ( value != '' ) { - searchingValue += getValueFormula( value ); - params += '&filterValues=' + searchingValue; - } - searchingValue = ''; - value = ''; - } - } ) - } - - params += '&facilityLB=selected'; - params += '&orgunitIds=' + getFieldValue( 'orgunitId' ); - params += '&programStageId=' + $( '#programId option:selected' ).attr( 'psid' ); - params += '&userOrganisationUnit=false'; - params += '&userOrganisationUnitChildren=false'; - - contentDiv = 'listDiv'; - showLoader(); - - $.ajax( { - type: "POST", - url: 'searchEvents.action', - data: params, - dataType: 'text', - cache: false, - success: function ( data ) { - if ( data.indexOf( "|>=|<|<=|=|!=]+[ ]*/ ); - - if( value.indexOf("'") == -1 ) { - if( flag == null ) { - value = "='" + value + "'"; - } - else { - value = value.replace(flag, flag + "'"); - value += "'"; - } - } - else { - if( flag == null ) { - value = "=" + value; - } - } - - return value; -} - -function removeEvent( programStageId ) { - DAO.store.get('dataValues', programStageId).done(function(obj) { - if(obj) { - if( confirm(i18n_comfirm_delete_event) ) { - DAO.store.remove('dataValues', programStageId).always(function() { - updateOfflineEvents(); - // needed, seemed that from time-to-time the events are updated too early, could be idb related - setTimeout(updateOfflineEvents, 100); - }); - } - } else { - removeItem( programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' ); - } - }); -} - -function showUpdateEvent( programStageInstanceId ) { - hideById( 'dataEntryMenu' ); - showById( 'eventActionMenu' ); - $( "[name=eventActionLink]" ).hide(); - hideById( 'selectDiv' ); - hideById( 'searchDiv' ); - hideById( 'listDiv' ); - hideById( 'offlineListDiv' ); - setFieldValue( 'programStageInstanceId', programStageInstanceId ); - setInnerHTML( 'dataEntryFormDiv', '' ); - showLoader(); - - service.displayProgramStage( getFieldValue( 'programStageId' ), programStageInstanceId, getFieldValue( 'orgunitId' ) ); - jQuery('.stage-object-selected').attr('id', 'ps_' + programStageInstanceId); -} - -function backEventList() { - showById( 'dataEntryMenu' ); - hideById( 'eventActionMenu' ); - hideById( 'dataEntryInfor' ); - hideById( 'programName' ); - showById( 'selectDiv' ); - showById( 'searchDiv' ); - showById( 'listDiv' ); - showById( 'offlineListDiv' ); - - updateOfflineEvents(); - searchEvents( eval( getFieldValue( 'listAll' ) ) ); -} - -function showAddEventForm( isCreateEvent ) { - showById( 'eventActionMenu' ); - $( "[name=eventActionLink]" ).hide(); - hideById( 'dataEntryMenu' ); - setInnerHTML( 'dataEntryFormDiv', '' ); - hideById( 'selectDiv' ); - hideById( 'searchDiv' ); - hideById( 'listDiv' ); - hideById( 'offlineListDiv' ); - showById( 'programName' ); - hideById( 'actionDiv' ); - showById( 'dataEntryInfor' ); - setFieldValue( 'programStageInstanceId', '0' ); - setInnerHTML( 'programName', $( '#programId option:selected' ).text() ); - setInnerHTML( 'orgunitNameInfor', getFieldValue("orgunitName")); - if( isCreateEvent != undefined ){ - addNewEvent(); - } -} - -function addNewEvent() { - var programStageInstanceId = getFieldValue( 'programStageInstanceId' ); - var programId = $( '#programId option:selected' ).val(); - var executionDate = getFieldValue( 'executionDate' ); - var orgunitId = getFieldValue( 'orgunitId' ); - - $( "#executionDate" ).css( 'background-color', SAVING_COLOR ); - - service.saveExecutionDate( programId, programStageInstanceId, executionDate, orgunitId ); -} - -function completedAndAddNewEvent() { - doComplete( true ); -} - -function removeEmptyEvents() { - var result = window.confirm( i18n_confirm_remove_empty_events ); - - if ( result ) { - $.getJSON( "removeEmptyEvents.action", - { - programStageId: $( '#selectDiv [id=programId] option:selected' ).attr( 'psid' ) - }, - function ( json ) { - if ( json.response == 'success' ) { - showSuccessMessage( i18n_remove_empty_events_success ); - validateSearchEvents( true ) - } - } ); - } -} - -function removeCurrentEvent() { - var programStageInstanceId = getFieldValue( 'programStageInstanceId' ); - - DAO.store.get('dataValues', programStageInstanceId).done(function(obj) { - if(obj) { - if( confirm(i18n_comfirm_delete_event) ) { - DAO.store.remove('dataValues', programStageInstanceId).always(function() { - setTimeout(backEventList, 200); - }); - } - } else { - removeCurrentEventFromServer(); - } - }); -} - -function removeCurrentEventFromServer() { - var result = window.confirm( i18n_comfirm_delete_event ); - - if ( result ) { - $.postJSON( "removeCurrentEncounter.action", { - "id": getFieldValue( 'programStageInstanceId' ) - }, - function ( json ) { - if ( json.response == "success" ) { - backEventList(); - } - else if ( json.response == "error" ) { - showWarningMessage( json.message ); - } - } ); - } -} - -function showFilterForm() { - showById( 'advanced-search' ); - hideById( 'minimized-advanced-search' ); - disable( 'filterBtn' ); - setFieldValue( 'listAll', false ); -} - -function removeAllOption() { - enable( 'filterBtn' ); - - $( '#advancedSearchTB tr' ).each( function ( idx ) { - if( idx > 2 ) { - $(this).remove(); - } - else if( idx == 2 ) { - $(this).find(':input').each(function( idx, item ) { - var input = $(item); - if( input.attr('type') != 'button' ) { - input.val(''); - } - }); - } - } ); - - $( '#searchObjectId' ).val( "" ); - $( '#searchText' ).val( "" ); - searchEvents( eval( getFieldValue( "listAll" ) ) ); -} - -function ajaxExecutionDate( programId, programStageInstanceId, executionDate, organisationUnitId ) { - return $.ajax( { - url: 'saveExecutionDate.action', - data: createExecutionDate( programId, programStageInstanceId, executionDate, organisationUnitId ), - type: 'POST', - dataType: 'json', - cache: false - } ); -} - -// execution date module -var service = (function () { - return { - saveExecutionDate: function( programId, programStageInstanceId, executionDate, organisationUnitId ) { - ajaxExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId).done(function ( json ) { - if ( json.response == 'success' ) { - $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR ); - setFieldValue( 'programStageInstanceId', json.message ); - jQuery('.stage-object-selected').attr('id', json.message ); - showUpdateEvent( json.message ); - } - else { - $( "#executionDate" ).css( 'background-color', ERROR_COLOR ); - showWarningMessage( json.message ); - } - } ).fail( function () { - if(programStageInstanceId == 0) { - DAO.store.getKeys( 'dataValues' ).done( function ( keys ) { - var i = 100; - - for(; i<10000; i++) { - if( keys.indexOf("local" + i) == -1 ) break; - } - - programStageInstanceId = "local"+i; - - var data = {}; - data.id = programStageInstanceId; - data.executionDate = createExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId); - data.executionDate.completed = 'false'; - - this.set( 'dataValues', data).done(function() { - setFieldValue( 'programStageInstanceId', programStageInstanceId ); - $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR ); - showUpdateEvent( programStageInstanceId ); - }); - }); - } else { - // if we have a programStageInstanceId, just reuse that one - setFieldValue( 'programStageInstanceId', programStageInstanceId ); - $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR ); - showUpdateEvent( programStageInstanceId ); - } - } ); - }, - - displayProgramStage: function( programStageId, programStageInstanceId, organisationUnitId ) { - loadProgramStage( programStageId, programStageInstanceId, organisationUnitId, function ( data ) { - $( '#dataEntryFormDiv' ).html( data ); - updateDataForm(); - },function () { - $( '#dataEntryFormDiv' ).html( "
    Unable to load form.
    " ); - hideById( 'loaderDiv' ); - } ); - } - } -})(); - -function updateDataForm() { - $( '#inputCriteriaDiv' ).remove(); - showById( 'programName' ); - showById( 'actionDiv' ); - var programName = $( '#programId option:selected' ).text(); - var programStageId = $( '#programId option:selected' ).attr( 'psid' ); - $( '.stage-object-selected' ).attr( 'psid', programStageId ); - setInnerHTML( 'programName', programName ); - $('#executionDate').css('width',430); - $('#executionDate').css('margin-right',34); - - if ( getFieldValue( 'completed' ) == 'true' ) { - disable( "completeBtn" ); - enable( "uncompleteBtn" ); - } - else { - enable( "completeBtn" ); - disable( "uncompleteBtn" ); - } - - hideById( 'loaderDiv' ); - showById( 'dataEntryInfor' ); - showById( 'entryFormContainer' ); - - $( "#entryForm :input" ).each( function () { - if ( ( $( this ).attr( 'options' ) != null && $( this ).attr( 'options' ) == 'true' ) - || ( $( this ).attr( 'username' ) != null && $( this ).attr( 'username' ) == 'true' ) ) { - var input = $( this ); - input.parent().width( input.width() + 200 ); - } - } ); -} - -function createExecutionDate( programId, programStageInstanceId, executionDate, organisationUnitId ) { - var data = {}; - - if(programId) - data.programId = programId; - - if(programStageInstanceId) - data.programStageInstanceId = programStageInstanceId; - - if(executionDate) - data.executionDate = executionDate; - - if(organisationUnitId) { - data.organisationUnitId = organisationUnitId; - data.organisationUnit = organisationUnits[organisationUnitId].n; - } - - return data; -} - -function createProgramStage( programStageId, programStageInstanceId, organisationUnitId ) { - var data = {}; - - if(programStageId) - data.programStageId = programStageId; - - if(programStageInstanceId) - data.programStageInstanceId = programStageInstanceId; - - if(organisationUnitId) - data.organisationUnitId = organisationUnitId; - - return data; -} - -function loadProgramStage( programStageId, programStageInstanceId, organisationUnitId, success, fail ) { - var data = createProgramStage( programStageId, programStageInstanceId, organisationUnitId ); - - if( programStageId === undefined ) { - programStageId = $('#programId option:selected').attr('psid'); - } - - DAO.store.get('programStages', programStageId ).done(function(obj) { - if(success) success(obj.form); - } ).fail(function() { - $.ajax( { - url: 'dataentryform.action', - data: data, - dataType: 'html', - cache: false - } ).done(function(data) { - if(success) success(data); - } ).fail(function() { - if(fail) fail(); - }); - }); -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/menu.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/menu.vm 2014-04-11 06:46:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/menu.vm 2014-05-07 10:09:11 +0000 @@ -22,9 +22,6 @@ #if( $auth.hasAccess( "dhis-web-caseentry", "singleEventSelect" ) )
  • $i18n.getString( "single_event_with_registration" )
  • #end - #if( $auth.hasAccess( "dhis-web-caseentry", "anonymousRegistration" ) ) -
  • $i18n.getString( "anonymous_events" )
  • - #end #if( $auth.hasAccess( "dhis-web-caseentry", "reportSelect" )