Quintiq file version 2.0
#parent: pnlActions/btnOKRun
Response OnClick () id:Response_pnlActions_btnOKRun_OnClick
{
  #keys: '[127710.2.15647450]'
  DefinitionID: 'Responsedef_WebButton_OnClick'
  Precondition:
  [*
    activescenario := DataHolderActiveScenario.Data();
    return not ScenarioManager::HasOptimizerRun( ScenarioManager, activescenario, feedback )
           and Period_MP::HasPeriod( feedback, MacroPlan )
           and MacroPlan.CanPlan( feedback )
           and ScenarioManager::HasCapacityForMaximumNumberofConcurrentRuns( ScenarioManager, activescenario, true, feedback )
           and AlgorithmRun::ValidateInputSelectOptimizer( feedback,
                                                           null( OptimizerPuzzle ),
                                                           DropDownListStrategy.Data(),
                                                           DropDownListPeriodsFrom.Data(),
                                                           DropDownListPeriodsTo.Data(),
                                                           MacroPlan, 
                                                           true ); //iswebapp = TRUE
  *]
  QuillAction
  {
    Body:
    [*
      // Run algorithm
      this.Enabled( false, '' );
      
      issmartplan := false;
      issmartplanfromperiodtask := false;
      hastotalsupplyuser := false;
      totalsupplyuser := 0.0;
      smartplanpispip := null( ProductInStockingPointInPeriodPlannings );
      forcenoautoscaling := false; 
      isupstreamsmartplan := false;
      ismiddleoutsmartplan := false;
      isonlyplanonestepupstream := false;
      ispostprocessing := false;
      isusingselectedunits := false;
      units := null( Units );
      process := null( Process_MP );
      // Set IsOptimizerRunning in designer, prevent the dialog to reopen when user click to terminate
      MacroPlan.IsOptimizerRunning( true );
      MacroPlan.RunOptimizer( issmartplan,
                              issmartplanfromperiodtask,
                              hastotalsupplyuser,
                              totalsupplyuser,
                              smartplanpispip,
                              isupstreamsmartplan,
                              ismiddleoutsmartplan,
                              isonlyplanonestepupstream,
                              ispostprocessing,
                              forcenoautoscaling, 
                              DataHolderSelectedStrategy.Data(),
                              CheckboxOverrideManualPlan.Checked(),  //override manual planning
                              DropDownListPeriodsFrom.Data(),
                              DropDownListPeriodsTo.Data(),
                              false,
                              isusingselectedunits,
                              units,
                              process,  // IsInventoryOptimizationRun 
                              DropDownListPuzzle.Data() );
      Form.Close();
    *]
    GroupServerCalls: false
  }
}
