Kathiravan of Leanswift
1/7/2019 - 2:19 PM

PPS200_POreceipt_H5_V1

H5 Script to trigger PO receipt from PPS200, shortcut to PPS300.

var PPS200_POreceipt_H5_V1 = new function() 
{ 
        var _this=this;
        var list;
        this.list=list;
        var button_PPS200;
        var columnPUNO;
		var columnWHLO;
        var startPanel = "PPS200/B";
   this.Init = function(scriptArgs)
   {
        this.debug = scriptArgs.debug;
        this.controller = scriptArgs.controller;
        var content = this.controller.RenderEngine.Content;
        this.$host = scriptArgs.controller.ParentWindow;
        this.args = scriptArgs;
        var element = scriptArgs.elem;
        this.log = scriptArgs.log;
        this.addButtonElement(69,5,15,"Receive Goods");
   };
    this.addButtonElement = function(col,row,width,text){
        button_PPS200 = new ButtonElement();
        button_PPS200.Value=text;
        var position = new PositionElement();
        position.Width=width;
        position.Top=row;
        position.Left=col;
        button_PPS200.Position=position;
        button_PPS200.IsEnabled=true;
		var contentElement = this.controller.GetContentElement();
        var button = contentElement.AddElement(button_PPS200);
		$(button).attr("title", "You will be redirected to PPS300").inforToolTip();
        var curPanel = this.controller.RenderEngine.PanelHeader;
        if (startPanel != curPanel) 
        {
            var errorMessage = this.controller.GetProgramName() + "  Please deploy the script on " + startPanel + " panel";
			ConfirmDialog.ShowMessageDialog({
                        dialogType: "Error",
                        header: "Error",
                        message: errorMessage
                    });
            return;
        }
        button.click({}, () => {
        try
        {
            this.OnClick_PPS200();       
        }
        catch (err)
        {
            console.log(err.message);  
            return (0);
        }                                               
        }); 
        
     };

    this.OnClick_PPS200 =function(){  
         try {
                  var OACONO = userContext['CONO'];
				  columnPUNO = ListControl.ListView.GetValueByColumnName("PUNO");
				  columnWHLO = ListControl.ListView.GetValueByColumnName("WHLO");
				  varOBWHLO = ScriptUtil.GetFieldValue('OBWHLO');
				  console.log("columnPUNO------"+columnPUNO);
				  if(columnPUNO==""){
				  ConfirmDialog.ShowMessageDialog({
                        dialogType: "Error",
                        header: "Row Selection Error",
                        message: "You must select a row before clicking the Allocation."
                    });
                  return;
				  }
                  var auto=new MFormsAutomation();
                  auto.addStep(ActionType.Run, "PPS300");
			      auto.addStep(ActionType.Key, "F13");
                  auto.addStep(ActionType.Set, "");
			      auto.addField('WWSPIC','A');
			      auto.addStep(ActionType.Key, 'ENTER');
				  auto.addStep(ActionType.Key, 'ENTER');
				  auto.addField('WWWHLO',columnWHLO);
				  auto.addStep(ActionType.Set, "");
			      auto.addField('WWPUNO',columnPUNO); 
			      var uri = auto.toEncodedUri();
				  ScriptUtil.Launch(uri);
            } 
        catch (ex) { 
                this.debug.WriteLine(ex);
            }
        };
    return PPS200_POreceipt_H5_V1;
}();