// Print an order ticket to the Kitchen
boolean kot1 = false;
boolean kot2 = false;
boolean kot3 = false;
boolean change_kot1 = false;
boolean change_kot2 = false;
boolean change_kot3 = false;
//set KOT number
if (ticket.getProperty("KotNumber") == null){
ticket.setProperty("KotNumber",ticket.getName());
}
for(int i= 0; i < ticket.getLinesCount(); i++){
line = ticket.getLine(i);
// Set Discount(kotnum=NULL) to N/A so it does not error on next section.
if (line.getProperty("kotnum") == null){
line.setProperty("kotnum", "KOT1");
}
if (line.getProperty("sendstatus") == null){
line.setProperty("sendstatus", "No");
}
if((line.getProperty("kotnum").equals("KOT1")) && (line.getProperty("sendstatus").equals("No"))){
kot1 = true; //There is something to print to KOT1
}else if ((line.getProperty("kotnum").equals("KOT2")) && (line.getProperty("sendstatus").equals("No"))){
kot2 = true; //There is something to print to KOT2
}else if ((line.getProperty("kotnum").equals("KOT3")) && (line.getProperty("sendstatus").equals("No"))){
kot3 = true; //There is something to print to KOT3
}else if ((line.getProperty("kotnum").equals("KOT1")) && (line.getProperty("sendstatus").equals("Cancel"))){
change_kot1 = true; //There is something to change for KOT1
}else if ((line.getProperty("kotnum").equals("KOT2")) && (line.getProperty("sendstatus").equals("Cancel"))){
change_kot2 = true; //There is something to change for KOT2
}else if ((line.getProperty("kotnum").equals("KOT3")) && (line.getProperty("sendstatus").equals("Cancel"))){
change_kot3 = true; //There is something to change for KOT3
}
}
if ((change_kot1 && kot1) || (change_kot1 && !kot1)) {
sales.printTicket("Printer.KOT1_Change"); //Print changed kitchen items to KOT1 printer
}
if ((change_kot2 && kot2) || (change_kot2 && !kot2)) {
sales.printTicket("Printer.KOT2_Change"); //Print changed dessert items to KOT2 printer
}
if ((change_kot3 && kot3) || (change_kot3 && !kot3)) {
sales.printTicket("Printer.KOT3_Change"); //Print changed dessert items to KOT3 printer
}
if (kot1 && !change_kot1) {
sales.printTicket("Printer.KOT1"); //Print KOT1 items to KOT1 printer
}
if (kot2 && !change_kot2) {
sales.printTicket("Printer.KOT2"); //Print KOT2 items to KOT2 printer
}
if (kot3 && !change_kot3) {
sales.printTicket("Printer.KOT3"); //Print KOT3 items to KOT3 printer
}
//Show a nice message for confirmation
//if (kot1 && kot2 && kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to KOT1, KOT2 & KOT3.");
//} else if (kot1 && !kot2 && !kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT1.");
//} else if (!kot1 && kot2 && !kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT2.");
//} else if (!kot1 && !kot2 && kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT3.");
//} else if (kot1 && kot2 && !kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT1 & KOT2.");
//} else if (!kot1 && kot2 && kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT2 & KOT3.");
//} else if (kot1 && !kot2 && kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your order has been sent to the KOT1 & KOT3.");
//} else if (change_kot1 || change_kot2 || change_kot3){
//javax.swing.JOptionPane.showMessageDialog(null, "Your cancelled items have been sent.");
//} else {
//javax.swing.JOptionPane.showMessageDialog(null, "There is nothing new to send.", "Print Warning", JOptionPane.WARNING_MESSAGE);
//}
//Set kotnum property of item to Yes so it is not printed again
for(int i = ticket.getLinesCount()-1; i>= 0 ; i--){
line = ticket.getLine(i);
String a = line.getProperty("sendstatus");
String b = "Cancel";
if(((line.getProperty("kotnum").equals("KOT1")) || (line.getProperty("kotnum").equals("KOT2")) || (line.getProperty("kotnum").equals("KOT3"))) && (line.getProperty("sendstatus").equals("No"))){
line.setProperty("sendstatus", "Yes");
}
//Remove cancelled lines
if (a.equals(b)) {
ticket.removeLine(i);
sales.keepLine(line);
}
}
Leave a Reply