Quintiq file version 2.0
#parent: #root
Method NewPeriodSpecification (
  internal[GUIComponent] parent,
  MacroPlan owner
) as PeriodSpecification_MP id:Method_DialogCreateEditPeriodSpecification_NewPeriodSpecification
{
  #keys: '[11660.0.59749342]'
  Body:
  [*
    // New period specification
    
    data := owner.PeriodSpecification_MP( relshadow, ID := "" ); // Temporary set ID to empty, will be based user defined value
    Dialog.Data( data );
    Dialog.SetDefaultValue();
    
    result := this.DoModal( parent );
    newobj := null( PeriodSpecification_MP );
    
    if ( result > 0 )
    {
      if( ApplicationLibMacroPlanner.GetChangeOfPlanningPeriodAtEditionWarningDialog( owner,
                                                                                      null( PeriodSpecification_MP ),
                                                                                      data.IsUsedForPlanning(),
                                                                                      data.PeriodAlignment(),
                                                                                      data.NrOfTimeUnit(),
                                                                                      data.TimeUnit(),
                                                                                      data.NrOfHistoricalPeriod(),
                                                                                      data.NrOfFuturePeriod(),
                                                                                      true ) )
      {                                                                            
        newobj := PeriodSpecification_MP::Create( EditorID.Text(),
                                                  owner,
                                                  data.TimeUnit(),
                                                  data.NrOfTimeUnit(),
                                                  data.PeriodAlignment(),
                                                  data.NrOfHistoricalPeriod(),
                                                  data.NrOfFuturePeriod(),
                                                  false,
                                                  data.IsUsedForPlanning(),
                                                  false );
      }
    }
    
    return newobj;
  *]
}
