← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18604: Add periodType property for ProgramStage object.

 

------------------------------------------------------------
revno: 18604
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-03-14 14:57:45 +0700
message:
  Add periodType property for ProgramStage object.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.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/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-03-14 07:57:45 +0000
@@ -30,18 +30,24 @@
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer;
+import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer;
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.common.view.WithoutOrganisationUnitsView;
 import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.schema.annotation.PropertyRange;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
 
@@ -118,6 +124,8 @@
     private String reportDateToUse;
 
     private Integer sortOrder;
+    
+    private PeriodType periodType;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -471,6 +479,22 @@
         this.sortOrder = sortOrder;
     }
 
+    @JsonProperty
+    @JsonSerialize( using = JacksonPeriodTypeSerializer.class )
+    @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public PeriodType getPeriodType()
+    {
+        return periodType;
+    }
+
+    public void setPeriodType( PeriodType periodType )
+    {
+        this.periodType = periodType;
+    }
+
+    
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml	2014-10-06 10:11:29 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml	2015-03-14 07:57:45 +0000
@@ -80,6 +80,9 @@
     </list>
     
     <property name="sortOrder" column="sort_order" />
-
+    
+    <many-to-one name="periodType" lazy="false" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
+      foreign-key="fk_programstage_periodtypeid" />
+    
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java	2015-02-16 11:46:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java	2015-03-14 07:57:45 +0000
@@ -38,6 +38,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramIndicator;
 import org.hisp.dhis.program.ProgramIndicatorService;
@@ -72,17 +74,31 @@
     {
         this.selectionTreeManager = selectionTreeManager;
     }
-    
+
     private UserGroupService userGroupService;
-    
+
     public void setUserGroupService( UserGroupService userGroupService )
     {
         this.userGroupService = userGroupService;
     }
-    
+
+    private List<PeriodType> periodTypes = new ArrayList<>();
+
+    public List<PeriodType> getPeriodTypes()
+    {
+        return periodTypes;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
     @Autowired
     private ProgramIndicatorService programIndicatorService;
-    
+
     @Autowired
     private ConstantService constantService;
 
@@ -134,21 +150,21 @@
     {
         this.level = level;
     }
-    
+
     private List<UserGroup> userGroups;
-    
+
     public List<UserGroup> getUserGroups()
     {
         return userGroups;
     }
-    
+
     private List<ProgramIndicator> programIndicators;
 
     public List<ProgramIndicator> getProgramIndicators()
     {
         return programIndicators;
     }
-    
+
     private List<Constant> constants;
 
     public List<Constant> getConstants()
@@ -164,20 +180,22 @@
     public String execute()
         throws Exception
     {
+        periodTypes = periodService.getAllPeriodTypes();
+
         program = programService.getProgram( id );
-        
+
         selectionTreeManager.setSelectedOrganisationUnits( program.getOrganisationUnits() );
-        
+
         userGroups = new ArrayList<>( userGroupService.getAllUserGroups() );
-       
+
         programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) );
 
         Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE );
 
-        constants = new ArrayList<>(constantService.getAllConstants());
-        
+        constants = new ArrayList<>( constantService.getAllConstants() );
+
         Collections.sort( constants, IdentifiableObjectNameComparator.INSTANCE );
-        
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java	2015-03-14 07:57:45 +0000
@@ -35,6 +35,8 @@
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramIndicator;
 import org.hisp.dhis.program.ProgramIndicatorService;
@@ -97,6 +99,13 @@
         this.userGroupService = userGroupService;
     }
 
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
     @Autowired
     private ProgramIndicatorService programIndicatorService;
 
@@ -326,6 +335,13 @@
         this.preGenerateUID = preGenerateUID;
     }
 
