Quintiq file version 2.0
#parent: Toolbar/btnOk
Response OnClick () id:Response_Toolbar_btnOk_OnClick
{
  #keys: '[11660.0.771099266]'
  Body:
  [*
    // Run algorithm
    // Running the optimizer asynchronous after copy the optimizer setting from scenario manager
    issmartplan := false;
    issmartplanperiodtask := false; 
    hastotalsupplyuser := false;
    totalsupplyuser := 0.0;
    smartplanpispip := null( ProductInStockingPointInPeriodPlannings );
    forcenoautoscaling := false; 
    isupstreamsmartplan := false;
    ismiddleoutsmartplan := false;
    isonlyplanonestepupstream := false;
    ispostprocessing := false;
    isusingselectedunits := false;
    units := null( Units );
    
    MacroPlan.RunOptimizer( issmartplan,                                           // FIX for time being call into this -- replace by call into meta mip
                            issmartplanperiodtask, 
                            hastotalsupplyuser,
                            totalsupplyuser,
                            smartplanpispip,
                            isupstreamsmartplan,
                            ismiddleoutsmartplan,
                            isonlyplanonestepupstream,
                            ispostprocessing,
                            forcenoautoscaling, 
                            Dialog.SelectionStrategy().Data(),
                            Dialog.CheckBoxOverrideManualPlanning().Checked(),
                            Dialog.SelectionPeriodFrom().Data(),
                            Dialog.SelectionPeriodTo().Data(),
                            false,
                            isusingselectedunits,
                            units,  // IsInventoryOptimizationRun 
                            null( Process_MP ),
                            SelectionOptimizerPuzzle.Data() ); // OptimizerPuzzle, used to change the last puzzle used
    
    Application.RemoveHistory();
    
    Dialog.Close();
  *]
  DefinitionID: 'Responsedef_GUIButtonBase_OnClick'
  Precondition:
  [*
    activescenario := DataHolderActiveScenario.Data();
    return not ScenarioManager::HasOptimizerRun( ScenarioManager, activescenario, feedback )
           and MacroPlan.CanPlan( feedback )
           and ScenarioManager::HasCapacityForMaximumNumberofConcurrentRuns( ScenarioManager, activescenario, true, feedback )
           and AlgorithmRun::ValidateInputSelectOptimizer( feedback,
                                                           SelectionOptimizerPuzzle.Data(),
                                                           SelectionStrategy.Data(),
                                                           SelectionPeriodFrom.Data(),
                                                           SelectionPeriodTo.Data(),
                                                           MacroPlan, false );  //iswebapp = FALSE
  *]
  UserRequiresReadWrite: true
}
