Quintiq file version 2.0
#parent: #root
Method NewTransportAvailability (
  internal[GUIComponent] parent
) as TransportAvailability id:Method_DialogCreateEditTransportAvailability_NewTransportAvailability
{
  #keys: '[121458.0.772017891]'
  Body:
  [*
    // New transport capacity
    
    Dialog.ShowHideComponentForBatchEdit( false, true, false );
    
    unit := select( MacroPlan, Unit, unit, unit.HasCapacityTypeTransportTime() );
    
    data := unit.TransportAvailability( relshadow, UnitID := unit.ID(), Start := MacroPlan.StartOfPlanning() );
    
    Dialog.Data( data );
    Dialog.SetDefaultValue( null( UnitPeriodTransportTime ) );
    
    result := Dialog.DoModal( parent );
    newobj := null( TransportAvailability );
    
    if( result > 0 )
    {
      newobj := TransportAvailability::Create( data.Unit(),
                                               data.Start(),
                                               data.TimeUnit(),
                                               data.Maintenance(),
                                               data.NumberOfUnit(),
                                               data.LotSize(),
                                               data.MinimumPerLot(),
                                               data.MaximumQuantity(),
                                               data.ShiftPattern(),
                                               false );
    }
    
    return newobj;
  *]
}
