yanweiyuan3
2023-09-11 7804ec7a70a7ffe3116daec64154c15842f8c513
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
Quintiq file version 2.0
#parent: #root
Method InitializeDataHolder (
  structured[UnitPeriodTime] selection
) id:Method_DialogCreateEditUnitAvailability_InitializeDataHolder
{
  #keys: '[151892.0.49084539]'
  Body:
  [*
    //Initial dataholder
    
    DataHolderUnitPeriodTime.Data( selection.Copy() );
    
    // Get the shift patterns that are allowed on every selected unit.
    shiftpatterns := ShiftPattern::GetAvailableShiftPatterns( MacroPlan, selection );
    DataHolderShiftPattern.Data( &shiftpatterns );
    
    firstElement := minselect( selection, Elements, e, true, e.Start() );
    
    // Need this for excluding itself in pre-condition primary keys checking.
    data := shadow( firstElement.UnitAvailability() );
    
    // In case selection.Element( 0 ) doesn't bind to any unit availability, calling SetDefaultValue method will return null error.
    // Check start in case of editing from UPT later than the existing UA, the Start date will be off if we pass in existing UA
    if( isnull( data )
        or data.Start() <> firstElement.Start() )
    {
      data := firstElement.Unit().UnitAvailability( relshadow, UnitID := firstElement.Unit().ID(), Start := firstElement.Start() );
    }
    
    DataHolderDialogData.Data( &data );
    Form.SetDefaultValue( firstElement );
    ApplicationMacroPlanner.ShowFormModal( this );
  *]
}