Quintiq file version 2.0
#parent: #root
Method EnableDisableComponent () derived id:Method_DialogCreateEditCustomerOrder_EnableDisableComponent
{
  #keys: '[136682.1.803278990]'
  BaseType => //DialogCreateEditSalesDemand/Method_DialogCreateEditSalesDemand_EnableDisableComponent
  Body:
  [*
    // Enable disable components
    
    DropDownListSalesSegment.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListSalesSegment ), "" );
    DropDownListStockingPoint.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListStockingPoint ), "" );
    DropDownListUnitOfMeasurement.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListUnitOfMeasurement ), "" );
    DropDownListProduct.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListProduct ), "" );
    DateSelectorStart.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DateSelectorStart ), "" );
    DateSelectorEnd.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DateSelectorEnd ), "" );
    DropDownListCurrency.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListCurrency ), "" );
    EditFieldQuantityUom.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldQuantityUom ), "" );
    EditFieldPrice.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldPrice ), "" );
    
    isexcludedfrmfulfillmentkpifrmproduct := guard( productselection.IsDerivedExcludeFromFulfillmentKPI(), false );
    
    EditFieldCustomerID.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldCustomerID ), "" );
    EditFieldCustomerName.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldCustomerName ), "" );
    EditFieldOrderID.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldOrderID ), "" );
    EditFieldOrderLineID.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldOrderLineID ), "" );
    CheckboxIsFirmed.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( CheckboxIsFirmed ), "" );
    CheckboxIsForNetting.Enabled( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( CheckboxIsForNetting ), "" );
    
    CheckBoxIsExcludedFromFulfillmentKPI.Enabled( ( not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( CheckBoxIsExcludedFromFulfillmentKPI ) )
                                                    and not isexcludedfrmfulfillmentkpifrmproduct,
                                                    ifexpr(  isexcludedfrmfulfillmentkpifrmproduct, 
                                                             Translations::MP_Designer_DialogSalesDemand_DisableCheckBoxIsExcludedFromFulfillmentKPI(), 
                                                             "" ) );
    
    isenabledpriority := false;
    isenableduncertaintypct := false;
    if( Form.CheckBoxIsExcludedFromFulfillmentKPI().Checked() )
    {
      Form.DropDownListPriority().Data( null( Priority ) );
      Form.EditFieldDemandUncertaintyPercentage().Text( ApplicationMacroPlanner.FormatRealToString( 0.0 ) );
    }
    else
    {
      isenabledpriority := not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( DropDownListPriority );
      isenableduncertaintypct := not isbatchedit or ApplicationMacroPlanner.IsActionLinkEnabledEdit( EditFieldDemandUncertaintyPercentage );
      
      if( isenabledpriority and isnull( DropDownListPriority.Data() ) )
      {
        Form.DropDownListPriority().Data( SalesDemandBase::GetDefaultPriority( MacroPlan ) );
      }
    }
    Form.DropDownListPriority().Enabled( isenabledpriority, "" );
    Form.EditFieldDemandUncertaintyPercentage().Enabled( isenableduncertaintypct, "" );
  *]
}
