From 6982337837db3443d05ada70c0afbf331032cf15 Mon Sep 17 00:00:00 2001
From: yanweiyuan3 <yanweiyuan3@gmail.com>
Date: 星期五, 15 九月 2023 17:43:59 +0800
Subject: [PATCH] Add Release & Copy(Save) button

---
 LibMacroPlanner/BL/Type_Scenario/Method_CanSelect.qbl                                                                             |    3 
 _Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuRelaeaseNewVersion_OnClick.def  |   52 +++++
 LibMacroPlanner/BL/Type_ScenarioMP/Method_SetReleased.qbl                                                                         |    6 
 _Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl                                                                      |    5 
 _Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl                                                                    |    2 
 _Main/BL/Type_VersionControl/StaticMethod_GetVersionInfo.qbl                                                                      |   30 +++
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def |    4 
 _Main/BL/InfoMessages.qbl                                                                                                         |    5 
 _Main/BL/Type_VersionControl/StaticMethod_FindLatestVersion.qbl                                                                   |   22 ++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def                                                    |   24 +-
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Component_PanelVersionOfSOPHeader.def                                      |    1 
 _Main/BL/Type_VersionControl/StaticMethod_CopyVersion.qbl                                                                         |   48 +++++
 _Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuSaveNewVersion_OnClick.def      |   49 +++++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Response_pnlActions_btnOk_OnClick.def                              |   22 ++
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/_ROOT_Component_DialogCreateEditScenario.def                       |    1 
 _Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Component_ListScenario.def                                              |  114 ++++++++++++
 _Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl                                                               |    4 
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_pnlActions.def                                           |   10 +
 _Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl                                                             |    3 
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderCopy_OnClick.def  |    3 
 _Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl                                                                |    2 
 LibMacroPlanner/BL/InfoMessages.qbl                                                                                               |    4 
 _Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_ListScenario_MenuCopyScenario_OnClick.def                      |   12 +
 LibMacroPlanner/BL/Type_Scenario/Method_SetReleased.qbl                                                                           |   12 +
 /dev/null                                                                                                                         |   26 --
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/_ROOT_Component_FormVersionOfSOP.def                                       |   10 +
 _Main/BL/Type_Scenario/Method_SetReleased.qbl                                                                                     |    5 
 _Main/UI/MacroPlannerWebApp/_ROOT_Project_MacroPlannerWebApp.qp                                                                   |    2 
 LibMacroPlanner/BL/Type_Scenario/Attribute_IsReleased.qbl                                                                         |    9 +
 29 files changed, 444 insertions(+), 46 deletions(-)

diff --git a/LibMacroPlanner/BL/InfoMessages.qbl b/LibMacroPlanner/BL/InfoMessages.qbl
index 05bad47..cfaabd1 100644
--- a/LibMacroPlanner/BL/InfoMessages.qbl
+++ b/LibMacroPlanner/BL/InfoMessages.qbl
@@ -529,6 +529,10 @@
   {
     DefaultText: 'Revert'
   }
+  InfoMessage Scenario_General_IsReleased
+  {
+    DefaultText: 'Not allowed on a released scenario'
+  }
   InfoMessage Strategy_CampaignOptimizer_DisableTooltip
   {
     DefaultText: 'When disabled, the optimizer is only allowed to replan the quantities of the campaigns based on the constraints of the campaigns created manually.'
diff --git a/LibMacroPlanner/BL/Type_Scenario/Attribute_IsReleased.qbl b/LibMacroPlanner/BL/Type_Scenario/Attribute_IsReleased.qbl
new file mode 100644
index 0000000..37963e6
--- /dev/null
+++ b/LibMacroPlanner/BL/Type_Scenario/Attribute_IsReleased.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsReleased
+{
+  #keys: '3[412960.0.172790038][412960.0.172790037][412960.0.172790039]'
+  Description: '璇ョ増鏈槸鍚﹀凡鍙戝竷'
+  ValueType: Boolean
+  InterfaceProperties { Accessibility: 'Module' }
+}
diff --git a/LibMacroPlanner/BL/Type_Scenario/Method_CanSelect.qbl b/LibMacroPlanner/BL/Type_Scenario/Method_CanSelect.qbl
index ee79d24..072d7c9 100644
--- a/LibMacroPlanner/BL/Type_Scenario/Method_CanSelect.qbl
+++ b/LibMacroPlanner/BL/Type_Scenario/Method_CanSelect.qbl
@@ -32,6 +32,9 @@
     {
       feedback_o := Translations::Scenario_General_IsDeleted();
     }
+    else if( this.IsReleased() ){
+      feedback_o := Translations::Scenario_General_IsReleased();
+      }
     
     return feedback_o = '';
   *]
