Quintiq file version 2.0
#parent: #root
Method NewUnitAvailability (
  internal[GUIComponent] parent,
  Unit unit
) as UnitAvailability id:Method_DialogCreateEditUnitAvailability_NewUnitAvailability_115
{
  #keys: '[131962.0.9570392]'
  Body:
  [*
    // New unit availability
    
    Dialog.ShowHideComponentForBatchEdit( false, true, false );
    
    data := unit.UnitAvailability( relshadow, UnitID := unit.ID(), Start := MacroPlan.StartOfPlanning() );// Set Start to StartOfPlanning, will be determined in method SetDefaultValue
    
    Dialog.Data( data );
    Dialog.SetDefaultValue( null( UnitPeriodTime ) );
    
    result := Dialog.DoModal( parent );
    newobj := null( UnitAvailability )
    
    if( result > 0 )
    {
      newobj := UnitAvailability::Create( data.Unit(),
                                          data.Start(),
                                          data.TimeUnit(),
                                          data.Maintenance(),
                                          data.Efficiency(),
                                          data.Allocation(),
                                          data.ShiftPattern(),
                                          data.MaximumLoadPercentage(),
                                          data.NrOfUnitsOpen(),
                                          data.MinimumLoadThreshold(),
                                          false
                                        );
    
    }
    
    return newobj;
  *]
}
