limj
2023-10-24 93652435728de839582440eefd5122c281181d35
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
50
51
52
53
Quintiq file version 2.0
#parent: #root
Method EditTransportAvailabilityFromListUnitPeriodTransportTime (
  internal[GUIComponent] parent,
  structured[UnitPeriodTransportTime] selection
) id:Method_DialogCreateEditTransportAvailability_EditTransportAvailabilityFromListUnitPeriodTransportTime
{
  #keys: '[121458.0.772017541]'
  Body:
  [*
    // Edit the capacity of the selection unit period times from periods list
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit, false, true );
    
    uptt := selection.Element( 0 );
    // Need this for excluding itself in pre-condition primary keys checking.
    data := shadow( uptt.TransportAvailability() );
    
    // 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 TC, the Start date will be off if we pass in existing TC
    if( isnull( data )
        or data.Start() <> uptt.Start() )
    {
      data := uptt.Unit().TransportAvailability( relshadow, UnitID := uptt.Unit().ID(), Start := uptt.Start() );
    }
     
    Dialog.Data( data );
    
    // Need this so that when the upt doesn't not have a unit availability, the fields in this Dialog will not be blank.
    Dialog.SetDefaultValue( uptt );
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      TransportAvailability::CreateOrUpdateForUnitPeriodTransports( selection, 
                                                                    not isbatchedit or CheckBoxBatchEditMaintenance.Checked(),
                                                                    data.TimeUnit(),
                                                                    data.Maintenance(),
                                                                    not isbatchedit or CheckBoxBatchEditNumberOfUnit.Checked(),
                                                                    data.NumberOfUnit(),
                                                                    not isbatchedit or CheckBoxBatchEditLotSize.Checked(),
                                                                    data.LotSize(),
                                                                    data.MinimumPerLot(),
                                                                    not isbatchedit or CheckBoxBatchEditCapacity.Checked(),
                                                                    data.MaximumQuantity(), 
                                                                    not isbatchedit or CheckBoxBatchEditShiftPattern.Checked(),
                                                                    data.ShiftPattern(),
                                                                    CheckBoxThisPeriodOnwards.Checked() );
    }
  *]
}