This script allow to control users who can cancel KOT. Use below script in event.removeline resource.
line = ticket.getLine(index); String a = line.getProperty("sendstatus"); String b = "Yes"; String c = "No"; String d = "N/A"; Integer myCount = 0; //Restrict KOT cancellation to Manage role if (a.equals(b) && !user.getRoleName().equals("Manager role")) { javax.swing.JOptionPane.showMessageDialog(null, "You are not allowed to cancel KOT!" ); removeLine.cancel=true; return "cancel"; } //get count of auxiliar after the main product for (i = index+1; i < ticket.getLinesCount(); i++) { if (ticket.getLine(i).isProductCom()){ myCount = myCount + 1; }else{ break; } } //Set SendStatus of sent items to Cancel if (a.equals(b) && !line.isProductCom()) { for (i = index + myCount; i>= index ; i--) { if (ticket.getLine(i).isProductCom() && ticket.getLine(i).getProperty("sendstatus").equals("Yes")){ ticket.getLine(i).setProperty("sendstatus", "Cancel"); }else if (ticket.getLine(i).isProductCom() && ticket.getLine(i).getProperty("sendstatus").equals("No")){ ticket.removeLine(i); }else{ break; } } line.setProperty("sendstatus", "Cancel"); } //Removelines of NOT sent items if ((a.equals(c) || a.equals(d))&& !line.isProductCom()) { for (i = index + myCount; i>= index ; i--) { if (ticket.getLine(i).isProductCom()){ ticket.removeLine(i); }else{ break; } } ticket.removeLine(index); }else if (a.equals(c) && line.isProductCom()) { ticket.removeLine(index); } //Cancel event removeLine.cancel=true;
Leave a Reply