+    private String periodTypeName;
+
+    public void setPeriodTypeName( String periodTypeName )
+    {
+        this.periodTypeName = periodTypeName;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -346,7 +362,8 @@
         remindCompleted = (remindCompleted == null) ? false : remindCompleted;
         allowGenerateNextVisit = (allowGenerateNextVisit == null) ? false : allowGenerateNextVisit;
         openAfterEnrollment = (openAfterEnrollment == null) ? false : openAfterEnrollment;
-        preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID;
+        preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID; 
+
 
         ProgramStage programStage = new ProgramStage();
         Program program = programService.getProgram( id );
@@ -360,6 +377,13 @@
         programStage.setMinDaysFromStart( minDaysFromStart );
         programStage.setDisplayGenerateEventBox( displayGenerateEventBox );
         programStage.setValidCompleteOnly( validCompleteOnly );
+        if( periodTypeName != null )
+        {
+
+            PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName );
+            programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) );
+        }
+        
         if ( program.isSingleEvent() )
         {
             programStage.setAutoGenerateEvent( true );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java	2015-03-14 07:57:45 +0000
@@ -32,6 +32,8 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.ProgramIndicator;
 import org.hisp.dhis.program.ProgramIndicatorService;
 import org.hisp.dhis.program.ProgramStage;
@@ -69,6 +71,13 @@
         this.userGroupService = userGroupService;
     }
 
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
     @Autowired
     private ProgramIndicatorService programIndicatorService;
     
@@ -120,6 +129,13 @@
     {
         return programIndicators;
     }
+
+    private List<PeriodType> periodTypes = new ArrayList<>();
+
+    public List<PeriodType> getPeriodTypes()
+    {
+        return periodTypes;
+    }
     
     // -------------------------------------------------------------------------
     // Action implementation
@@ -129,6 +145,8 @@
     public String execute()
         throws Exception
     {
+        periodTypes = periodService.getAllPeriodTypes();
+        
         programStage = programStageService.getProgramStage( id );
 
         programStageDataElements = programStage.getProgramStageDataElements();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java	2015-03-14 07:57:45 +0000
@@ -35,6 +35,8 @@
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.ProgramIndicator;
 import org.hisp.dhis.program.ProgramIndicatorService;
 import org.hisp.dhis.program.ProgramService;
@@ -89,9 +91,19 @@
         this.userGroupService = userGroupService;
     }
 
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
     @Autowired
     private ProgramService programService;
-    
+
+    @Autowired
+    private ProgramIndicatorService programIndicatorService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -320,9 +332,13 @@
         this.preGenerateUID = preGenerateUID;
     }
 
-    @Autowired
-    private ProgramIndicatorService programIndicatorService;
+    private String periodTypeName;
 
