Quintiq file version 2.0
#parent: #root
Method SetWarning () id:Method_DialogRunOptimizer_SetWarning
{
  #keys: '[136682.0.2062013298]'
  Body:
  [*
    //Set warning
    inbound := guard( not DataHolderSelectedStrategy.Data().IsBounded(), false );
    invalidkpiweight := guard( not DataHolderSelectedStrategy.Data().IsValidKPIWeight(), false );
    invalidkpi := guard( not DataHolderSelectedStrategy.Data().IsValidKPIUsed(), false );
    procminqtyissue := exists( DataHolderSelectedStrategy.Data(), KPIWeight, kpiw, true, kpiw.KPIName() = Translations::MP_GlobalParameters_KPIProcessMinimumQuantity() and kpiw.Level() > 1 );      
    isvisible := inbound or invalidkpiweight or invalidkpi or procminqtyissue;
    
    
    text :="";
    if ( inbound )
    {
      text := Translations::MP_Designer_InboundStrategy_Warning();
    }
    else if( invalidkpiweight )
    {
      invalidkpiweightname := guard( select( DataHolderSelectedStrategy.Data(), InvalidKPIWeight, kpiweight, true ).KPIName(), "" )
      text := Translations::Strategy_CanCopy_IsKPIWeightOK( invalidkpiweightname );
    }
    else if( invalidkpi )
    {
      invalidkpiname := guard( select( DataHolderSelectedStrategy.Data(), KPIWeight, kpiweight, true, not kpiweight.IsValidKPIUsedByOptimizer() ).KPIName(), "" )
      text := Translations::SM_KPIWeight_KPINotUsedByOptimizer( invalidkpiname ); 
    }
    else if ( procminqtyissue ) 
    {
      text := Translations::MP_Designer_ProcessMinQtyWarning(); 
    }
    
    ButtonWarning.Tooltip( text );
    ButtonWarning.Visible( isvisible );
  *]
}