diff --git a/LibMacroPlanner/BL/Type_Scenario/Method_SetReleased.qbl b/LibMacroPlanner/BL/Type_Scenario/Method_SetReleased.qbl
new file mode 100644
index 0000000..c30613e
--- /dev/null
+++ b/LibMacroPlanner/BL/Type_Scenario/Method_SetReleased.qbl
@@ -0,0 +1,12 @@
+Quintiq file version 2.0
+#parent: #root
+Method SetReleased
+{
+  Description: '璁剧疆鏌愬満鏅殑鍙戝竷鐘舵��'
+  IsAbstract: true
+  TextBody:
+  [*
+    // Administrator Sep-15-2023 (created)
+    this.IsReleased( true );
+  *]
+}
diff --git a/LibMacroPlanner/BL/Type_ScenarioMP/Method_SetReleased.qbl b/LibMacroPlanner/BL/Type_ScenarioMP/Method_SetReleased.qbl
new file mode 100644
index 0000000..b84962e
--- /dev/null
+++ b/LibMacroPlanner/BL/Type_ScenarioMP/Method_SetReleased.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#parent: #root
+MethodOverride SetReleased
+{
+  TextBody: 'this.IsReleased( true );'
+}
diff --git a/_Main/BL/InfoMessages.qbl b/_Main/BL/InfoMessages.qbl
new file mode 100644
index 0000000..d3fc0df
--- /dev/null
+++ b/_Main/BL/InfoMessages.qbl
@@ -0,0 +1,5 @@
+Quintiq file version 2.0
+#parent: #root
+InfoMessages id:#InfoMessages #extension
+{
+}
diff --git a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl
index 5e79d99..a8610b8 100644
--- a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl
+++ b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl
@@ -31,7 +31,7 @@
     listtodeal := selectset( macroplan, 
                               Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, 
                               pispip, 
-                              true );
+                              pispip.SalesDemandQuantity() > 0 );
     
     if( latestversion.CalType() = "TM_SOP_R1" ){
       listtodeal := selectset( macroplan, 
diff --git a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl
index 0cba7c5..b094140 100644
--- a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl
+++ b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl
@@ -10,7 +10,7 @@
   [*
     // Administrator Sep-14-2023 (created)
     businesstype := GlobalOTDTable::GetBusinessTypeName( businessname );
-    
+    releasetime := DateTime::ActualTime();
     // Clean exist data
     traverse( owner, MappingVersionControl, mpc, true ){
       mpc.Delete();
@@ -28,7 +28,7 @@
       if( isnull( existversion ) ){
         longversionname := item.VersionName();
         longversionnamelist := longversionname.Tokenize( "-" );
-        shortversionname := longversionnamelist.Element( longversionnamelist.Size() );
+        shortversionname := longversionnamelist.Element( longversionnamelist.Size() - 1 );
         caltype := shortversionname.SubString( 0, 10 );
         shortversionid := versionid.ReplaceAll( "-" + caltype, "" );
         newversioncontrol := VersionControl::Create( owner, 
@@ -40,6 +40,7 @@
                                                      shortversionname, 
                                                      item.User() );
         newversioncontrol.IsReleased( true );
+        newversioncontrol.ReleaseTime( releasetime );
         } 
       }
   *]
diff --git a/_Main/BL/Type_Scenario/Method_SetReleased.qbl b/_Main/BL/Type_Scenario/Method_SetReleased.qbl
new file mode 100644
index 0000000..9406560
--- /dev/null
+++ b/_Main/BL/Type_Scenario/Method_SetReleased.qbl
@@ -0,0 +1,5 @@
+Quintiq file version 2.0
+#parent: #root
+Method SetReleased #extension
+{
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_CopyVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_CopyVersion.qbl
new file mode 100644
index 0000000..fee8475
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_CopyVersion.qbl
@@ -0,0 +1,48 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CopyVersion (
+  GlobalOTDTable owner,
+  String businessname
+) as VersionControl
+{
+  Description: '澶嶅埗褰撳墠鐗堟湰骞舵洿鏂扮増鏈彿'
+  TextBody:
+  [*
+    // Administrator Sep-13-2023 (created)
+    createtime := DateTime::ActualTime();
+    user := QuintiqUser::CurrentUser().Username();
+    starttime := DateTime::Construct(1970,1,1,0,0,0);
+    // Get the local scenario businesstype
+    businesstype := GlobalOTDTable::GetBusinessTypeName( businessname );
+    
+    // Get the older version info
+    oldversionid := "";
+    oldversionname := "";
+    
+    latestversion := VersionControl::FindLatestUpdateVersion( owner, businesstype );
+    copyversionid := latestversion.VersionID();
+    
+    if( copyversionid.FindString( "-", 0 ) > 0 ){
+      latestversionlist := copyversionid.Tokenize( "-" );
+      latestversionnamelist := latestversion.LongVersionName().Tokenize( "-" );
+      for( i := 0; i < latestversionlist.Size(); i := i + 1 ){
+        oldversionid := oldversionid + "-" + latestversionlist.Element( i );
+        oldversionname := oldversionname + "-" + latestversionnamelist.Element( i );
+        }
+      oldversionid := oldversionid + "-";
+      oldversionname := oldversionname + "-";
+      }
+    
+    // Calculate new version info
+    additionversionid := ( createtime.MinutesAsReal( starttime ) * 60 * 10 + createtime.SecondOfMinute() ).Round( 0 );
+    newversionid := oldversionid + [String]additionversionid;
+    newcaltype := latestversion.CalType();
+    newsingleversionname := newcaltype + "(" + createtime.Format( "Y/M2/D2 H:m:s" ) + ")";
+    newversionname := oldversionname + newsingleversionname;
+    
+    // Create new version
+    newversion := VersionControl::Create( owner, businesstype, newcaltype, createtime, newversionid, newversionname, newsingleversionname, user );
+    
+    return newversion;
+  *]
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl
index 7030997..450646d 100644
--- a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl
+++ b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl
@@ -24,11 +24,13 @@
     additionversionid := ( createtime.MinutesAsReal( starttime ) * 60 * 10 + createtime.SecondOfMinute() ).Round( 0 );
     newversionid := oldversion_id + [String]additionversionid;
     newcaltype := GlobalOTDTable::GetNextCalType( oldcaltype, businesstype );
-    newsingleversionname := newcaltype + "(" + createtime.Format( "Y-M2-D2 H:m:s" ) + ")";
+    newsingleversionname := newcaltype + "(" + createtime.Format( "Y/M2/D2 H:m:s" ) + ")";
     newversionname := oldversion_name + newsingleversionname;
     
     // Create new version
     newversion := VersionControl::Create( owner, businesstype, newcaltype, createtime, newversionid, newversionname, newsingleversionname, user );
+    newversion.IsReleased( true );
+    newversion.ReleaseTime( createtime );
     
     return newversion;
   *]
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
index 9c93bdf..8f05fb1 100644
--- a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
+++ b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
@@ -36,7 +36,7 @@
     additionversionid := ( createtime.MinutesAsReal( starttime ) * 60 * 10 + createtime.SecondOfMinute() ).Round( 0 );
     newversionid := oldversion_id + [String]additionversionid;
     newcaltype := GlobalOTDTable::GetNextCalType( oldcaltype, businesstype );
-    newsingleversionname := newcaltype + "(" + createtime.Format( "Y-M2-D2 H:m:s" ) + ")";
+    newsingleversionname := newcaltype + "(" + createtime.Format( "Y/M2/D2 H:m:s" ) + ")";
     newversionname := oldversion_name + newsingleversionname;
     
     // Create new version
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
index 1b2ab3f..4450bf4 100644
--- a/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
+++ b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
@@ -14,8 +14,7 @@
     latestversion := maxselect( globalotdtable, 
                                 VersionControl, 
                                 version, 
-                                version.BusinessType()=businesstype, 
-    //                             and version.IsReleased()=true, 
+                                version.BusinessType()=businesstype and version.IsReleased()=true, 
                                 version.CreateTime() );
     
     return latestversion;
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_FindLatestVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestVersion.qbl
new file mode 100644
index 0000000..df4f8f4
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestVersion.qbl
@@ -0,0 +1,22 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindLatestVersion (
+  GlobalOTDTable globalotdtable,
+  String businesstype
+) as VersionControl
+{
+  Description: '鑾峰彇鏌愪簨涓氶儴鐩墠鏈�鏂扮殑鐗堟湰鍙�'
+  TextBody:
+  [*
+    // Administrator Sep-13-2023 (created)
+    
+    // Get the latest version data 
+    latestversion := maxselect( globalotdtable, 
+                                VersionControl, 
+                                version, 
+                                version.BusinessType()=businesstype, 
+                                version.CreateTime() );
+    
+    return latestversion;
+  *]
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_GetSOPVersionInfo.qbl b/_Main/BL/Type_VersionControl/StaticMethod_GetSOPVersionInfo.qbl
deleted file mode 100644
index a49274b..0000000
--- a/_Main/BL/Type_VersionControl/StaticMethod_GetSOPVersionInfo.qbl
+++ /dev/null
@@ -1,26 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod GetSOPVersionInfo (
-  GlobalOTDTable owner
-) as owning Strings
-{
-  Description: '鑾峰彇SOP澶х増鏈増鏈彿鍙婄増鏈悕绉�'
-  TextBody:
-  [*
-    // Administrator Sep-13-2023 (created)
-    result := construct( Strings );
-    rootversion := VersionControl::FindLatestUpdateVersion( owner, "TM" );
-    
-    if( not isnull( rootversion ) ){
-      result.Add( rootversion.VersionID() );
-      result.Add( rootversion.LongVersionName() );
-      result.Add( rootversion.VersionID() + "-" + rootversion.CalType() );
-      }else{
-        result.Add( "" );
-        result.Add( "" );
-        result.Add( "" );
-        }
-    
-    return &result;
-  *]
-}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_GetVersionInfo.qbl b/_Main/BL/Type_VersionControl/StaticMethod_GetVersionInfo.qbl
new file mode 100644
index 0000000..03b2084
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_GetVersionInfo.qbl
@@ -0,0 +1,30 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod GetVersionInfo (
+  GlobalOTDTable owner,
+  String businessname
+) as owning Strings
+{
+  Description: '鑾峰彇澶х増鏈増鏈彿鍙婄増鏈悕绉�'
+  TextBody:
+  [*
+    // Administrator Sep-13-2023 (created)
+    businesstyoe := GlobalOTDTable::GetBusinessTypeName( businessname );
+    result := construct( Strings );
+    rootversion := VersionControl::FindLatestVersion( owner, businesstyoe );
+    
+    if( not isnull( rootversion ) ){
+      result.Add( rootversion.VersionID() );
+      result.Add( rootversion.LongVersionName() );
+      result.Add( rootversion.VersionID() + "-" + rootversion.CalType() );
+      result.Add( rootversion.SingleVersionName() );
+      }else{
+        result.Add( "" );
+        result.Add( "" );
+        result.Add( "" );
+        result.Add( "" );
+        }
+    
+    return &result;
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_pnlActions.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_pnlActions.def
new file mode 100644
index 0000000..61bc669
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_pnlActions.def
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+Component pnlActions #extension
+{
+  Children:
+  [
+    Component btnOK #extension
+    {
+    }
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
index 1d0ed83..92e4f73 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
@@ -17,6 +17,21 @@
     newscenario := null( Scenario );
     strategy := null( Strategy );
     
+    // New version
+    globalotdtable := GlobalOTDTable;
+    testbusinesstype := "闆嗗洟";
+    if( data.IsCreateNewVersion() ){
+      VersionControl::CreateNewSceneVersion( globalotdtable, testbusinesstype );
+      }else{
+        VersionControl::CreateNewVersion( globalotdtable, testbusinesstype );
+        }
+    versionname := VersionControl::GetVersionInfo( globalotdtable, testbusinesstype ).Element( 3 );
+    
+    // Get Version Name
+    if( data.Name() = "" ){
+      data.Name( versionname );
+      }
+    
     // Copy scenario
     if( isnull( data.WrappedInstance() ) )
     {
@@ -95,15 +110,6 @@
         MacroPlan::DoSync( macroPlanNew, 
                            data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() );
     }
-    
-    // New version
-    globalotdtable := GlobalOTDTable;
-    testbusinesstype := "闆嗗洟";
-    if( data.IsCreateNewVersion() ){
-      VersionControl::CreateNewSceneVersion( globalotdtable, testbusinesstype );
-      }else{
-        VersionControl::CreateNewVersion( globalotdtable, testbusinesstype );
-        }
     
     this.Close();
   *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Response_pnlActions_btnOk_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Response_pnlActions_btnOk_OnClick.def
new file mode 100644
index 0000000..e56830c
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Response_pnlActions_btnOk_OnClick.def
@@ -0,0 +1,22 @@
+Quintiq file version 2.0
+#parent: pnlActions/btnOK
+Response OnClick () id:Response_pnlActions_btnOK_OnClick #extension
+{
+  Precondition:
+  [*
+    data := DataHolderDialogData.Data();
+    return not isnull( data )
+           and Scenario::ValidateInput( feedback,
+                                        ScenarioManager,
+    //                                    edtName.Text(),
+                                        "for version", 
+                                        data.WrappedInstance(),
+                                        '',
+                                        GlobalParameters_MP::GetKB_New(),
+                                        'Test',
+                                        RadioButtonGroupStorageState.BoundValue(),
+                                        Domain.MDSStorageDefinitionManager().Enabled(),
+                                        Domain.MDSStorageDefinitionManager().DatasetStoreEnabled(),
+                                        Domain.MDSStorageDefinitionManager().DatabaseEnabled() );
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/_ROOT_Component_DialogCreateEditScenario.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/_ROOT_Component_DialogCreateEditScenario.def
index c446fac..c7bba6d 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/_ROOT_Component_DialogCreateEditScenario.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/_ROOT_Component_DialogCreateEditScenario.def
@@ -6,5 +6,6 @@
   Children:
   [
     #child: pnlContent
+    #child: pnlActions
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Component_ListScenario.def b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Component_ListScenario.def
index 71d6ba4..015e693 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Component_ListScenario.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Component_ListScenario.def
@@ -1,4 +1,118 @@
 Quintiq file version 2.0
 Component ListScenario #extension
 {
+  Children:
+  [
+    Component DataSetLevelScenario #extension
+    {
+      Children:
+      [
+        Component listContextMenuScenarioFolder #extension
+        {
+          Children:
+          [
+            Component MenuRelaeaseNewVersion
+            {
+              #keys: '[412960.0.168283194]'
+              BaseType: 'WebMenu'
+              Properties:
+              [
+                DelegationID: 'ActionBarScenario_Release'
+                Description: '鍙戝竷鏂扮増鏈�'
+                Image: 'EDITOR_ALGORITHM'
+                Taborder: 10
+                Title: 'Release New Version...'
+              ]
+            }
+            Component MenuCopyScenario #extension
+            {
+            }
+            Component MenuSaveNewVersion
+            {
+              #keys: '[412960.0.172960163]'
+              BaseType: 'WebMenu'
+              Properties:
+              [
+                DelegationID: 'ActionBarScenario_Save'
+                Description: '鍙戝竷鏂扮増鏈�'
+                Image: 'DATA_DISK'
+                Taborder: 11
+                Title: 'Save New Version...'
+              ]
+            }
+            Component MenuSeparator2 #extension
+            {
+              Properties:
+              [
+                Taborder: 12
+              ]
+            }
+            Component MenuSeparator3 #extension
+            {
+              Properties:
+              [
+                Taborder: 14
+              ]
+            }
+            Component MenuSelectScenario #extension
+            {
+              Properties:
+              [
+                Taborder: 13
+              ]
+            }
+            Component MenuEditAuthorization #extension
+            {
+              Properties:
+              [
+                Taborder: 15
+              ]
+            }
+            Component MenuSeparator4 #extension
+            {
+              Properties:
+              [
+                Taborder: 16
+              ]
+            }
+            Component MenuLoadScenario #extension
+            {
+              Properties:
+              [
+                Taborder: 17
+              ]
+            }
+            Component MenuUnloadScenario #extension
+            {
+              Properties:
+              [
+                Taborder: 18
+              ]
+            }
+            Component MenuSeparator5 #extension
+            {
+              Properties:
+              [
+                Taborder: 19
+              ]
+            }
+            Component MenuAdministration #extension
+            {
+              Properties:
+              [
+                Taborder: 20
+              ]
+            }
+            Component MenuRestoreItem #extension
+            {
+              Properties:
+              [
+                Taborder: 21
+              ]
+            }
+          ]
+        }
+      ]
+    }
+  ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_ListScenario_MenuCopyScenario_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_ListScenario_MenuCopyScenario_OnClick.def
new file mode 100644
index 0000000..93390c2
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_ListScenario_MenuCopyScenario_OnClick.def
@@ -0,0 +1,12 @@
+Quintiq file version 2.0
+#parent: ListScenario
+Response OnClick (
+  ScenarioMP selection
+) id:Response_ListScenario_MenuCopyScenario_OnClick #extension
+{
+  Precondition:
+  [*
+    feedback := ApplicationMacroPlanner.HasValidDataset( selection );
+    return feedback = '' and selection.CanCopy( feedback );
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuRelaeaseNewVersion_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuRelaeaseNewVersion_OnClick.def
new file mode 100644
index 0000000..745d231
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuRelaeaseNewVersion_OnClick.def
@@ -0,0 +1,52 @@
+Quintiq file version 2.0
+#parent: ListScenario
+Response OnClick (
+  ScenarioMP selection
+) id:Response_ListScenario_MenuRelaeaseNewVersion_OnClick
+{
+  #keys: '[412960.0.170112594]'
+  CanBindMultiple: false
+  DefinitionID => /ListScenario/Responsedef_ListScenario_WebMenu_OnClick
+  Initiator: 'MenuRelaeaseNewVersion'
+  Precondition:
+  [*
+    feedback := ApplicationMacroPlanner.HasValidDataset( selection );
+    return feedback = '' and selection.CanCopy( feedback );
+  *]
+  QuillAction
+  {
+    Body:
+    [*
+      // Copy scenario
+      owner := GlobalOTDTable;
+      macroplan := MacroPlan;
+      testbusinesstype := "闆嗗洟";
+      
+      VersionControl::ReleaseNewVersion( owner, testbusinesstype );
+      GlobalOTDTable::GetOutputVersionData( owner, macroplan, testbusinesstype );
+      selection.SetReleased();
+      
+      versionname := VersionControl::GetVersionInfo( owner, testbusinesstype ).Element( 3 );
+      // Get the active scenario
+      //data := selection;
+      newscenario := null( Scenario );
+      strategy := null( Strategy );
+      
+      data := ScenarioManager.ScenarioNode( relshadow,
+                                                ScenarioMP,
+                                                Parent := selection,
+                                                Name := versionname,
+                                                SelectedStrategy := selection.SelectedStrategy(),
+                                                State := selection.State() );
+      
+      scenario := data.Parent().astype( ScenarioMP );
+      strategy := data.SelectedStrategy();
+           
+      newscenario:= scenario.Copy( data.Parent(), versionname, "",
+                                   data.Comment(), data.State() );
+      
+      newscenario.SelectedStrategy( relset, strategy );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuSaveNewVersion_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuSaveNewVersion_OnClick.def
new file mode 100644
index 0000000..1f8b93b
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormScenarioManager/Response_TIANMA_JITUAN_ListScenario_MenuSaveNewVersion_OnClick.def
@@ -0,0 +1,49 @@
+Quintiq file version 2.0
+#parent: ListScenario
+Response OnClick (
+  ScenarioMP selection
+) id:Response_ListScenario_MenuSaveNewVersion_OnClick
+{
+  #keys: '[412960.0.171680443]'
+  CanBindMultiple: false
+  DefinitionID => /ListScenario/Responsedef_ListScenario_WebMenu_OnClick
+  Initiator: 'MenuSaveNewVersion'
+  Precondition:
+  [*
+    feedback := ApplicationMacroPlanner.HasValidDataset( selection );
+    return feedback = '' and selection.CanCopy( feedback );
+  *]
+  QuillAction
+  {
+    Body:
+    [*
+      // Copy scenario
+      owner := GlobalOTDTable;
+      macroplan := MacroPlan;
+      testbusinesstype := "闆嗗洟";
+      
+      VersionControl::CopyVersion( owner, testbusinesstype );
+      
+      versionname := VersionControl::GetVersionInfo( owner, testbusinesstype ).Element( 3 );
+      // Copy scenario
+      newscenario := null( Scenario );
+      strategy := null( Strategy );
+      
+      data := ScenarioManager.ScenarioNode( relshadow,
+                                                ScenarioMP,
+                                                Parent := selection,
+                                                Name := versionname,
+                                                SelectedStrategy := selection.SelectedStrategy(),
+                                                State := selection.State() );
+      
+      scenario := data.Parent().astype( ScenarioMP );
+      strategy := data.SelectedStrategy();
+           
+      newscenario:= scenario.Copy( data.Parent(), versionname, "",
+                                   data.Comment(), data.State() );
+      
+      newscenario.SelectedStrategy( relset, strategy );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Component_PanelVersionOfSOPHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Component_PanelVersionOfSOPHeader.def
index f29ab77..8fc6655 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Component_PanelVersionOfSOPHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Component_PanelVersionOfSOPHeader.def
@@ -61,6 +61,7 @@
         Description: '鍙戝竷涓�涓柊鐗堟湰'
         Label: '娴嬭瘯鐢ㄧ増鏈彂甯�'
         Taborder: 4
+        Visible: false
       ]
     }
   ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderCopy_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderCopy_OnClick.def
index 461fb7f..ff0fa8b 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderCopy_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderCopy_OnClick.def
@@ -10,7 +10,8 @@
     Body:
     [*
       owner := GlobalOTDTable;
-      rootversionid := VersionControl::GetSOPVersionInfo( owner ).Element( 2 );
+      testbusinesstype := "闆嗗洟";
+      rootversionid := VersionControl::GetVersionInfo( owner, testbusinesstype ).Element( 2 );
       dlg := construct( DialogVersionIDCopy );
       dlg.lblContent().Text( rootversionid );
       dlg.JustShow();
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
index 9fea94f..91d48bd 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
@@ -12,9 +12,9 @@
       owner := GlobalOTDTable;
       testbusinesstype := "闆嗗洟";
       GlobalOTDTable::GetVersionData( owner, testbusinesstype );
-      rootversionid := VersionControl::GetSOPVersionInfo( owner ).Element( 0 );
+      rootversionid := VersionControl::GetVersionInfo( owner, testbusinesstype ).Element( 0 );
       DataExtractorVersionOfSOPDetails.FixedFilter( "object.VersionID().FindString( " + rootversionid.AsQUILL() + ", 0 ) = 0" );
-      rootversionname := VersionControl::GetSOPVersionInfo( owner ).Element( 1 );
+      rootversionname := VersionControl::GetVersionInfo( owner, testbusinesstype ).Element( 1 );
       LabelVersionOfSOPHeader.Text( rootversionname );
       VersionStatus::GetBusinessTypeStatus( owner, rootversionid );
     *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/_ROOT_Component_FormVersionOfSOP.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/_ROOT_Component_FormVersionOfSOP.def
index 21f15fc..9a4348d 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/_ROOT_Component_FormVersionOfSOP.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/_ROOT_Component_FormVersionOfSOP.def
@@ -62,6 +62,16 @@
         Taborder: 4
       ]
     }
+    Component DataHolderVersionOfSOPCopy
+    {
+      #keys: '[412960.0.166861218]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'shadow[ScenarioMP]*'
+      Properties:
+      [
+        Taborder: 5
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/_ROOT_Project_MacroPlannerWebApp.qp b/_Main/UI/MacroPlannerWebApp/_ROOT_Project_MacroPlannerWebApp.qp
index 237ed78..ddbe397 100644
--- a/_Main/UI/MacroPlannerWebApp/_ROOT_Project_MacroPlannerWebApp.qp
+++ b/_Main/UI/MacroPlannerWebApp/_ROOT_Project_MacroPlannerWebApp.qp
@@ -5,7 +5,7 @@
   ProjectProperties
   {
     ApplicationComponentName: 'ApplicationMacroPlanner'
-    BuildVersion: '2022.3.0.72'
+    BuildVersion: '2022.3.0.171'
     Description: 'Quintiq Macro Planner'
     ProjectKind: 'WebClient'
   }

--
Gitblit v1.9.3