lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Quintiq file version 2.0
#parent: #root
Method InitializeCapacity () id:Method_LibCal_dlgMultipleEvent_InitializeCapacity
{
  #keys: '[415136.0.647371166]'
  Body:
  [*
    // Extensible method USE_PARTIAL_CAPACITY indicates if partial capacity is allowed.
    // If so, then add it as possible option.
    useParticalCapacity := LibCal_Event::USE_PARTIAL_CAPACITY();
    
    if( useParticalCapacity )
    {
      ddslType.Strings( ddslType.Strings() + ";" + LibCal_Event::TYPE_PARTIAL() );
    }
    
    event     := dhEvent.Data();
    eventType := event.Type();
    
    // See if the eventType can be used as is or if it should be converted first.
    if( useParticalCapacity )
    {
      ddslType.Text( eventType );
    }
    else
    {
      // Partial capacity should not be used. Convert it to Unavailable or Available.
      // This is an edge case that can only happen via import, or when using partial capacity was first enabled and later disabled.
      if( eventType = LibCal_Event::TYPE_PARTIAL() )
      {
        if( event.PartialCapacity() = 0.0 )
        {
          eventType := LibCal_Event::TYPE_UNAVAILABLE();
        }
        else
        {
          eventType := LibCal_Event::TYPE_AVAILABLE();
        }
    
        // Show a message to inform the user that the EventType and Capacity was changed.
        capacity := LibCal_GlobalState.RealToString( event.PartialCapacity() );
        WebMessageBox::Warning( "The event type was 'Partial' with Capacity = " + capacity + ", but partial capacity is not enabled."
                              + "The event type is set to '" + eventType + "'.", false, false );
      }
    
      ddslType.Text( eventType );
    }
  *]
}