Menu

#186 Auto Close Returns popup

0.54
open
nobody
None
2023-04-29
2021-11-08
No

Hi,

It would be useful if there was an option the popup showing the value the customer should get back in cash automatically closes in XX seconds.

Provided that this may not always be useful for anyone with an on/off button in the configuration screen.

Also, the button could be slightly ok/close button slightly larger compared to the product buttons.

Kind Regards,
B.

Discussion

  • DVBHardware

    DVBHardware - 2021-11-08

    The wise programmer said "Search and thou shall receive". Its in here somewhere, I can look at my script later today. I installed years ago.

     
    • Bart Devroey

      Bart Devroey - 2021-11-08

      Correct, maybe i used the wrong search terms :p..
      Thanks in advance..

       
      • DVBHardware

        DVBHardware - 2021-11-08

        Backup yours first
        There is no timeout, wanted to confirm customer had the correct change before clicking OK manually and to have on the screen when using an external CC machine

         
        • Bart Devroey

          Bart Devroey - 2021-11-08

          Big thanks for this!
          I will implement this in an hour of to...

          I also found this on the forum:

          JButton okButton = getOkButton( pane );
          okButton.setEnabled(false);
          JDialog dialog = pane.createDialog("Cash payment");
          dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          Timer t = new Timer(0, null);
          t.setDelay(1000);
          t.setRepeats(true);
          CountdownListener countdownListener = new CountdownListener( okButton, t );
          t.addActionListener( countdownListener );
          t.start();
              new Thread(new Runnable() {
                   void run() {
                      dialog.show();
                  } 
              }).start();
          
          }
          

          ​ I can try to apply this to your script :)

          Kind Regards,
          B.

           
        • Bart Devroey

          Bart Devroey - 2021-11-08

          It works :)

          //   Chromis POS - The New Face of Open Source POS 
          //   Copyright (c) (c) 2015-2016Chromis , previous uniCenta & Openbravo POS works   
          //
          //   This file is part of chromis oPOS
          //
          //   Chromis POS is free software: you can redistribute it and/or modify
          //   it under the terms of the GNU General Public License as published by
          //   the Free Software Foundation, either version 3 of the License, or
          //   (at your option) any later version.
          //
          //   Chromis POS is distributed in the hope that it will be useful,
          //   but WITHOUT ANY WARRANTY; without even the implied warranty of
          //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          //   GNU General Public License for more details.
          //
          //   You should have received a copy of the GNU General Public License
          //   along with Chromis POS.  If not, see <http://www.gnu.org/licenses/>.
          // **************************************************************************
          // Ticket.Close
          // This script displays the amount of Cash Change (CashTendered - TicketValue) to be given to Customer
          
          import java.awt.Font; 
          import javax.swing.plaf.FontUIResource; 
          import uk.chromis.pos.payment.PaymentInfo;
          import javax.swing.JOptionPane;
          import javax.swing.JDialog;
          import uk.chromis.pos.forms.AppConfig;
          import uk.chromis.pos.printer.TicketPrinterException;
          import uk.chromis.pos.forms.DataLogicSystem;
          import uk.chromis.pos.forms.AppLocal;
          
          import javax.swing.JButton;
          
          import javax.swing.JOptionPane;
          import javax.swing.Timer;
          
          
          boolean isCash = false;
          String change = "";
          PaymentInfo p = ticket.payments.getFirst();
          
          if ("cash".equals(p.getName())) {
              isCash = true;
              change = p.printChange();
          }
          
          
          
           private JButton getOkButton( Container cont ) {
                  Component[] components = cont.getComponents();
                  for( int k = 0; k < components.length; k++ ) {
                      Component comp = components[k];
          
                      if( comp instanceof JButton ) {
                          JButton button = (JButton)comp;
          
                          if( button.getText() == "OK" )
                              return button;
                      } else if( comp instanceof Container ) {
                          JButton button = getOkButton( (Container)comp );
                          if( button != null ) return button;
                      }
                  }
          
                  return null;
              }
          
              private class CountdownListener implements ActionListener {
                  private JButton _button;
                  private Timer _timer;
                  private int _ticks;
                  public CountdownListener( JButton button, Timer timer ) {
                      _button = button;
                      _timer = timer;
                      _ticks = 5;
                  }
          
          
                  public void actionPerformed(ActionEvent ae) {
                      if( _ticks > 0 ) {
                          _button.setText( "OK ("+_ticks+")" );
                          _button.setEnabled(true);       
                      } else {
                          _button.doClick();
                      }
                      --_ticks;
                  }
              }
          
          boolean isCash = false;
          String change = "";
          String paid = "";
          String total = "";
          
          PaymentInfo p = ticket.payments.getFirst();
          
          for (PaymentInfo p : ticket.payments){
          if ("cash".equals(p.getName())) {
              isCash = true;
              paid = p.printPaid();
              total = p.printTotal();
              change = p.printChange();
          } else {
               new Thread(new Runnable() {
                   void run() {
                       Thread.sleep(3000);
                       try {
                           m_TTP.printTicket(dlSystem.getResourceAsXML("Display.Message"));
                       } catch (TicketPrinterException ex) {
                           m_App.getDeviceTicket().getDeviceDisplay().writeVisor(AppLocal.APP_NAME, AppLocal.APP_VERSION);
                      } 
                  }
               }).start();
          }
          }
          
          // Get details of the original font before we change it otherwise all dialogboxes will use new settings
          JOptionPane pane = new JOptionPane();
          Font originalFont=pane.getFont();
          
          UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("ARIAL",Font.PLAIN,40))); 
          message = "<HTML><table>";
          message = message + "<tr><th style=\"text-align:left\">Te betalen : </th><th style=\"text-align:left\">" + total + "</th></tr>";
          message = message + "<tr><th style=\"text-align:left\">Ontvangen : </th><th style=\"text-align:left\">" + paid + "</th></tr>";  
          message = message + "<tr><th style=\"text-align:left color:#000000\">Wisselgeld : </th><th style=\"text-align:left\">" + change + "</th></tr>";
          message = message + "</table>";
          
          
          
          
           JLabel FontText = new JLabel(message);
           FontText.setFont (new Font ( "Arial", Font.BOLD, 36) );
          
          ticket.setProperty("Paid", paid);
          ticket.setProperty("change", change);
          if(isCash) {
          
          Object[] options = { "OK" };
          JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION,null, options);
          pane.setMessage(FontText);
          pane.setPreferredSize( new Dimension(450,300));
          
          JButton okButton = getOkButton( pane );
          okButton.setEnabled(false);
          JDialog dialog = pane.createDialog("Cash payment");
          dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          Timer t = new Timer(0, null);
          t.setDelay(1000);
          t.setRepeats(true);
          CountdownListener countdownListener = new CountdownListener( okButton, t );
          t.addActionListener( countdownListener );
          t.start();
              new Thread(new Runnable() {
                   void run() {
                      dialog.show();
                  } 
              }).start();
          
          }
          
          
          // Return to default settings
          UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font(originalFont.getName(),originalFont.getStyle(),originalFont.getSize())));
          
           
  • Si Ono

    Si Ono - 2023-04-29

    I have created this custom change screen. Larger display, larger dismiss button. If anyone is interested I can share my source code.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.