陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
Method New (
  structured[SalesSegment_MP] salesSegmentsSelected,
  structured[Product_MP] products
) id:Method_DialogCreateEditFulfillmentRestriction_New
{
  #keys: '[135040.0.183105624]'
  Body:
  [*
    // Create a new fulfillment restriction
    // Select an owner
    // Get a default sales segment so we can relshadow fulfillment restriction and bind to dialog
    product   := null( Product_MP );
    owner     := null( SalesSegment_MP );
    
    if ( products.Size() >0 )
    {
      product := minselect( products, Elements, p, p.Child( relsize ) =0, p.DisplayIndex() );  
    }
    
    //get default SS
    if( salesSegmentsSelected.Size() > 0 )
    {
      
      //get a default leaf sales segment from the selected sales segment
      owner   := select(  salesSegmentsSelected, Elements.AllChildren.AsChildren, ss, ss.Child( relsize ) =0 );
    }
    else
    {
      
      owner   := FulfillmentRestriction::GetDefaultOwner( MacroPlan, product );
    }
    
    
    obj       := owner.FulfillmentRestriction( relshadow,
                                               ProductID := guard( product.ID(), "" ),
                                               SalesSegmentName := "",
                                               StartDate := Date::MinDate(),
                                               EndDate := Date::MaxDate(),
                                               Product_MP := product
                                              );
    
    DataHolderDialogData.Data( &obj );
    
    Form.SetDefaultValue( salesSegmentsSelected );
    
    ApplicationMacroPlanner.ShowFormModal( this );
  *]
}