Quintiq file version 2.0
#parent: #root
Method Copy (
  internal[GUIComponent] parent,
  FulfillmentRestriction fr
) as FulfillmentRestriction id:Method_DialogCreateEditFulfillmentRestriction_Copy
{
  #keys: '[116826.1.12686015]'
  Body:
  [*
    // New fulfillment restriction
    
    // Get a default sales segment so we can relshadow fulfillment restriction and bind to dialog
    // Follow the expression filter defined in data extractor for dropdown
    product := fr.Product_MP();
    salessegment := fr.SalesSegment_MP();
    
    data := salessegment.FulfillmentRestriction( relshadow, ProductID := product.ID(), SalesSegmentName := "", StartDate := fr.StartDate() );
    data.Product_MP( relset, product );
    
    // Set default data
    data.EndDate( fr.EndDate() );
    
    CheckBoxHasStart.Checked( data.StartDate().IsFinite() );
    CheckBoxHasEnd.Checked( data.EndDate().IsFinite() );
    
    Dialog.Data( data );
    
    fulfillmentrestriction := null( FulfillmentRestriction );
    
    if ( Dialog.DoModal( parent ) > 0 )
    {
      fulfillmentrestriction := FulfillmentRestriction::Create( SelectionSalesSegment.Data(), 
                                                                SelectionProduct.Data().ID(), 
                                                                GUIDateTimeSelectorStartDate.DateTime().Date(),
                                                                GUIDateTimeSelectorEndDate.DateTime().Date() );  
    }
    
    return fulfillmentrestriction;
  *]
}