+    public void setPeriodTypeName( String periodTypeName )
+    {
+        this.periodTypeName = periodTypeName;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -362,7 +378,13 @@
         programStage.setOpenAfterEnrollment( openAfterEnrollment );
         programStage.setReportDateToUse( reportDateToUse );
         programStage.setPreGenerateUID( preGenerateUID );
-
+        
+        if( periodTypeName != null )
+        {
+            PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName );
+            programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) );
+        }
+        
         if ( programStage.getProgram().isSingleEvent() )
         {
             programStage.setAutoGenerateEvent( true );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2015-02-18 13:48:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2015-03-14 07:57:45 +0000
@@ -200,6 +200,7 @@
 		<property name="selectionTreeManager"
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.trackedentity.action.program.RemoveProgramAction"
@@ -270,6 +271,7 @@
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 
 	<bean
@@ -278,6 +280,7 @@
 		scope="prototype">
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 
 	<bean
@@ -296,6 +299,7 @@
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties	2015-02-24 21:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties	2015-03-14 07:57:45 +0000
@@ -507,4 +507,6 @@
 program_stage_sort_order = Program stage sort order
 sort_order = Sort order
 expression_is_not_well_formed = Expression is not well-formed
-program_variables = Program variables
\ No newline at end of file
+program_variables = Program variables
+custom_standard_interval = Custom standard interval
+period_type = Period type
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm	2014-08-18 14:21:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm	2015-03-14 07:57:45 +0000
@@ -48,10 +48,27 @@
 	</tr>
 	
 	<tr>
+		<td><label for="customStandardInterval">$i18n.getString( "custom_standard_interval" )</label></td>
+		<td><input type="checkbox" id="customStandardInterval" name="customStandardInterval" checked disabled onchange=" customStandardIntervalOnChange()" /></td>
+	</tr>
+	
+	<tr>
 		<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
 		<td><input type="text" id="standardInterval" name="standardInterval" disabled /></td>
 	</tr>
 	
+	<tr>
+		<td><label for="periodTypeName">$i18n.getString( "period_type" )</label></td>
+		<td>
+			<select id="periodTypeName" name="periodTypeName" disabled>
+				<option value="">[$i18n.getString("please_select")]</option>
+				#foreach( $periodType in $periodTypes )
+					  <option value="$periodType.name">$i18n.getString( $periodType.name )</option>
+				#end
+			</select>
+		</td>
+	</tr>
+	
 	#end
 	
 	<tr><th colspan="2">$i18n.getString( "form_details" )</th></tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js	2015-03-14 07:57:45 +0000
@@ -9,6 +9,14 @@
 		{
 			selectAllById('selectedIndicators');
 		
+			var customStandardInterval = byId('customStandardInterval').checked;
+			if( customStandardInterval ){
+				setFieldValue('periodTypeName','');
+			}
+			else{
+				setFieldValue('standardInterval','');
+			}
+				
 			var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
 			selectedDataElementsValidator.empty();
 			

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js	2014-08-18 14:21:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js	2015-03-14 07:57:45 +0000
@@ -265,13 +265,31 @@
 	var checked = byId('irregular').checked;
 	if( checked )
 	{
+		enable('displayGenerateEventBox');
+		enable('customStandardInterval');
+		enable('periodTypeName');
+	}
+	else
+	{
+		disable('displayGenerateEventBox');
+		disabled('customStandardInterval');
+		disabled('periodTypeName');
+	}
+	customStandardIntervalOnChange();
+}
+
+function customStandardIntervalOnChange()
+{
+	var checked = byId('customStandardInterval').checked;
+	if( checked )
+	{
 		enable('standardInterval');
-		enable('displayGenerateEventBox');
+		disable('periodTypeName');
 	}
 	else
 	{
 		disable('standardInterval');
-		disable('displayGenerateEventBox');
+		enable('periodTypeName');
 	}
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js	2015-03-14 07:57:45 +0000
@@ -10,7 +10,15 @@
 		'beforeValidateHandler' : function()
 		{
 			selectAllById('selectedIndicators');
-		
+			
+			var customStandardInterval = byId('customStandardInterval').checked;
+			if( customStandardInterval ){
+				setFieldValue('periodTypeName','');
+			}
+			else{
+				setFieldValue('standardInterval','');
+			}
+			
 			var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
 			selectedDataElementsValidator.empty();
 			

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm	2015-01-06 14:51:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm	2015-03-14 07:57:45 +0000
@@ -52,12 +52,29 @@
 
 			<tr>
 				<td><label for="displayGenerateEventBox">$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
-				<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' #if( $programStage.displayGenerateEventBox && $programStage.displayGenerateEventBox=='true' ) checked #end #if($programStage.irregular!='true' ) disabled checked #end /></td>
+				<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' #if( $programStage.displayGenerateEventBox && $programStage.displayGenerateEventBox=='true' ) checked #end /></td>
 			</tr>
 
 			<tr>
+				<td><label for="customStandardInterval">$i18n.getString( "custom_standard_interval" )</label></td>
+				<td><input type="checkbox" id="customStandardInterval" name="customStandardInterval" #if($!programStage.periodType) #else checked #end #if($programStage.irregular!='true' ) disabled #end onchange=" customStandardIntervalOnChange()" /></td>
+			</tr>
+			
+			<tr>
 				<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
-				<td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval'#if($programStage.irregular!='true' ) disabled #end /></td>
+				<td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval'#if($programStage.irregular!='true' ) disabled #end #if($!programStage.periodType) disabled #end #if($programStage.irregular!='true' ) disabled #end  #if($programStage.irregular!='true' ) disabled checked #end /></td>
+			</tr>
+						
+			<tr>
+				<td><label for="periodTypeName">$i18n.getString( "period_type" )</label></td>
+				<td>
+					<select id="periodTypeName" name="periodTypeName" #if($!programStage.periodType) #else disabled #end  #if($programStage.irregular!='true' ) disabled checked #end >
+						<option value="">[$i18n.getString("please_select")]</option>
+						#foreach( $periodType in $periodTypes )
+						<option value="$periodType.name" #if($programStage.periodType.name=="$periodType.name") selected #end >$i18n.getString( $periodType.name )</option>
+						#end
+					</select>
+				</td>
 			</tr>
 			
 			#end