Quintiq file version 2.0
#parent: #root
Method Edit (
  internal[GUIComponent] parent,
  structured[SafetyStock] selection
) id:Method_DialogCreateEditSafetyStock_Edit
{
  #keys: '[136682.2.182627981]'
  Body:
  [*
    // Edit inventory specifications
    data := shadow( selection.Element(0) );
    Dialog.Data( data );
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponent( isbatchedit );
    Dialog.EnableBatchEditComponents( isbatchedit );
    
    if ( Dialog.DoModal( parent ) > 0 )
    {
      istargetinday := [Boolean]RadioButtonGroupTarget.BoundValue()
      targetindays := ifexpr( istargetinday, ApplicationLibMacroPlanner.FormatStringToReal( EditorTargetInDays.Text(),0.0), 0.0 );
      targetinqty := ifexpr( not istargetinday, ApplicationLibMacroPlanner.FormatStringToReal( EditorTargetInQuantity.Text(),0.0 ), 0.0 );
      
      SafetyStock::Update( selection,
                           SelectionProduct.Data(),
                           SelectionStockingPoint.Data(),
                           GUIStartDateTimeSelector.DateTime().Date(),
                           istargetinday, targetindays, targetinqty,            // Does not have a target in days, the initial targets are 0
                           false, CheckBoxHasUserTarget.Checked(), false );     
    }
  *]
}
