dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29942
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15190: ProgramStageInstanceService, removed methods for searching events. Removed single event without r...
------------------------------------------------------------
revno: 15190
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-05-07 12:09:11 +0200
message:
ProgramStageInstanceService, removed methods for searching events. Removed single event without registration feature from dhis-web-caseentry module. Replaced by event capture app.
removed:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java
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/webapp/dhis-web-caseentry/anonymousRegistration.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
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/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
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/menu.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<TabularEventColumn> columns,
- Collection<Integer> organisationUnits, Date startDate, Date endDate, Boolean completed, Integer min,
- Integer max, I18n i18n );
-
- int searchEventsCount( ProgramStage programStage, List<TabularEventColumn> columns,
- Collection<Integer> 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<Integer> 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<Integer> orgUnits, List<TabularEventColumn> 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<TabularEventColumn> columns,
- Collection<Integer> 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<TabularEventColumn> columns,
- Collection<Integer> 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<TabularEventColumn> columns,
- Collection<Integer> 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<Integer> orgUnits, List<TabularEventColumn> 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<String> deKeys = new HashSet<String>();
- 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<TabularEventColumn> columns,
- Collection<Integer> 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<TabularEventColumn> columns,
- Collection<Integer> orgUnits, Date startDate, Date endDate, Boolean completed, Integer min, Integer max )
- {
- Set<String> deKeys = new HashSet<String>();
- 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 @@
<property name="sessionFactory" ref="sessionFactory" />
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="statementBuilder" ref="statementBuilder" />
</bean>
<bean id="org.hisp.dhis.program.ProgramInstanceStore"
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java 1970-01-01 00:00:00 +0000
@@ -1,125 +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.Collections;
-import java.util.List;
-
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- *
- * @version $Id: LoadAnonymousProgramsAction.java Dec 14, 2011 9:12:34 AM $
- */
-public class LoadAnonymousProgramsAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private OrganisationUnitSelectionManager selectionManager;
-
- public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
- {
- this.selectionManager = selectionManager;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- private ProgramService programService;
-
- public void setProgramService( ProgramService programService )
- {
- this.programService = programService;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private OrganisationUnit orgunit;
-
- public OrganisationUnit getOrgunit()
- {
- return orgunit;
- }
-
- private List<Program> programs;
-
- public List<Program> getPrograms()
- {
- return programs;
- }
-
- private List<OrganisationUnitLevel> levels;
-
- public List<OrganisationUnitLevel> getLevels()
- {
- return levels;
- }
-
- // -------------------------------------------------------------------------
- // Implementation Action
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- orgunit = selectionManager.getSelectedOrganisationUnit();
-
- if ( orgunit != null )
- {
- programs = new ArrayList<Program>( 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<ProgramStageInstance>
-{
- // -------------------------------------------------------------------------
- // 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<TrackedEntityAttribute> attributes = new ArrayList<TrackedEntityAttribute>();
-
- public List<TrackedEntityAttribute> getAttributes()
- {
- return attributes;
- }
-
- private Collection<String> orgunitIds = new HashSet<String>();
-
- public void setOrgunitIds( Collection<String> 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<String> values = new ArrayList<String>();
-
- public List<String> getValues()
- {
- return values;
- }
-
- private List<String> filterValues = new ArrayList<String>();
-
- public void setFilterValues( List<String> 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<DataElement> dataElements = new ArrayList<DataElement>();
-
- public List<DataElement> 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<String> valueTypes = new ArrayList<String>();
-
- public List<String> getValueTypes()
- {
- return valueTypes;
- }
-
- private Map<Integer, List<String>> mapSuggestedValues = new HashMap<Integer, List<String>>();
-
- public Map<Integer, List<String>> 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<OrganisationUnit> ous = new HashSet<OrganisationUnit>( organisationUnitService.getOrganisationUnitsByUid( orgunitIds ) );
- Set<Integer> orgUnitIds = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class, ous ) );
-
- if ( userOrganisationUnit || userOrganisationUnitChildren )
- {
- Collection<OrganisationUnit> userOrgunits = currentUserService.getCurrentUser().getOrganisationUnits();
- orgUnitIds = new HashSet<Integer>();
-
- 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<Integer> organisationUnits = new HashSet<Integer>();
-
- 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<TabularEventColumn> 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<TabularEventColumn> getTableColumns()
- {
- List<TabularEventColumn> columns = new ArrayList<TabularEventColumn>();
-
- 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<String> getSuggestedDataElementValues( DataElement dataElement )
- {
- List<String> values = new ArrayList<String>();
- 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 @@
</bean>
<bean
- id="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
- class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
- scope="prototype">
- <property name="selectionManager"
- ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
- <property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- </bean>
-
- <bean
id="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction"
class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction"
scope="prototype">
@@ -687,18 +676,6 @@
scope="prototype">
</bean>
- <bean id="org.hisp.dhis.caseentry.action.caseentry.SearchEventsAction"
- class="org.hisp.dhis.caseentry.action.caseentry.SearchEventsAction"
- scope="prototype">
- <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
- <property name="programStageInstanceService"
- ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- </bean>
-
<!-- Reminder -->
<bean
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2014-04-17 16:00:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 1970-01-01 00:00:00 +0000
@@ -1,252 +0,0 @@
-<script type="text/javascript">
- jQuery( document ).ready( function () {
- datePickerInRange( 'startDate', 'endDate', true, true );
- disableCriteriaDiv();
- } );
-</script>
-
-<h3>$i18n.getString( "anonymous_events_management" ) #openHelp('single_event_without_registration')</h3>
-<h3 id='orgunitNameInfor' name='orgunitNameInfor'></h3>
-<h4 id='programName' name='programName'>fasdfadfa</h4>
-
-<input type='hidden' id='orgunitId' name='orgunitId' value='$orgunit.id'>
-<input type='hidden' id='programStageInstanceId' name='programStageInstanceId' value='0'>
-<input type='hidden' id='programStageId' name='programStageId' class='stage-object-selected'>
-<input type='hidden' id='listAll' name='listAll' value="true">
-
-<select multiple id='displayInReports' name='displayInReports' class='hidden'></select>
-
-<div>
- <div id='selectDiv'>
- <table>
- <tr>
- <td><label>$i18n.getString( "registering_unit" )</label></td>
- <td><input type="text" id='orgunitName' name='orgunitName' #if( $orgunit ) value="$encoder.htmlEncode( $orgunit.name )" #else value="[$i18n.getString( 'please_select_village' )]" #end disabled /></td>
- </tr>
- <tr>
- <td>
- $i18n.getString("program") <em title="$i18n.getString( "required" )" class="required">*</em></label>
- </td>
- <td>
- <select type="text" id="programId" name="programId" onchange='getDataElements();'>
- <option value="" psid="" reportDateDes="$i18n.getString('report_date')">[$i18n.getString("please_select")]</option>
- #foreach( $program in $programs )
- #foreach( $programStage in $program.programStages )
- <option value='$program.id' psid='$programStage.id' reportDateDes="$programStage.reportDateDescription">$program.displayName</option>
- #end
- #end
- </select>
- <input type='hidden' class='stage-object-selected hidden' />
- </td>
- <td colspan="2" style="padding-left: 20px;">
- <input type="button" class='large-button' id='addBtn' style="width: 145px;" value='$i18n.getString( "add_new" )' onclick="showAddEventForm();" />
- <input type="button" id='removeBtn' value='$i18n.getString( "remove_empty_events" )' onclick="removeEmptyEvents();" style="width: 145px;" />
- </td>
- </tr>
- <tr><td style="padding-top: 10px;"></td></tr>
- <tr>
- <td><label>$i18n.getString('from')</label></td>
- <td>
- <input type="text" id='startDate' name='startDate' style="width:260px;" />
- </td>
- <td style="padding-left: 20px;">
- <input type="checkbox" id="incompleted" name="incompleted" value="true">$i18n.getString("incomplete")</input>
- </td>
- </tr>
- <tr>
- <td><label>$i18n.getString('to')</label></td>
- <td>
- <input type="text" id='endDate' name='endDate' style="width:260px;" />
- </td>
- <td style="padding-left: 20px;">
- <input type="button" class='large-button' style="width: 145px;" id='filterBtn' name="filterBtn" value='$i18n.getString( "show_filter" )' onclick="showFilterForm();" />
- <input type="button" class='large-button' style="width: 145px;" id='listBtn' value="$i18n.getString( 'search' )" onclick="validateSearchEvents(false);" />
- </td>
- </tr>
- <tr><td> </td></tr>
- <tr id='minimized-advanced-search' class="hidden">
- <td align='right' colspan='5' height="50px">
- $i18n.getString('you_have_active_filters')
- <input type="button" class='normal-button' value="$i18n.getString('show_all')" onclick='showFilterForm()'>
- <input type="button" class='normal-button' value="$i18n.getString('clear_all')" onclick='removeAllOption()'>
- </td>
- </tr>
- </table>
- <table id='advanced-search' class='hidden advanced-search'>
- <col/>
- <col/>
- <col/>
- <col width="180"/>
- <tr class="hidden">
- <td id='searchingAttributeIdTD'>
- <select id="searchObjectId" name="searchObjectId" onchange='dataElementOnChange(this);'></select>
- </td>
- </tr>
- <tbody id='advancedSearchTB'>
- <tr><td></td></tr>
- <tr>
- <td></td>
- <td></td>
- <tr/>
-
- <tr id='advSearchBox0'>
- <td>
- <select id="searchObjectId" name="searchObjectId" onchange='dataElementOnChange(this);'></select>
- </td>
- <td>
- <input type="text" id="searchText" name="searchText" value="$!searchText">
- <input type="button" class='normal-button' name="clearSearchBtn" value='$i18n.getString( "clear" )' onclick="removeAttributeOption('advSearchBox0');" disabled>
- </td>
- </tr>
-
- </tbody>
- <tfoot>
- <tr>
- <td colspan="2">
- <input type="button" class='normal-button' id='addSearchOptionBtn' name='addSearchOptionBtn' value="$i18n.getString('add')" onclick='addAttributeOption()' />
- <input type="button" class='normal-button' id='clearAllBtn' name='clearAllBtnaddSearchOptionBtn' value="$i18n.getString('clear_all')" onclick='removeAllOption()' />
- </td>
- </tr>
- </tfoot>
- </table>
- </div>
-</div>
-
-<script id="offline-event-template" type="text/template">
- <tr id="tr<%= programStageInstanceId %>" class="listRow">
- <td><%= index %></td>
- <td><%= executionDate %></td>
-
- <td align="right" style="padding-right:20px;">
- <% if( !completed ) { %>
- <span class="incomplete-record" title="Incomplete"> ! </span>
- <% } %>
- <a href="javascript:showUpdateEvent( '<%= programStageInstanceId %>' )" title="Data entry"><img src="images/data_entry.png" alt="Data entry"></a>
- <a href="javascript:removeEvent( '<%= programStageInstanceId %>' )" title="Remove"><img src="../images/delete.png" alt="Remove"></a>
- </td>
- </tr>
-</script>
-
-<script id="no-offline-event-template" type="text/template">
- <tr class="listRow">
- <td colspan="3">No offline events</td>
- </tr>
-</script>
-
-<div id='offlineListDiv'>
- <table class="listTable hidden">
- <thead>
- <tr>
- <th colspan="4">Offline Events</th>
- </tr>
- </thead>
- <thead>
- <tr>
- <th>#</th>
- <th>Report date</th>
- <th style="width:100px">Operations</th>
- </tr>
- </thead>
-
- <tbody id="offlineEventList">
- </tbody>
- </table>
-</div>
-
-<div id='listDiv'></div>
-
-<div id='dataEntryInfor' class='hidden'>
- <table style="width:600px; margin-bottom: 0;" class="listTable">
- <tr>
- <th style='width:220px' colspan='2'><span id="reportDateDescriptionField2">$i18n.getString( "report_date" )</span> <em title="$i18n.getString( "required" )" class="required">*</em> </th>
- <th colspan="2"><input type="text" id="executionDate" name="executionDate" onchange="addNewEvent();" style="padding-left: 2px; margin-left:6px;width:300px;" ></th>
- <script type="text/javascript">
- datePickerValid( 'executionDate', false );
- </script>
- </tr>
- </table>
- <div id='dataEntryFormDiv'></div>
-
- <div id='actionDiv' class="page inputCriteria" style="width:700px;height:29px;">
- <input type="button" id="completeAndNewBtn" onclick="completedAndAddNewEvent();" value="$i18n.getString('complete_and_add_new_event')" style="width:160px;">
- <input type="button" id="completeBtn" onclick="doComplete()" value="$i18n.getString('complete')">
- <input type="button" id="uncompleteBtn" onclick="doUnComplete()" value="$i18n.getString('incomplete')">
- <input type="button" id="validateBtn" value="$i18n.getString('run_validation')" onclick="javascript: runValidation();">
- <input type="button" id="completeBtn" onclick="removeCurrentEvent();" value="$i18n.getString('remove')">
- </div>
-</div>
-
-#parse( "dhis-web-commons/loader/loader.vm" )
-
-<script>
- var i18n_please_select = '$encoder.jsEscape( $i18n.getString( "please_select" ) , "'")';
-
- var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
- var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
- var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
- var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
- var i18n_value_must_zero_or_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_zero_or_positive_integer" ) , "'")';
- var i18n_value_must_unit_interval = '$encoder.jsEscape( $i18n.getString( "value_must_unit_interval" ) , "'")';
- var i18n_invalid_date = '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n "
- + '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '"
- + dateFormat.replace('yy', 'yyyy') + " '" ;
- var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
- var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
- var i18n_searching_tracked_entity_instance_failed = '$encoder.jsEscape( $i18n.getString( "searching_tracked_entity_instance_failed" ) , "'")';
- var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
- var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
- var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
- var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
-
- var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
- var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
- var i18n_specify_data_element = '$encoder.jsEscape( $i18n.getString( "specify_data_element" ) , "'")';
- var i18n_comfirm_delete_event = '$encoder.jsEscape( $i18n.getString( "comfirm_delete_event" ) , "'")';
- var i18n_delete_event_success = '$encoder.jsEscape( $i18n.getString( "delete_event_success" ) , "'")';
- var i18n_report_date = '$encoder.jsEscape( $i18n.getString( "report_date" ) , "'")';
- var i18n_search_events_by_dataelements = '$encoder.jsEscape( $i18n.getString( "search_events_by_dataelements" ) , "'")';
- var i18n_list_all_events = '$encoder.jsEscape( $i18n.getString( "list_all_events" ) , "'")';
- var i18n_no_compulsary_data_elements = '$encoder.jsEscape( $i18n.getString( "no_compulsary_data_elements" ) , "'")';
- var i18n_remove_empty_events_success = '$encoder.jsEscape( $i18n.getString( "remove_empty_events_success" ) , "'")';
- var i18n_confirm_remove_empty_events = '$encoder.jsEscape( $i18n.getString( "confirm_remove_empty_events" ) , "'")';
- var i18n_report_date = '$encoder.jsEscape( $i18n.getString( "report_date" ) , "'")';
-
- var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
- var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
- var i18n_specify_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_search_criteria" ) , "'")';
- var i18n_add_filter = '$encoder.jsEscape( $i18n.getString( "add_filter" ) , "'")';
- var i18n_clear_filter = '$encoder.jsEscape( $i18n.getString( "clear_filter" ) , "'")';
- var i18n_specify_a_date = '$encoder.jsEscape( $i18n.getString( "specify_a_date" ) , "'")';
- var i18n_clear = '$encoder.jsEscape( $i18n.getString( "clear" ) , "'")';
- var i18n_insert_a_report_date = '$encoder.jsEscape( $i18n.getString( "insert_a_report_date" ) , "'")';
- var i18n_comment_added = '$encoder.jsEscape( $i18n.getString( "comment_added" ) , "'")';
-
- var i18n_need_to_sync_notification = '$encoder.jsEscape( $i18n.getString( "need_to_sync_notification" ) , "'")';
- var i18n_sync_now = '$encoder.jsEscape( $i18n.getString( "sync_now" ) , "'")';
- var i18n_sync_success = '$encoder.jsEscape( $i18n.getString( "sync_success" ) , "'")';
- var i18n_sync_failed = '$encoder.jsEscape( $i18n.getString( "sync_failed" ) , "'")';
- var i18n_uploading_data_notification = '$encoder.jsEscape( $i18n.getString( "uploading_data_notification" ) , "'")';
- var i18n_incomplete_confirm_message = '$encoder.jsEscape( $i18n.getString( "incomplete_confirm_message" ) , "'")';
- var i18n_ajax_login_failed = '$encoder.jsEscape( $i18n.getString( "ajax_login_failed" ) , "'")';
- var i18n_online_notification = '$encoder.jsEscape( $i18n.getString( "online_notification" ) , "'")';
- var i18n_offline_notification = '$encoder.jsEscape( $i18n.getString( "offline_notification" ) , "'")';
- var i18n_operation_not_available_offline = '$encoder.jsEscape( $i18n.getString( "operation_not_available_offline" ) , "'")';
- var i18n_please_wait_loading = '$encoder.jsEscape( $i18n.getString( "please_wait_loading" ) , "'")';
- var i18n_complete_program_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_program_confirm_message" ) , "'")';
-
- isAjax = true;
- contentDiv = '';
- var unSave = false;
- var searchTextBox = '<input type="text" id="searchText" name="searchText">';
- setInnerHTML('reportDateDescriptionField', jQuery('#programId option:selected').attr('reportDateDes'));
- setInnerHTML('reportDateDescriptionField2', jQuery('#programId option:selected').attr('reportDateDes'));
-
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y= date.getFullYear();
-
- var startDateSince = jQuery.datepicker.formatDate( dateFormat, new Date(y, m, d-7) ) ;
- setFieldValue('startDate', startDateSince);
-
-</script>
=== 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
- + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
- 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
- + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
- 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 = [
- '<form style="display:inline;">',
- '<label for="username">Username</label>',
- '<input name="username" id="username" type="text" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
- '<label for="password">Password</label>',
- '<input name="password" id="password" type="password" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
- '<button id="login_button" type="button">Login</button>',
- '</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( '<option value="" psid="" reportDateDes="' + i18n_report_date + '">[' + i18n_please_select + ']</option>' );
-
- for ( var i = 0; i < arr.length; i++ ) {
- $( '#programId' ).append(
- '<option value="' + arr[i].id
- + '" puid="' + arr[i].uid
- + '" programType="' + arr[i].type
- + '" psid="' + arr[i].programStages[0].id
- + '" psuid="' + arr[i].programStages[0].uid
- + '" reportDateDes="' + arr[i].programStages[0].reportDateDescription + '">'
- + arr[i].name
- + '</option>' );
- }
-
- 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('<option value="" >[' + i18n_please_select + ']</option>');
-
- $.each(json.programStageDataElements, function() {
- $('[name=searchObjectId]').append('<option value="' + this.id + '" uid="' + this.uid + '" type="' + this.type + '">' + this.name + '</option>');
-
- if( this.displayInReports == 'true' ) {
- $('#displayInReports').append('<option value="' + this.id + '" uid="' + this.uid + '" ></option>');
- }
- });
-
- 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 $( "<li></li>" )
- .data( "item.autocomplete", item )
- .append( "<a>" + item.label + "</a>" )
- .appendTo( ul );
- };
-
- var wrapper = this.wrapper = $( "<span style='width:200px'>" )
- .addClass( "ui-combobox" )
- .insertAfter( input );
-
- var button = $( "<a style='width:20px; margin-bottom:-5px;height:20px;'>" )
- .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 $( "<li></li>" )
- .data( "item.autocomplete", item )
- .append( "<a>" + item.label + "</a>" )
- .appendTo( ul );
- };
-
- var wrapper = this.wrapper = $( "<span style='width:200px'>" )
- .addClass( "ui-combobox" )
- .insertAfter( input );
-
- var button = $( "<a style='width:20px; margin-bottom:-5px;height:20px;'>" )
- .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( "<!DOCTYPE" ) != 0 ) {
- hideById( 'dataEntryInfor' );
- setInnerHTML( 'listDiv', data );
- }
-
- hideLoader();
- showById( 'listDiv' );
- }
- } ).fail(function() {
- hideById( 'dataEntryInfor' );
- hideById( 'listDiv' );
- } ).always(function() {
- var searchInfor = (listAll) ? i18n_list_all_events : i18n_search_events_by_dataelements;
- setInnerHTML( 'searchInforTD', searchInfor );
-
- if ( !listAll && $( '#filterBtn' ).attr( "disabled" ) == "disabled" ) {
- showById( 'minimized-advanced-search' );
- hideById( 'advanced-search' );
- }
- else {
- hideById( 'minimized-advanced-search' );
- hideById( 'advanced-search' );
- showById( 'filterBtn' );
- }
-
- hideLoader();
- });
-}
-
-function getValueFormula( value ) {
- if ( value.indexOf( '"' ) != value.lastIndexOf( '"' ) ) {
- value = value.replace( /"/g, "'" );
- }
-
- var flag = value.match( /[>|>=|<|<=|=|!=]+[ ]*/ );
-
- 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( "<div class='message message-info'>Unable to load form.</div>" );
- 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" ) )
<li><a href="singleEventSelect.action">$i18n.getString( "single_event_with_registration" )</a></li>
#end
- #if( $auth.hasAccess( "dhis-web-caseentry", "anonymousRegistration" ) )
- <li><a href="anonymousRegistration.action">$i18n.getString( "anonymous_events" )</a></li>
- #end
</ul>
#if( $auth.hasAccess( "dhis-web-caseentry", "reportSelect" )